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

/**
 * 检修计划全流程管理Controller
 * 
 * @author ruoyi
 * @date 2024-12-05
 */
@RestController
@RequestMapping("/powerdistribution/process")
public class PdmMaintenanceProcessController extends BaseController
{
    @Autowired
    private IPdmMaintenanceProcessService pdmMaintenanceProcessService;

    /**
     * 查询检修计划全流程管理列表
     */
    @PreAuthorize("@ss.hasPermi('powerdistribution:process:list')")
    @GetMapping("/list")
    public TableDataInfo list(PdmMaintenanceProcess pdmMaintenanceProcess)
    {
        startPage();
        List<PdmMaintenanceProcess> list = pdmMaintenanceProcessService.selectPdmMaintenanceProcessList(pdmMaintenanceProcess);
        return getDataTable(list);
    }

    /**
     * 导出检修计划全流程管理列表
     */
    @PreAuthorize("@ss.hasPermi('powerdistribution:process:export')")
    @Log(title = "检修计划全流程管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PdmMaintenanceProcess pdmMaintenanceProcess)
    {
        List<PdmMaintenanceProcess> list = pdmMaintenanceProcessService.selectPdmMaintenanceProcessList(pdmMaintenanceProcess);
        ExcelUtil<PdmMaintenanceProcess> util = new ExcelUtil<PdmMaintenanceProcess>(PdmMaintenanceProcess.class);
        util.exportExcel(response, list, "检修计划全流程管理数据");
    }

    /**
     * 获取检修计划全流程管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('powerdistribution:process:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pdmMaintenanceProcessService.selectPdmMaintenanceProcessById(id));
    }

    /**
     * 新增检修计划全流程管理
     */
    @PreAuthorize("@ss.hasPermi('powerdistribution:process:add')")
    @Log(title = "检修计划全流程管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PdmMaintenanceProcess pdmMaintenanceProcess)
    {
        return toAjax(pdmMaintenanceProcessService.insertPdmMaintenanceProcess(pdmMaintenanceProcess));
    }

    /**
     * 修改检修计划全流程管理
     */
    @PreAuthorize("@ss.hasPermi('powerdistribution:process:edit')")
    @Log(title = "检修计划全流程管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PdmMaintenanceProcess pdmMaintenanceProcess)
    {
        return toAjax(pdmMaintenanceProcessService.updatePdmMaintenanceProcess(pdmMaintenanceProcess));
    }

    /**
     * 删除检修计划全流程管理
     */
    @PreAuthorize("@ss.hasPermi('powerdistribution:process:remove')")
    @Log(title = "检修计划全流程管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pdmMaintenanceProcessService.deletePdmMaintenanceProcessByIds(ids));
    }
}
