package com.ruoyi.project.asset.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.project.asset.domain.TLeakagePointsPatrol;
import com.ruoyi.project.asset.service.ITLeakagePointsPatrolService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 漏点巡检Controller
 * 
 * @author ruoyi
 * @date 2024-04-01
 */
@RestController
@RequestMapping("/asset/pointPatrol")
public class TLeakagePointsPatrolController extends BaseController
{
    @Autowired
    private ITLeakagePointsPatrolService tLeakagePointsPatrolService;

    /**
     * 查询漏点巡检列表
     */
    @PreAuthorize("@ss.hasPermi('asset:pointPatrol:list')")
    @GetMapping("/list")
    public TableDataInfo list(TLeakagePointsPatrol tLeakagePointsPatrol)
    {
        startPage();
        List<TLeakagePointsPatrol> list = tLeakagePointsPatrolService.selectTLeakagePointsPatrolList(tLeakagePointsPatrol);
        return getDataTable(list);
    }

    /**
     * 导出漏点巡检列表
     */
    @PreAuthorize("@ss.hasPermi('asset:pointPatrol:export')")
    @Log(title = "漏点巡检", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TLeakagePointsPatrol tLeakagePointsPatrol)
    {
        List<TLeakagePointsPatrol> list = tLeakagePointsPatrolService.selectTLeakagePointsPatrolList(tLeakagePointsPatrol);
        ExcelUtil<TLeakagePointsPatrol> util = new ExcelUtil<TLeakagePointsPatrol>(TLeakagePointsPatrol.class);
        util.exportExcel(response, list, "漏点巡检数据");
    }

    /**
     * 获取漏点巡检详细信息
     */
    @PreAuthorize("@ss.hasPermi('asset:pointPatrol:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tLeakagePointsPatrolService.selectTLeakagePointsPatrolById(id));
    }

    /**
     * 新增漏点巡检
     */
    @PreAuthorize("@ss.hasPermi('asset:pointPatrol:add')")
    @Log(title = "漏点巡检", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TLeakagePointsPatrol tLeakagePointsPatrol)
    {
        return toAjax(tLeakagePointsPatrolService.insertTLeakagePointsPatrol(tLeakagePointsPatrol));
    }

    /**
     * 修改漏点巡检
     */
    @PreAuthorize("@ss.hasPermi('asset:pointPatrol:edit')")
    @Log(title = "漏点巡检", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TLeakagePointsPatrol tLeakagePointsPatrol)
    {
        return toAjax(tLeakagePointsPatrolService.updateTLeakagePointsPatrol(tLeakagePointsPatrol));
    }

    /**
     * 删除漏点巡检
     */
    @PreAuthorize("@ss.hasPermi('asset:pointPatrol:remove')")
    @Log(title = "漏点巡检", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tLeakagePointsPatrolService.deleteTLeakagePointsPatrolByIds(ids));
    }
}
