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.MonitorParameterConfig;
import com.phm.manage.service.IMonitorParameterConfigService;
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/monitorParameterConfig")
public class MonitorParameterConfigController extends BaseController {
    @Autowired
    private IMonitorParameterConfigService monitorParameterConfigService;

    /**
     * 查询状态监控参数配置信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:monitorParameterConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(MonitorParameterConfig monitorParameterConfig) {
        startPage();
        List<MonitorParameterConfig> list = monitorParameterConfigService.selectMonitorParameterConfigList(monitorParameterConfig);
        return getDataTable(list);
    }

    /**
     * 导出状态监控参数配置信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:monitorParameterConfig:export')")
    @Log(title = "状态监控参数配置信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MonitorParameterConfig monitorParameterConfig) {
        List<MonitorParameterConfig> list = monitorParameterConfigService.selectMonitorParameterConfigList(monitorParameterConfig);
        ExcelUtil<MonitorParameterConfig> util = new ExcelUtil<MonitorParameterConfig>(MonitorParameterConfig.class);
        util.exportExcel(response, list, "状态监控参数配置信息数据");
    }

    /**
     * 获取状态监控参数配置信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:monitorParameterConfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(monitorParameterConfigService.selectMonitorParameterConfigById(id));
    }

    /**
     * 新增状态监控参数配置信息
     */
    @PreAuthorize("@ss.hasPermi('manage:monitorParameterConfig:add')")
    @Log(title = "状态监控参数配置信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MonitorParameterConfig monitorParameterConfig) {
        return toAjax(monitorParameterConfigService.insertMonitorParameterConfig(monitorParameterConfig));
    }

    /**
     * 修改状态监控参数配置信息
     */
    @PreAuthorize("@ss.hasPermi('manage:monitorParameterConfig:edit')")
    @Log(title = "状态监控参数配置信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MonitorParameterConfig monitorParameterConfig) {
        return toAjax(monitorParameterConfigService.updateMonitorParameterConfig(monitorParameterConfig));
    }

    /**
     * 删除状态监控参数配置信息
     */
    @PreAuthorize("@ss.hasPermi('manage:monitorParameterConfig:remove')")
    @Log(title = "状态监控参数配置信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(monitorParameterConfigService.deleteMonitorParameterConfigByIds(ids));
    }
}
