Files
be.ems/src/modules/monitor/controller/monitor.go

53 lines
1.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package controller
import (
"be.ems/src/framework/i18n"
"be.ems/src/framework/utils/ctx"
"be.ems/src/framework/vo/result"
"be.ems/src/modules/monitor/service"
"github.com/gin-gonic/gin"
)
// 实例化控制层 MonitorInfoController 结构体
var NewMonitor = &MonitorController{
monitorService: service.NewMonitor,
}
// 服务器资源监控信息
//
// PATH /monitor
type MonitorController struct {
monitorService *service.Monitor // 服务器系统相关信息服务
}
// 资源监控信息加载
//
// GET /load
func (s *MonitorController) Load(c *gin.Context) {
language := ctx.AcceptLanguage(c)
var querys struct {
Type string `form:"type" binding:"required,oneof=all load cpu memory io network"` // 数据类型all/load/cpu/memory/io/network
StartTime int64 `form:"startTime" binding:"required"` // 开始时间
EndTime int64 `form:"endTime" binding:"required"` // 结束时间
NeType string `form:"neType"` // 网元类型
NeID string `form:"neId"` // 网元ID
Name string `form:"name"` // 名称networ和io时有效
}
if err := c.ShouldBindQuery(&querys); err != nil {
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
return
}
// 查询数据
data := s.monitorService.SelectMonitorInfo(map[string]any{
"type": querys.Type,
"startTime": querys.StartTime,
"endTime": querys.EndTime,
"neType": querys.NeType,
"neId": querys.NeID,
"name": querys.Name,
})
c.JSON(200, result.OkData(data))
}