package com.ruoyi.ems.report.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.ems.report.domain.EmsReportPointWater;
import com.ruoyi.ems.report.service.IEmsReportPointWaterService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 水整点数据Controller
 *
 * @author Yinq
 * @date 2024-05-22
 */
@RestController
@RequestMapping("/ems/report/reportPointWater")
public class EmsReportPointWaterController extends BaseController {
    @Autowired
    private IEmsReportPointWaterService emsReportPointWaterService;

    /**
     * 查询水整点数据列表
     */
    @PreAuthorize("@ss.hasPermi('ems/report:reportPointWater:list')")
    @GetMapping("/list")
    public TableDataInfo list(EmsReportPointWater emsReportPointWater) {
        startPage();
        List<EmsReportPointWater> list = emsReportPointWaterService.selectEmsReportPointWaterList(emsReportPointWater);
        return getDataTable(list);
    }

    /**
     * 导出水整点数据列表
     */
    @PreAuthorize("@ss.hasPermi('ems/report:reportPointWater:export')")
    @Log(title = "水整点数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmsReportPointWater emsReportPointWater) {
        List<EmsReportPointWater> list = emsReportPointWaterService.selectEmsReportPointWaterList(emsReportPointWater);
        ExcelUtil<EmsReportPointWater> util = new ExcelUtil<EmsReportPointWater>(EmsReportPointWater.class);
        util.exportExcel(response, list, "水整点数据数据");
    }

    /**
     * 获取水整点数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('ems/report:reportPointWater:query')")
    @GetMapping(value = "/{objId}")
    public AjaxResult getInfo(@PathVariable("objId") Long objId) {
        return success(emsReportPointWaterService.selectEmsReportPointWaterByObjId(objId));
    }

    /**
     * 新增水整点数据
     */
    @PreAuthorize("@ss.hasPermi('ems/report:reportPointWater:add')")
    @Log(title = "水整点数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmsReportPointWater emsReportPointWater) {
        return toAjax(emsReportPointWaterService.insertEmsReportPointWater(emsReportPointWater));
    }

    /**
     * 修改水整点数据
     */
    @PreAuthorize("@ss.hasPermi('ems/report:reportPointWater:edit')")
    @Log(title = "水整点数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmsReportPointWater emsReportPointWater) {
        emsReportPointWater.setUpdateBy(getUsername());
        return toAjax(emsReportPointWaterService.updateEmsReportPointWater(emsReportPointWater));
    }

    /**
     * 删除水整点数据
     */
    @PreAuthorize("@ss.hasPermi('ems/report:reportPointWater:remove')")
    @Log(title = "水整点数据", businessType = BusinessType.DELETE)
    @DeleteMapping("/{objIds}")
    public AjaxResult remove(@PathVariable Long[] objIds) {
        return toAjax(emsReportPointWaterService.deleteEmsReportPointWaterByObjIds(objIds));
    }
}
