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.TwinCalcAlarms;
import com.jjt.calc.service.ITwinCalcAlarmsService;
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/calcAlarms")
public class TwinCalcAlarmsController extends BaseController{
    @Resource
    private ITwinCalcAlarmsService twinCalcAlarmsService;

    /**
     * 查询告警数据统计列表
     */
    @ApiOperation("查询告警数据统计列表")
    @PreAuthorize("@ss.hasPermi('calc:calcAlarms:list')")
    @GetMapping("/list")
    public TableDataInfo list(TwinCalcAlarms twinCalcAlarms)
    {
        startPage();
        List<TwinCalcAlarms> list = twinCalcAlarmsService.selectTwinCalcAlarmsList(twinCalcAlarms);
        return getDataTable(list);
    }

    /**
     * 导出告警数据统计列表
     */
    @ApiOperation("导出告警数据统计列表")
    @PreAuthorize("@ss.hasPermi('calc:calcAlarms:export')")
    @Log(title = "告警数据统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TwinCalcAlarms twinCalcAlarms)
    {
        List<TwinCalcAlarms> list = twinCalcAlarmsService.selectTwinCalcAlarmsList(twinCalcAlarms);
        ExcelUtil<TwinCalcAlarms> util = new ExcelUtil<TwinCalcAlarms>(TwinCalcAlarms.class);
        util.exportExcel(response, list, "告警数据统计数据");
    }

    /**
     * 获取告警数据统计详细信息
     */
    @ApiOperation("获取告警数据统计详细信息")
    @PreAuthorize("@ss.hasPermi('calc:calcAlarms:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(twinCalcAlarmsService.selectTwinCalcAlarmsById(id));
    }

    /**
     * 新增告警数据统计
     */
    @ApiOperation("新增告警数据统计")
    @PreAuthorize("@ss.hasPermi('calc:calcAlarms:add')")
    @Log(title = "告警数据统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TwinCalcAlarms twinCalcAlarms)
    {
        return toAjax(twinCalcAlarmsService.insertTwinCalcAlarms(twinCalcAlarms));
    }

    /**
     * 修改告警数据统计
     */
    @ApiOperation("修改告警数据统计")
    @PreAuthorize("@ss.hasPermi('calc:calcAlarms:edit')")
    @Log(title = "告警数据统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TwinCalcAlarms twinCalcAlarms)
    {
        return toAjax(twinCalcAlarmsService.updateTwinCalcAlarms(twinCalcAlarms));
    }

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