package controller

import (
	"be.ems/src/framework/resp"
	"be.ems/src/modules/monitor/service"

	"github.com/gin-gonic/gin"
)

// NewSystem 实例化控制层
var NewSystem = &SystemController{
	systemInfoService: service.NewSystemInfo,
}

// SystemController 服务器监控信息 控制层处理
//
// PATH /monitor/system
type SystemController struct {
	// 服务器系统相关信息服务
	systemInfoService *service.SystemInfo
}

// 服务器信息
//
// GET /
//
//	@Tags			monitor
//	@Accept			json
//	@Produce		json
//	@Success		200	{object}	object	"Response Results"
//	@Security		TokenAuth
//	@Summary		System Server Information
//	@Description	System Server Information
//	@Router			/monitor/system-info [get]
func (s SystemController) Info(c *gin.Context) {
	data := map[string]any{
		"cpu":     s.systemInfoService.CPUInfo(),
		"memory":  s.systemInfoService.MemoryInfo(),
		"network": s.systemInfoService.NetworkInfo(),
		"time":    s.systemInfoService.TimeInfo(),
		"system":  s.systemInfoService.SystemInfo(),
		"disk":    s.systemInfoService.DiskInfo(),
	}
	c.JSON(200, resp.OkData(data))
}
