package com.ruoyi.project.sems.controller;

import java.util.List;
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.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.sems.domain.TReportPatrol;
import com.ruoyi.project.sems.service.ITReportPatrolService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 月度检查巡检记录Controller
 *
 * @author ruoyi
 * @date 2021-09-01
 */
@RestController
@RequestMapping("/sems/patrol")
public class TReportPatrolController extends BaseController
{
    @Autowired
    private ITReportPatrolService tReportPatrolService;

    /**
     * 查询月度检查巡检记录列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TReportPatrol tReportPatrol)
    {
        startPage();
        List<TReportPatrol> list = tReportPatrolService.selectTReportPatrolList(tReportPatrol);
        return getDataTable(list);
    }

    /**
     * 导出月度检查巡检记录列表
     */
    @Log(title = "月度检查巡检记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TReportPatrol tReportPatrol)
    {
        List<TReportPatrol> list = tReportPatrolService.selectTReportPatrolList(tReportPatrol);
        ExcelUtil<TReportPatrol> util = new ExcelUtil<TReportPatrol>(TReportPatrol.class);
        return util.exportExcel(list, "patrol");
    }

    /**
     * 获取月度检查巡检记录详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tReportPatrolService.selectTReportPatrolById(id));
    }

    /**
     * 新增月度检查巡检记录
     */
    @Log(title = "月度检查巡检记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TReportPatrol tReportPatrol)
    {
        return toAjax(tReportPatrolService.insertTReportPatrol(tReportPatrol));
    }

    /**
     * 修改月度检查巡检记录
     */
    @Log(title = "月度检查巡检记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TReportPatrol tReportPatrol)
    {
        return toAjax(tReportPatrolService.updateTReportPatrol(tReportPatrol));
    }

    /**
     * 删除月度检查巡检记录
     */
    @Log(title = "月度检查巡检记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tReportPatrolService.deleteTReportPatrolByIds(ids));
    }
}
