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.AlarmConfig;
import com.dcs.hnyz.service.IAlarmConfigService;
import com.dcs.common.utils.poi.ExcelUtil;
import com.dcs.common.core.page.TableDataInfo;

/**
 * 告警配置管理Controller
 * 
 * @author hmy
 * @date 2025-05-22
 */
@Api(tags = "告警配置管理")
@RestController
@RequestMapping("/hnyz/alarmConfig")
public class AlarmConfigController extends BaseController
{
    @Autowired
    private IAlarmConfigService alarmConfigService;

    /**
     * 查询告警配置管理列表
     */
    @PreAuthorize("@ss.hasPermi('hnyz:alarmConfig:list')")
    @GetMapping("/list")
    @ApiOperation("查询告警配置管理列表")
    public TableDataInfo list(@ApiParam("告警配置对象") AlarmConfig alarmConfig)
    {
        startPage();
        List<AlarmConfig> list = alarmConfigService.selectAlarmConfigList(alarmConfig);
        return getDataTable(list);
    }

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

    /**
     * 获取告警配置管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('hnyz:alarmConfig:query')")
    @GetMapping(value = "/{configId}")
    @ApiOperation("获取告警配置管理详细信息")
    public AjaxResult getInfo(@PathVariable("configId") @ApiParam("告警配置id") Long configId)
    {
        return success(alarmConfigService.selectAlarmConfigByConfigId(configId));
    }

    /**
     * 新增告警配置管理
     */
    @PreAuthorize("@ss.hasPermi('hnyz:alarmConfig:add')")
    @Log(title = "告警配置管理", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增告警配置管理")
    public AjaxResult add(@RequestBody @ApiParam("告警配置对象") AlarmConfig alarmConfig)
    {
        return toAjax(alarmConfigService.insertAlarmConfig(alarmConfig));
    }

    /**
     * 修改告警配置管理
     */
    @PreAuthorize("@ss.hasPermi('hnyz:alarmConfig:edit')")
    @Log(title = "告警配置管理", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改告警配置管理")
    public AjaxResult edit(@RequestBody @ApiParam("告警配置对象") AlarmConfig alarmConfig)
    {
        return toAjax(alarmConfigService.updateAlarmConfig(alarmConfig));
    }

    /**
     * 删除告警配置管理
     */
    @PreAuthorize("@ss.hasPermi('hnyz:alarmConfig:remove')")
    @Log(title = "告警配置管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{configIds}")
    @ApiOperation("删除告警配置管理")
    public AjaxResult remove(@PathVariable @ApiParam(value = "多个告警配置id，用英文逗号分隔", required = true) Long[] configIds)
    {
        return toAjax(alarmConfigService.deleteAlarmConfigByConfigIds(configIds));
    }
}
