package com.aucma.dms.controller;

import com.aucma.common.core.controller.BaseController;
import com.aucma.common.core.domain.AjaxResult;
import com.aucma.common.core.page.TableDataInfo;
import com.aucma.common.utils.poi.ExcelUtil;
import com.aucma.dms.domain.DmsPlanInspect;
import com.aucma.dms.service.IDmsPlanInspectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

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

/**
 * 巡检计划信息Controller
 * 
 * @author Open Platform
 * @date 2024-01-17
 */
@RestController
@RequestMapping("/dms/dmsPlanInspect")
public class DmsPlanInspectController extends BaseController
{

    @Autowired
    private IDmsPlanInspectService dmsPlanInspectService;

    /**
     * 查询巡检计划信息列表
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsPlanInspect:list')" )
    @GetMapping("/list")
    public TableDataInfo list(DmsPlanInspect dmsPlanInspect)
    {
        startPage();
        List<DmsPlanInspect> list = dmsPlanInspectService.selectDmsPlanInspectList(dmsPlanInspect);
        return getDataTable(list);
    }

    /**
     * 导出巡检计划信息列表
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsPlanInspect:export')" )
    ////@Log(title = "巡检计划信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DmsPlanInspect dmsPlanInspect)
    {
        List<DmsPlanInspect> list = dmsPlanInspectService.selectDmsPlanInspectList(dmsPlanInspect);
        ExcelUtil<DmsPlanInspect> util = new ExcelUtil<DmsPlanInspect>(DmsPlanInspect.class);
        util.exportExcel(response, list, "巡检计划信息数据");
    }

    /**
     * 获取巡检计划信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsPlanInspect:remove')" )
    @GetMapping(value = "/{planInspectId}")
    public AjaxResult getInfo(@PathVariable("planInspectId") Long planInspectId)
    {
        return success(dmsPlanInspectService.selectDmsPlanInspectByPlanInspectId(planInspectId));
    }

    /**
     * 新增巡检计划信息
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsPlanInspect:add')" )
    ////@Log(title = "巡检计划信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DmsPlanInspect dmsPlanInspect)
    {
        return toAjax(dmsPlanInspectService.insertDmsPlanInspect(dmsPlanInspect));
    }

    /**
     * 修改巡检计划信息
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsPlanInspect:edit')" )
    ////@Log(title = "巡检计划信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DmsPlanInspect dmsPlanInspect)
    {
        return toAjax(dmsPlanInspectService.updateDmsPlanInspect(dmsPlanInspect));
    }

    /**
     * 删除巡检计划信息
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsPlanInspect:remove')" )
    ////@Log(title = "巡检计划信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{planInspectIds}")
    public AjaxResult remove(@PathVariable Long[] planInspectIds)
    {
        return toAjax(dmsPlanInspectService.deleteDmsPlanInspectByPlanInspectIds(planInspectIds));
    }
}
