package com.ruoyi.base.controller;

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.base.domain.BaseAlarmInfo;
import com.ruoyi.base.service.IBaseAlarmInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 报警信息Controller
 * 
 * @author zangch
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/base/baseAlarmInfo")
public class BaseAlarmInfoController extends BaseController
{
    @Autowired
    private IBaseAlarmInfoService baseAlarmInfoService;

    /**
     * 查询报警信息列表
     */
    @PreAuthorize("@ss.hasPermi('base:baseAlarmInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(BaseAlarmInfo baseAlarmInfo)
    {
        startPage();
        List<BaseAlarmInfo> list = baseAlarmInfoService.selectBaseAlarmInfoList(baseAlarmInfo);
        return getDataTable(list);
    }

    /**
     * 导出报警信息列表
     */
    @PreAuthorize("@ss.hasPermi('base:baseAlarmInfo:export')")
    @Log(title = "报警信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BaseAlarmInfo baseAlarmInfo)
    {
        List<BaseAlarmInfo> list = baseAlarmInfoService.selectBaseAlarmInfoList(baseAlarmInfo);
        ExcelUtil<BaseAlarmInfo> util = new ExcelUtil<BaseAlarmInfo>(BaseAlarmInfo.class);
        util.exportExcel(response, list, "报警信息数据");
    }

    /**
     * 获取报警信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('base:baseAlarmInfo:query')")
    @GetMapping(value = "/{objId}")
    public AjaxResult getInfo(@PathVariable("objId") Long objId)
    {
        return success(baseAlarmInfoService.selectBaseAlarmInfoByObjId(objId));
    }

    /**
     * 新增报警信息
     */
    @PreAuthorize("@ss.hasPermi('base:baseAlarmInfo:add')")
    @Log(title = "报警信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BaseAlarmInfo baseAlarmInfo)
    {
        return toAjax(baseAlarmInfoService.insertBaseAlarmInfo(baseAlarmInfo));
    }

    /**
     * 修改报警信息
     */
    @PreAuthorize("@ss.hasPermi('base:baseAlarmInfo:edit')")
    @Log(title = "报警信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BaseAlarmInfo baseAlarmInfo)
    {
        return toAjax(baseAlarmInfoService.updateBaseAlarmInfo(baseAlarmInfo));
    }

    /**
     * 删除报警信息
     */
    @PreAuthorize("@ss.hasPermi('base:baseAlarmInfo:remove')")
    @Log(title = "报警信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{objIds}")
    public AjaxResult remove(@PathVariable Long[] objIds)
    {
        return toAjax(baseAlarmInfoService.deleteBaseAlarmInfoByObjIds(objIds));
    }
}
