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.EmsReportPointSteam;
import org.dromara.ems.report.service.IEmsReportPointSteamService;
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-06-11
 */
@RestController
@RequiredArgsConstructor

@RequestMapping("/ems/report/reportPointSteam")
public class EmsReportPointSteamController extends EmsBaseController {

    private final IEmsReportPointSteamService emsReportPointSteamService;

    /**
     * 查询蒸汽整点数据列表
     */
    @SaCheckPermission("ems/report:reportPointSteam:list")
    @GetMapping("/list")
    public TableDataInfo list(EmsReportPointSteam emsReportPointSteam) {
        startPage();
        List<EmsReportPointSteam> list = emsReportPointSteamService.selectEmsReportPointSteamList(emsReportPointSteam);
        return getDataTable(list);
    }

    /**
     * 导出蒸汽整点数据列表
     */
    @SaCheckPermission("ems/report:reportPointSteam:export")
    @Log(title = "蒸汽整点数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmsReportPointSteam emsReportPointSteam) {
        List<EmsReportPointSteam> list = emsReportPointSteamService.selectEmsReportPointSteamList(emsReportPointSteam);
        ExcelUtil.exportExcel(list, "蒸汽整点数据数据", EmsReportPointSteam.class, response);
    }

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

    /**
     * 新增蒸汽整点数据
     */
    @SaCheckPermission("ems/report:reportPointSteam:add")
    @Log(title = "蒸汽整点数据", businessType = BusinessType.INSERT)
    @PostMapping
    public R<?> add(@RequestBody EmsReportPointSteam emsReportPointSteam) {
        return toAjax(emsReportPointSteamService.insertEmsReportPointSteam(emsReportPointSteam));
    }

    /**
     * 修改蒸汽整点数据
     */
    @SaCheckPermission("ems/report:reportPointSteam:edit")
    @Log(title = "蒸汽整点数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<?> edit(@RequestBody EmsReportPointSteam emsReportPointSteam) {
        return toAjax(emsReportPointSteamService.updateEmsReportPointSteam(emsReportPointSteam));
    }

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