package com.phm.manage.controller;

import com.phm.common.annotation.Log;
import com.phm.common.core.controller.BaseController;
import com.phm.common.core.domain.AjaxResult;
import com.phm.common.core.page.TableDataInfo;
import com.phm.common.enums.BusinessType;
import com.phm.common.utils.poi.ExcelUtil;
import com.phm.manage.domain.FalseAlarmRestrainModel;
import com.phm.manage.service.IFalseAlarmRestrainModelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

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

/**
 * 虚警抑制模型Controller
 *
 * @author phm
 * @date 2023-08-22
 */
@RestController
@RequestMapping("/manage/falseAlarmRestrainModel")
public class FalseAlarmRestrainModelController extends BaseController {
    @Autowired
    private IFalseAlarmRestrainModelService falseAlarmRestrainModelService;

    /**
     * 查询虚警抑制模型列表
     */
    @PreAuthorize("@ss.hasPermi('manage:falseAlarmRestrainModel:list')")
    @GetMapping("/list")
    public TableDataInfo list(FalseAlarmRestrainModel falseAlarmRestrainModel) {
        startPage();
        List<FalseAlarmRestrainModel> list = falseAlarmRestrainModelService.selectFalseAlarmRestrainModelList(falseAlarmRestrainModel);
        return getDataTable(list);
    }

    /**
     * 导出虚警抑制模型列表
     */
    @PreAuthorize("@ss.hasPermi('manage:falseAlarmRestrainModel:export')")
    @Log(title = "虚警抑制模型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FalseAlarmRestrainModel falseAlarmRestrainModel) {
        List<FalseAlarmRestrainModel> list = falseAlarmRestrainModelService.selectFalseAlarmRestrainModelList(falseAlarmRestrainModel);
        ExcelUtil<FalseAlarmRestrainModel> util = new ExcelUtil<FalseAlarmRestrainModel>(FalseAlarmRestrainModel.class);
        util.exportExcel(response, list, "虚警抑制模型数据");
    }

    /**
     * 获取虚警抑制模型详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:falseAlarmRestrainModel:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(falseAlarmRestrainModelService.selectFalseAlarmRestrainModelById(id));
    }

    /**
     * 新增虚警抑制模型
     */
    @PreAuthorize("@ss.hasPermi('manage:falseAlarmRestrainModel:add')")
    @Log(title = "虚警抑制模型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FalseAlarmRestrainModel falseAlarmRestrainModel) {
        return toAjax(falseAlarmRestrainModelService.insertFalseAlarmRestrainModel(falseAlarmRestrainModel));
    }

    /**
     * 修改虚警抑制模型
     */
    @PreAuthorize("@ss.hasPermi('manage:falseAlarmRestrainModel:edit')")
    @Log(title = "虚警抑制模型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FalseAlarmRestrainModel falseAlarmRestrainModel) {
        return toAjax(falseAlarmRestrainModelService.updateFalseAlarmRestrainModel(falseAlarmRestrainModel));
    }

    /**
     * 删除虚警抑制模型
     */
    @PreAuthorize("@ss.hasPermi('manage:falseAlarmRestrainModel:remove')")
    @Log(title = "虚警抑制模型", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(falseAlarmRestrainModelService.deleteFalseAlarmRestrainModelByIds(ids));
    }
}
