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.PerformanceMonitorModel;
import com.phm.manage.service.IPerformanceMonitorModelService;
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/performanceMonitorModel")
public class PerformanceMonitorModelController extends BaseController {
    @Autowired
    private IPerformanceMonitorModelService performanceMonitorModelService;

    /**
     * 查询性能监测模型信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:performanceMonitorModel:list')")
    @GetMapping("/list")
    public TableDataInfo list(PerformanceMonitorModel performanceMonitorModel) {
        startPage();
        List<PerformanceMonitorModel> list = performanceMonitorModelService.selectPerformanceMonitorModelList(performanceMonitorModel);
        return getDataTable(list);
    }

    /**
     * 导出性能监测模型信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:performanceMonitorModel:export')")
    @Log(title = "性能监测模型信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PerformanceMonitorModel performanceMonitorModel) {
        List<PerformanceMonitorModel> list = performanceMonitorModelService.selectPerformanceMonitorModelList(performanceMonitorModel);
        ExcelUtil<PerformanceMonitorModel> util = new ExcelUtil<PerformanceMonitorModel>(PerformanceMonitorModel.class);
        util.exportExcel(response, list, "性能监测模型信息数据");
    }

    /**
     * 获取性能监测模型信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:performanceMonitorModel:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(performanceMonitorModelService.selectPerformanceMonitorModelById(id));
    }

    /**
     * 新增性能监测模型信息
     */
    @PreAuthorize("@ss.hasPermi('manage:performanceMonitorModel:add')")
    @Log(title = "性能监测模型信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PerformanceMonitorModel performanceMonitorModel) {
        return toAjax(performanceMonitorModelService.insertPerformanceMonitorModel(performanceMonitorModel));
    }

    /**
     * 修改性能监测模型信息
     */
    @PreAuthorize("@ss.hasPermi('manage:performanceMonitorModel:edit')")
    @Log(title = "性能监测模型信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PerformanceMonitorModel performanceMonitorModel) {
        return toAjax(performanceMonitorModelService.updatePerformanceMonitorModel(performanceMonitorModel));
    }

    /**
     * 删除性能监测模型信息
     */
    @PreAuthorize("@ss.hasPermi('manage:performanceMonitorModel:remove')")
    @Log(title = "性能监测模型信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(performanceMonitorModelService.deletePerformanceMonitorModelByIds(ids));
    }
}
