package com.jjt.calc.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
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.jjt.common.annotation.Log;
import com.jjt.common.core.controller.BaseController;
import com.jjt.common.core.domain.AjaxResult;
import com.jjt.common.enums.BusinessType;
import com.jjt.calc.domain.TwinRecordAlarms;
import com.jjt.calc.service.ITwinRecordAlarmsService;
import com.jjt.common.utils.poi.ExcelUtil;
import com.jjt.common.core.page.TableDataInfo;

/**
 * 告警数据记录Controller
 *
 * @author wukai
 * @date 2025-01-18
 */
@Api(tags="告警数据记录")
@RestController
@RequestMapping("/calc/recordAlarms")
public class TwinRecordAlarmsController extends BaseController{
    @Resource
    private ITwinRecordAlarmsService twinRecordAlarmsService;

    /**
     * 查询告警数据记录列表
     */
    @ApiOperation("查询告警数据记录列表")
    @PreAuthorize("@ss.hasPermi('calc:recordAlarms:list')")
    @GetMapping("/list")
    public TableDataInfo list(TwinRecordAlarms twinRecordAlarms)
    {
        startPage();
        List<TwinRecordAlarms> list = twinRecordAlarmsService.selectTwinRecordAlarmsList(twinRecordAlarms);
        return getDataTable(list);
    }

    /**
     * 导出告警数据记录列表
     */
    @ApiOperation("导出告警数据记录列表")
    @PreAuthorize("@ss.hasPermi('calc:recordAlarms:export')")
    @Log(title = "告警数据记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TwinRecordAlarms twinRecordAlarms)
    {
        List<TwinRecordAlarms> list = twinRecordAlarmsService.selectTwinRecordAlarmsList(twinRecordAlarms);
        ExcelUtil<TwinRecordAlarms> util = new ExcelUtil<TwinRecordAlarms>(TwinRecordAlarms.class);
        util.exportExcel(response, list, "告警数据记录数据");
    }

    /**
     * 获取告警数据记录详细信息
     */
    @ApiOperation("获取告警数据记录详细信息")
    @PreAuthorize("@ss.hasPermi('calc:recordAlarms:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(twinRecordAlarmsService.selectTwinRecordAlarmsById(id));
    }

    /**
     * 新增告警数据记录
     */
    @ApiOperation("新增告警数据记录")
    @PreAuthorize("@ss.hasPermi('calc:recordAlarms:add')")
    @Log(title = "告警数据记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TwinRecordAlarms twinRecordAlarms)
    {
        return toAjax(twinRecordAlarmsService.insertTwinRecordAlarms(twinRecordAlarms));
    }

    /**
     * 修改告警数据记录
     */
    @ApiOperation("修改告警数据记录")
    @PreAuthorize("@ss.hasPermi('calc:recordAlarms:edit')")
    @Log(title = "告警数据记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TwinRecordAlarms twinRecordAlarms)
    {
        return toAjax(twinRecordAlarmsService.updateTwinRecordAlarms(twinRecordAlarms));
    }

    /**
     * 删除告警数据记录
     */
    @ApiOperation("删除告警数据记录")
    @PreAuthorize("@ss.hasPermi('calc:recordAlarms:remove')")
    @Log(title = "告警数据记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(twinRecordAlarmsService.deleteTwinRecordAlarmsByIds(ids));
    }
}
