Files
be.ems/src/modules/monitor/controller/monitor.go
2023-11-20 18:54:59 +08:00

61 lines
1.5 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 (
"ems.agt/src/framework/i18n"
"ems.agt/src/framework/utils/ctx"
"ems.agt/src/framework/vo/result"
"ems.agt/src/modules/monitor/service"
"github.com/gin-gonic/gin"
)
// 实例化控制层 MonitorInfoController 结构体
var NewMonitor = &MonitorController{
monitorService: service.NewMonitorImpl,
}
// 服务器资源监控信息
//
// PATH /monitor
type MonitorController struct {
// 服务器系统相关信息服务
monitorService service.IMonitor
}
// 资源监控信息加载
//
// GET /load
func (s *MonitorController) Load(c *gin.Context) {
language := ctx.AcceptLanguage(c)
var querys struct {
// 数据类型all/load/cpu/memory/io/network
Type string `form:"type" binding:"required,oneof=all load cpu memory io network"`
// 开始时间
StartTime int64 `form:"startTime" binding:"required"`
// 结束时间
EndTime int64 `form:"endTime" binding:"required"`
// 网元类型
NeType string `form:"neType"`
// 网元ID
NeID string `form:"neId"`
// 名称networ和iok时有效
Name string `form:"name"`
}
err := c.ShouldBindQuery(&querys)
if 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))
}