package org.dromara.ems.record.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.record.domain.EmsRecordSteamInstant;
import org.dromara.ems.record.service.IEmsRecordSteamInstantService;
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/record/recordSteamInstant")
public class EmsRecordSteamInstantController extends EmsBaseController {
    
    private final IEmsRecordSteamInstantService emsRecordSteamInstantService;

    /**
     * 查询蒸汽实时数据列表
     */
    @SaCheckPermission("ems/record:recordSteamInstant:list")
    @GetMapping("/list")
    public TableDataInfo list(EmsRecordSteamInstant emsRecordSteamInstant) {
        startPage();
        List<EmsRecordSteamInstant> list = emsRecordSteamInstantService.selectEmsRecordSteamInstantList(emsRecordSteamInstant);
        return getDataTable(list);
    }

    /**
     * 导出蒸汽实时数据列表
     */
    @SaCheckPermission("ems/record:recordSteamInstant:export")
    @Log(title = "蒸汽实时数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmsRecordSteamInstant emsRecordSteamInstant) {
        List<EmsRecordSteamInstant> list = emsRecordSteamInstantService.selectEmsRecordSteamInstantList(emsRecordSteamInstant);
        ExcelUtil.exportExcel(list, "蒸汽实时数据数据", EmsRecordSteamInstant.class, response);
    }

    /**
     * 获取蒸汽实时数据详细信息
     */
    @SaCheckPermission("ems/record:recordSteamInstant:query")
    @GetMapping(value = "/{objId}")
    public R<?> getInfo(@PathVariable("objId") Long objId) {
        return success(emsRecordSteamInstantService.selectEmsRecordSteamInstantByObjId(objId));
    }

    /**
     * 新增蒸汽实时数据
     */
    @SaCheckPermission("ems/record:recordSteamInstant:add")
    @Log(title = "蒸汽实时数据", businessType = BusinessType.INSERT)
    @PostMapping
    public R<?> add(@RequestBody EmsRecordSteamInstant emsRecordSteamInstant) {
        return toAjax(emsRecordSteamInstantService.insertEmsRecordSteamInstant(emsRecordSteamInstant));
    }

    /**
     * 修改蒸汽实时数据
     */
    @SaCheckPermission("ems/record:recordSteamInstant:edit")
    @Log(title = "蒸汽实时数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<?> edit(@RequestBody EmsRecordSteamInstant emsRecordSteamInstant) {
        return toAjax(emsRecordSteamInstantService.updateEmsRecordSteamInstant(emsRecordSteamInstant));
    }

    /**
     * 删除蒸汽实时数据
     */
    @SaCheckPermission("ems/record:recordSteamInstant:remove")
    @Log(title = "蒸汽实时数据", businessType = BusinessType.DELETE)
    @DeleteMapping("/{objIds}")
    public R<?> remove(@PathVariable Long[] objIds) {
        return toAjax(emsRecordSteamInstantService.deleteEmsRecordSteamInstantByObjIds(objIds));
    }
}
