package com.jiayue.ssi.controller;

import com.jiayue.ssi.annotation.OperateLog;
import com.jiayue.ssi.annotation.PreventReplay;
import com.jiayue.ssi.backenum.AuditType;
import com.jiayue.ssi.backenum.BusinessType;
import com.jiayue.ssi.constant.CustomException;
import com.jiayue.ssi.entity.Server;
import com.jiayue.ssi.util.ResponseVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 服务监控器
 *
 * @author xsl
 * @since 2023/03/13
 */
@RestController
@RequestMapping("/monitor/server")
@Slf4j
public class ServerController {
    @PreAuthorize("@ss.hasPermi('monitor:server:list')")
    @GetMapping()
    @OperateLog(title = "服务监控", businessType = BusinessType.QUERY, auditType = AuditType.SYS,operdesc = "获取服务监控信息")
    @PreventReplay
    public ResponseVO getInfo() throws CustomException {
        try {
            Server server = new Server();
            server.copyTo();
            return ResponseVO.success(server);
        } catch (Exception e) {
            throw new CustomException("获取服务监控异常", e);
        }
    }
}
