package com.hw.dms.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
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.hw.common.log.annotation.Log;
import com.hw.common.log.enums.BusinessType;
import com.hw.common.security.annotation.RequiresPermissions;
import com.hw.dms.domain.DmsPlanInspect;
import com.hw.dms.service.IDmsPlanInspectService;
import com.hw.common.core.web.controller.BaseController;
import com.hw.common.core.web.domain.AjaxResult;
import com.hw.common.core.utils.poi.ExcelUtil;
import com.hw.common.core.web.page.TableDataInfo;

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

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

    /**
     * 导出巡检计划信息列表
     */
    @RequiresPermissions("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, "巡检计划信息数据");
    }

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

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

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

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