package com.tongran.system.controller;

import com.tongran.common.core.utils.poi.ExcelUtil;
import com.tongran.common.core.web.controller.BaseController;
import com.tongran.common.core.web.domain.AjaxResult;
import com.tongran.common.core.web.page.TableDataInfo;
import com.tongran.common.log.annotation.Log;
import com.tongran.common.log.enums.BusinessType;
import com.tongran.common.security.annotation.RequiresPermissions;
import com.tongran.system.domain.MtmMonitoringTemplate;
import com.tongran.system.service.IMtmMonitoringTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * 监控模板管理Controller
 * 
 * @author tongran
 * @date 2025-08-12
 */
@RestController
@RequestMapping("/template")
@RequiresPermissions("system:template")
public class MtmMonitoringTemplateController extends BaseController
{
    @Autowired
    private IMtmMonitoringTemplateService mtmMonitoringTemplateService;

    /**
     * 查询监控模板管理列表
     */
    @GetMapping("/list")
    public TableDataInfo list(MtmMonitoringTemplate mtmMonitoringTemplate)
    {
        startPage();
        List<MtmMonitoringTemplate> list = mtmMonitoringTemplateService.selectMtmMonitoringTemplateList(mtmMonitoringTemplate);
        return getDataTable(list);
    }

    /**
     * 导出监控模板管理列表
     */
    @Log(title = "监控模板管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MtmMonitoringTemplate mtmMonitoringTemplate)
    {
        List<MtmMonitoringTemplate> list = mtmMonitoringTemplateService.selectMtmMonitoringTemplateList(mtmMonitoringTemplate);
        ExcelUtil<MtmMonitoringTemplate> util = new ExcelUtil<MtmMonitoringTemplate>(MtmMonitoringTemplate.class);
        util.exportExcel(response, list, "监控模板管理数据");
    }

    /**
     * 获取监控模板管理详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mtmMonitoringTemplateService.selectMtmMonitoringTemplateById(id));
    }

    /**
     * 新增监控模板管理
     */
    @Log(title = "监控模板管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MtmMonitoringTemplate mtmMonitoringTemplate)
    {
        return toAjax(mtmMonitoringTemplateService.insertMtmMonitoringTemplate(mtmMonitoringTemplate));
    }

    /**
     * 修改监控模板管理
     */
    @Log(title = "监控模板管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MtmMonitoringTemplate mtmMonitoringTemplate)
    {
        return toAjax(mtmMonitoringTemplateService.updateMtmMonitoringTemplate(mtmMonitoringTemplate));
    }

    /**
     * 删除监控模板管理
     */
    @Log(title = "监控模板管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mtmMonitoringTemplateService.deleteMtmMonitoringTemplateByIds(ids));
    }
}
