package org.dromara.ems.report.controller;

import org.dromara.common.log.annotation.Log;
import org.dromara.ems.common.web.EmsBaseController;
import org.dromara.common.core.domain.R;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.ems.report.domain.EmsReportPointWater;
import org.dromara.ems.report.service.IEmsReportPointWaterService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 水整点数据Controller
 *
 * @author Yinq
 * @date 2024-05-22
 */
@RestController
@RequiredArgsConstructor

@RequestMapping("/ems/report/reportPointWater")
public class EmsReportPointWaterController extends EmsBaseController {
    
    private final IEmsReportPointWaterService emsReportPointWaterService;

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

    /**
     * 导出水整点数据列表
     */
    @SaCheckPermission("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.exportExcel(list, "水整点数据数据", EmsReportPointWater.class, response);
    }

    /**
     * 获取水整点数据详细信息
     */
    @SaCheckPermission("ems/report:reportPointWater:query")
    @GetMapping(value = "/{objId}")
    public R<?> getInfo(@PathVariable("objId") Long objId) {
        return success(emsReportPointWaterService.selectEmsReportPointWaterByObjId(objId));
    }

    /**
     * 新增水整点数据
     */
    @SaCheckPermission("ems/report:reportPointWater:add")
    @Log(title = "水整点数据", businessType = BusinessType.INSERT)
    @PostMapping
    public R<?> add(@RequestBody EmsReportPointWater emsReportPointWater) {
        return toAjax(emsReportPointWaterService.insertEmsReportPointWater(emsReportPointWater));
    }

    /**
     * 修改水整点数据
     */
    @SaCheckPermission("ems/report:reportPointWater:edit")
    @Log(title = "水整点数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<?> edit(@RequestBody EmsReportPointWater emsReportPointWater) {
        return toAjax(emsReportPointWaterService.updateEmsReportPointWater(emsReportPointWater));
    }

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