package com.ruoyi.powerdistribution.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.powerdistribution.domain.PdmExamineRequire;
import com.ruoyi.powerdistribution.service.IPdmExamineRequireService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 时户数要求
Controller
 *
 * @author ruoyi
 * @date 2025-01-02
 */
@RestController
@RequestMapping("/powerdistribution/pdmExamineRequire")
public class PdmExamineRequireController extends BaseController
{
    @Autowired
    private IPdmExamineRequireService pdmExamineRequireService;

    /**
     * 查询时户数要求
列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PdmExamineRequire pdmExamineRequire)
    {
        startPage();
        List<PdmExamineRequire> list = pdmExamineRequireService.selectPdmExamineRequireList(pdmExamineRequire);
        return getDataTable(list);
    }

    /**
     * 导出时户数要求
列表
     */
    @Log(title = "时户数要求 ", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PdmExamineRequire pdmExamineRequire)
    {
        List<PdmExamineRequire> list = pdmExamineRequireService.selectPdmExamineRequireList(pdmExamineRequire);
        ExcelUtil<PdmExamineRequire> util = new ExcelUtil<PdmExamineRequire>(PdmExamineRequire.class);
        util.exportExcel(response, list, "时户数要求 数据");
    }

    /**
     * 获取时户数要求
详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pdmExamineRequireService.selectPdmExamineRequireById(id));
    }

    /**
     * 新增时户数要求

     */
    @Log(title = "时户数要求 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PdmExamineRequire pdmExamineRequire)
    {
        return toAjax(pdmExamineRequireService.insertPdmExamineRequire(pdmExamineRequire));
    }

    /**
     * 修改时户数要求

     */
    @Log(title = "时户数要求 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PdmExamineRequire pdmExamineRequire)
    {
        return toAjax(pdmExamineRequireService.updatePdmExamineRequire(pdmExamineRequire));
    }

    /**
     * 删除时户数要求

     */
    @Log(title = "时户数要求 ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pdmExamineRequireService.deletePdmExamineRequireByIds(ids));
    }
}
