package controller import ( "be.ems/src/framework/vo/result" "be.ems/src/modules/monitor/service" "github.com/gin-gonic/gin" ) // 实例化控制层 SystemInfoController 结构体 var NewSystemInfo = &SystemInfoController{ systemInfogService: service.NewSystemInfo, } // 服务器监控信息 // // PATH /monitor/system-info type SystemInfoController struct { systemInfogService *service.SystemInfo // 服务器系统相关信息服务 } // 服务器信息 // // GET / func (s *SystemInfoController) Info(c *gin.Context) { data := map[string]any{ "cpu": s.systemInfogService.CPUInfo(), "memory": s.systemInfogService.MemoryInfo(), "network": s.systemInfogService.NetworkInfo(), "time": s.systemInfogService.TimeInfo(), "system": s.systemInfogService.SystemInfo(), "disk": s.systemInfogService.DiskInfo(), } c.JSON(200, result.OkData(data)) }