package com.starry.admin.modules.system.controller;

import com.starry.admin.modules.system.module.entity.Server;
import com.starry.common.result.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
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 huoqiang 服务器监控
 * @since 2022/10/17
 */
@Api(tags = "服务器监控", description = "服务器状态监控相关接口")
@RestController
@RequestMapping("/monitor/server")
public class ServerController {

    @ApiOperation(value = "获取服务器信息", notes = "获取服务器运行状态、CPU、内存等信息")
    @ApiResponses({@ApiResponse(code = 200, message = "操作成功", response = Server.class)})
    @PreAuthorize("@customSs.hasPermission('monitor:server:list')")
    @GetMapping()
    public R getInfo() throws Exception {
        Server server = new Server();
        server.setServeInfo();
        return R.ok(server);
    }
}
