package com.ruoyi.project.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.domain.TrsSiteUpdate;
import com.ruoyi.project.service.ITrsSiteUpdateService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 更新监测Controller
 * 
 * @author ruoyi
 * @date 2025-06-09
 */
@Controller
@RequestMapping("/project/monitoring")
public class TrsSiteUpdateController extends BaseController
{
    private String prefix = "project/monitoring";

    @Autowired
    private ITrsSiteUpdateService trsSiteUpdateService;

    @RequiresPermissions("project:monitoring:view")
    @GetMapping()
    public String monitoring()
    {
        return prefix + "/monitoring";
    }

    /**
     * 查询更新监测列表
     */
    @RequiresPermissions("project:monitoring:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TrsSiteUpdate trsSiteUpdate)
    {
        startPage();
        List<TrsSiteUpdate> list = trsSiteUpdateService.selectTrsSiteUpdateList(trsSiteUpdate);
        return getDataTable(list);
    }

    /**
     * 导出更新监测列表
     */
    @RequiresPermissions("project:monitoring:export")
    @Log(title = "更新监测", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TrsSiteUpdate trsSiteUpdate)
    {
        List<TrsSiteUpdate> list = trsSiteUpdateService.selectTrsSiteUpdateList(trsSiteUpdate);
        ExcelUtil<TrsSiteUpdate> util = new ExcelUtil<TrsSiteUpdate>(TrsSiteUpdate.class);
        return util.exportExcel(list, "更新监测数据");
    }

    /**
     * 新增更新监测
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存更新监测
     */
    @RequiresPermissions("project:monitoring:add")
    @Log(title = "更新监测", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TrsSiteUpdate trsSiteUpdate)
    {
        return toAjax(trsSiteUpdateService.insertTrsSiteUpdate(trsSiteUpdate));
    }

    /**
     * 修改更新监测
     */
    @RequiresPermissions("project:monitoring:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TrsSiteUpdate trsSiteUpdate = trsSiteUpdateService.selectTrsSiteUpdateById(id);
        mmap.put("trsSiteUpdate", trsSiteUpdate);
        return prefix + "/edit";
    }

    /**
     * 修改保存更新监测
     */
    @RequiresPermissions("project:monitoring:edit")
    @Log(title = "更新监测", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TrsSiteUpdate trsSiteUpdate)
    {
        return toAjax(trsSiteUpdateService.updateTrsSiteUpdate(trsSiteUpdate));
    }

    /**
     * 删除更新监测
     */
    @RequiresPermissions("project:monitoring:remove")
    @Log(title = "更新监测", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(trsSiteUpdateService.deleteTrsSiteUpdateByIds(ids));
    }
}
