package com.dcs.hnyz.controller;

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

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
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.dcs.common.annotation.Log;
import com.dcs.common.core.controller.BaseController;
import com.dcs.common.core.domain.AjaxResult;
import com.dcs.common.enums.BusinessType;
import com.dcs.hnyz.domain.AlarmEvent;
import com.dcs.hnyz.service.IAlarmEventService;
import com.dcs.common.utils.poi.ExcelUtil;
import com.dcs.common.core.page.TableDataInfo;

/**
 * 告警中心管理Controller
 * 
 * @author hmy
 * @date 2025-04-30
 */
@Api(tags = "告警中心管理")
@RestController
@RequestMapping("/hnyz/alarmEvent")
public class AlarmEventController extends BaseController
{
    @Autowired
    private IAlarmEventService alarmEventService;

    /**
     * 查询告警中心管理列表
     */
    @PreAuthorize("@ss.hasPermi('hnyz:alarmEvent:list')")
    @GetMapping("/list")
    @ApiOperation("查询告警中心管理列表")
    public TableDataInfo list(@ApiParam("告警信息对象") AlarmEvent alarmEvent)
    {
        startPage();
        List<AlarmEvent> list = alarmEventService.selectAlarmEventList(alarmEvent);
        return getDataTable(list);
    }

    /**
     * 导出告警中心管理列表
     */
    @PreAuthorize("@ss.hasPermi('hnyz:alarmEvent:export')")
    @Log(title = "告警中心管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AlarmEvent alarmEvent)
    {
        List<AlarmEvent> list = alarmEventService.selectAlarmEventList(alarmEvent);
        ExcelUtil<AlarmEvent> util = new ExcelUtil<AlarmEvent>(AlarmEvent.class);
        util.exportExcel(response, list, "告警中心管理数据");
    }

    /**
     * 获取告警中心管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('hnyz:alarmEvent:query')")
    @GetMapping(value = "/{alarmId}")
    @ApiOperation("获取告警中心管理详细信息")
    public AjaxResult getInfo(@ApiParam("告警id") @PathVariable("alarmId") Long alarmId)
    {
        return success(alarmEventService.selectAlarmEventByAlarmId(alarmId));
    }

    /**
     * 新增告警中心管理
     */
    @ApiOperation("新增告警信息管理")
    @PreAuthorize("@ss.hasPermi('hnyz:alarmEvent:add')")
    @Log(title = "告警中心管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@ApiParam("告警信息对象") @RequestBody AlarmEvent alarmEvent)
    {
        return toAjax(alarmEventService.insertAlarmEvent(alarmEvent));
    }

    /**
     * 修改告警中心管理
     */
    @ApiOperation("修改告警信息")
    @PreAuthorize("@ss.hasPermi('hnyz:alarmEvent:edit')")
    @Log(title = "告警中心管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@ApiParam("告警信息") @RequestBody AlarmEvent alarmEvent)
    {
        return toAjax(alarmEventService.updateAlarmEvent(alarmEvent));
    }

    /**
     * 删除告警中心管理
     */
    @ApiOperation("删除告警信息")
    @PreAuthorize("@ss.hasPermi('hnyz:alarmEvent:remove')")
    @Log(title = "告警中心管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{alarmIds}")
    public AjaxResult remove(@ApiParam("告警信息id数组，中间用英文逗号隔开") @PathVariable Long[] alarmIds)
    {
        return toAjax(alarmEventService.deleteAlarmEventByAlarmIds(alarmIds));
    }
}
