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.EmsRecordWaterInstant;
import org.dromara.ems.record.service.IEmsRecordWaterInstantService;
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-14
 */
@RestController
@RequiredArgsConstructor

@RequestMapping("/ems/record/recordWaterInstant")
public class EmsRecordWaterInstantController extends EmsBaseController
{

    private final IEmsRecordWaterInstantService emsRecordWaterInstantService;

    /**
     * 查询水实时数据列表
     */
    @SaCheckPermission("ems/record:recordWaterInstant:list")
    @GetMapping("/list")
    public TableDataInfo list(EmsRecordWaterInstant emsRecordWaterInstant)
    {
        startPage();
        List<EmsRecordWaterInstant> list = emsRecordWaterInstantService.selectEmsRecordWaterInstantList(emsRecordWaterInstant);
        return getDataTable(list);
    }

    /**
     * 导出水实时数据列表
     */
    @SaCheckPermission("ems/record:recordWaterInstant:export")
    @Log(title = "水实时数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmsRecordWaterInstant emsRecordWaterInstant)
    {
        List<EmsRecordWaterInstant> list = emsRecordWaterInstantService.selectEmsRecordWaterInstantList(emsRecordWaterInstant);
        ExcelUtil.exportExcel(list, "水实时数据数据", EmsRecordWaterInstant.class, response);
    }

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

    /**
     * 新增水实时数据
     */
    @SaCheckPermission("ems/record:recordWaterInstant:add")
    @Log(title = "水实时数据", businessType = BusinessType.INSERT)
    @PostMapping
    public R<?> add(@RequestBody EmsRecordWaterInstant emsRecordWaterInstant)
    {
        return toAjax(emsRecordWaterInstantService.insertEmsRecordWaterInstant(emsRecordWaterInstant));
    }

    /**
     * 修改水实时数据
     */
    @SaCheckPermission("ems/record:recordWaterInstant:edit")
    @Log(title = "水实时数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<?> edit(@RequestBody EmsRecordWaterInstant emsRecordWaterInstant)
    {
        return toAjax(emsRecordWaterInstantService.updateEmsRecordWaterInstant(emsRecordWaterInstant));
    }

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