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.PdmExamineRoleDetail;
import com.ruoyi.powerdistribution.service.IPdmExamineRoleDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 时户数考核规则明细Controller
 *
 * @author ruoyi
 * @date 2024-12-30
 */
@Api(value = "PdmExamineRoleDetailController", tags = "时户数考核规则明细")
@RestController
@RequestMapping("/power/examineRoleDetail")
public class PdmExamineRoleDetailController extends BaseController
{
    @Autowired
    private IPdmExamineRoleDetailService pdmExamineRoleDetailService;

    /**
     * 查询时户数考核规则明细列表
     */
    @ApiOperation(value = "查询时户数考核规则明细列表")
    @PreAuthorize("@ss.hasPermi('system:detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(PdmExamineRoleDetail pdmExamineRoleDetail)
    {
        startPage();
        List<PdmExamineRoleDetail> list = pdmExamineRoleDetailService.selectPdmExamineRoleDetailList(pdmExamineRoleDetail);
        return getDataTable(list);
    }

    /**
     * 导出时户数考核规则明细列表
     */
    @PreAuthorize("@ss.hasPermi('system:detail:export')")
    @Log(title = "时户数考核规则明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PdmExamineRoleDetail pdmExamineRoleDetail)
    {
        List<PdmExamineRoleDetail> list = pdmExamineRoleDetailService.selectPdmExamineRoleDetailList(pdmExamineRoleDetail);
        ExcelUtil<PdmExamineRoleDetail> util = new ExcelUtil<PdmExamineRoleDetail>(PdmExamineRoleDetail.class);
        util.exportExcel(response, list, "时户数考核规则明细数据");
    }

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

    /**
     * 新增时户数考核规则明细
     */
    @ApiOperation(value = "新增时户数考核规则明细")
    @PreAuthorize("@ss.hasPermi('system:detail:add')")
    @Log(title = "时户数考核规则明细", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody PdmExamineRoleDetail pdmExamineRoleDetail)
    {
        return toAjax(pdmExamineRoleDetailService.insertPdmExamineRoleDetail(pdmExamineRoleDetail));
    }

    /**
     * 修改时户数考核规则明细
     */
    @ApiOperation(value = "修改时户数考核规则明细")
    @PreAuthorize("@ss.hasPermi('system:detail:edit')")
    @Log(title = "时户数考核规则明细", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody PdmExamineRoleDetail pdmExamineRoleDetail)
    {
        return toAjax(pdmExamineRoleDetailService.updatePdmExamineRoleDetail(pdmExamineRoleDetail));
    }

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