package com.ruoyi.web.controller.manage;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manage.domain.WarnManage;
import com.ruoyi.manage.service.IWarnManageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 告警管理Controller
 *
 * @author boman
 * @date 2025-05-07
 */
@RestController
@RequestMapping("/manage/warnManage")
public class WarnManageController extends BaseController
{
    @Autowired
    private IWarnManageService warnManageService;

/**
 * 查询告警管理列表
 */
@PreAuthorize("@ss.hasPermi('manage:warnManage:list')")
@GetMapping("/list")
    public TableDataInfo list(WarnManage warnManage)
    {
        startPage();
        List<WarnManage> list = warnManageService.selectWarnManageList(warnManage);
        return getDataTable(list);
    }

    /**
     * 导出告警管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:warnManage:export')")
    @Log(title = "告警管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WarnManage warnManage)
    {
        List<WarnManage> list = warnManageService.selectWarnManageList(warnManage);
        ExcelUtil<WarnManage> util = new ExcelUtil<WarnManage>(WarnManage.class);
        util.exportExcel(response, list, "告警管理数据");
    }

    /**
     * 获取告警管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:warnManage:query')")
    @GetMapping(value = "/{warnId}")
    public AjaxResult getInfo(@PathVariable("warnId") Long warnId)
    {
        return success(warnManageService.selectWarnManageByWarnId(warnId));
    }

    /**
     * 新增告警管理
     */
    @PreAuthorize("@ss.hasPermi('manage:warnManage:add')")
    @Log(title = "告警管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WarnManage warnManage)
    {
        return toAjax(warnManageService.insertWarnManage(warnManage));
    }

    /**
     * 修改告警管理
     */
    @PreAuthorize("@ss.hasPermi('manage:warnManage:edit')")
    @Log(title = "告警管理", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody WarnManage warnManage)
    {
        return toAjax(warnManageService.updateWarnManage(warnManage));
    }

    /**
     * 删除告警管理
     */
    @PreAuthorize("@ss.hasPermi('manage:warnManage:remove')")
    @Log(title = "告警管理", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{warnIds}")
    public AjaxResult remove(@PathVariable Long[] warnIds)
    {
        return toAjax(warnManageService.deleteWarnManageByWarnIds(warnIds));
    }
}
