package com.zyc.web.controller.api;

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.zyc.common.annotation.Log;
import com.zyc.common.core.controller.BaseController;
import com.zyc.common.core.domain.AjaxResult;
import com.zyc.common.enums.BusinessType;
import com.zyc.system.domain.ResourceMetricsInfo;
import com.zyc.system.service.IResourceMetricsInfoService;
import com.zyc.common.utils.poi.ExcelUtil;
import com.zyc.common.core.page.TableDataInfo;

/**
 * 资源指标信息Controller
 * 
 * @author zyc
 * @date 2024-12-26
 */
@RestController
@RequestMapping("/system/ResourceMetricsInfoController")
public class ResourceMetricsInfoController extends BaseController
{
    @Autowired
    private IResourceMetricsInfoService resourceMetricsInfoService;

    /**
     * 查询资源指标信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(ResourceMetricsInfo resourceMetricsInfo)
    {
        startPage();
        List<ResourceMetricsInfo> list = resourceMetricsInfoService.selectResourceMetricsInfoList(resourceMetricsInfo);
        return getDataTable(list);
    }

    /**
     * 导出资源指标信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "资源指标信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ResourceMetricsInfo resourceMetricsInfo)
    {
        List<ResourceMetricsInfo> list = resourceMetricsInfoService.selectResourceMetricsInfoList(resourceMetricsInfo);
        ExcelUtil<ResourceMetricsInfo> util = new ExcelUtil<ResourceMetricsInfo>(ResourceMetricsInfo.class);
        util.exportExcel(response, list, "资源指标信息数据");
    }

    /**
     * 获取资源指标信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(resourceMetricsInfoService.selectResourceMetricsInfoById(id));
    }

    /**
     * 新增资源指标信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "资源指标信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ResourceMetricsInfo resourceMetricsInfo)
    {
        return toAjax(resourceMetricsInfoService.insertResourceMetricsInfo(resourceMetricsInfo));
    }

    /**
     * 修改资源指标信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "资源指标信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ResourceMetricsInfo resourceMetricsInfo)
    {
        return toAjax(resourceMetricsInfoService.updateResourceMetricsInfo(resourceMetricsInfo));
    }

    /**
     * 删除资源指标信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "资源指标信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(resourceMetricsInfoService.deleteResourceMetricsInfoByIds(ids));
    }
}
