package com.ruoyi.powerdistribution.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.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.PdmExamineRoleTarget;
import com.ruoyi.powerdistribution.service.IPdmExamineRoleTargetService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 时户数考核规则分级Controller
 *
 * @author ruoyi
 * @date 2024-12-30
 */
@Api(value = "PdmExamineRoleTargetController", tags = "时户数考核规则分级")
@RestController
@RequestMapping("/power/examineRoleTarget")
public class PdmExamineRoleTargetController extends BaseController
{
    @Autowired
    private IPdmExamineRoleTargetService pdmExamineRoleTargetService;

    /**
     * 查询时户数考核规则分级列表
     */
    @ApiOperation(value = "查询时户数考核规则分级列表")
    @PreAuthorize("@ss.hasPermi('system:target:list')")
    @GetMapping("/list")
    public TableDataInfo list(PdmExamineRoleTarget pdmExamineRoleTarget)
    {
        startPage();
        List<PdmExamineRoleTarget> list = pdmExamineRoleTargetService.selectPdmExamineRoleTargetList(pdmExamineRoleTarget);
        return getDataTable(list);
    }

    /**
     * 导出时户数考核规则分级列表
     */
    @PreAuthorize("@ss.hasPermi('system:target:export')")
    @Log(title = "时户数考核规则分级", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PdmExamineRoleTarget pdmExamineRoleTarget)
    {
        List<PdmExamineRoleTarget> list = pdmExamineRoleTargetService.selectPdmExamineRoleTargetList(pdmExamineRoleTarget);
        ExcelUtil<PdmExamineRoleTarget> util = new ExcelUtil<PdmExamineRoleTarget>(PdmExamineRoleTarget.class);
        util.exportExcel(response, list, "时户数考核规则分级数据");
    }

    /**
     * 获取时户数考核规则分级详细信息
     */
    @ApiOperation(value = "获取时户数考核规则分级详细信息")
    @PreAuthorize("@ss.hasPermi('system:target:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pdmExamineRoleTargetService.selectPdmExamineRoleTargetById(id));
    }

    /**
     * 新增时户数考核规则分级
     */
    @ApiOperation(value = "新增时户数考核规则分级")
    @PreAuthorize("@ss.hasPermi('system:target:add')")
    @Log(title = "时户数考核规则分级", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PdmExamineRoleTarget pdmExamineRoleTarget)
    {
        return toAjax(pdmExamineRoleTargetService.insertPdmExamineRoleTarget(pdmExamineRoleTarget));
    }

    /**
     * 修改时户数考核规则分级
     */
    @ApiOperation(value = "修改时户数考核规则分级")
    @PreAuthorize("@ss.hasPermi('system:target:edit')")
    @Log(title = "时户数考核规则分级", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody PdmExamineRoleTarget pdmExamineRoleTarget)
    {
        return toAjax(pdmExamineRoleTargetService.updatePdmExamineRoleTarget(pdmExamineRoleTarget));
    }

    /**
     * 删除时户数考核规则分级
     */
    @ApiOperation(value = "删除时户数考核规则分级")
    @PreAuthorize("@ss.hasPermi('system:target:remove')")
    @Log(title = "时户数考核规则分级", businessType = BusinessType.DELETE)
	@GetMapping("delete/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pdmExamineRoleTargetService.deletePdmExamineRoleTargetByIds(ids));
    }
}
