feat: omc原始代码
This commit is contained in:
60
src/modules/monitor/controller/monitor.go
Normal file
60
src/modules/monitor/controller/monitor.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"nms_nbi/src/framework/i18n"
|
||||
"nms_nbi/src/framework/utils/ctx"
|
||||
"nms_nbi/src/framework/vo/result"
|
||||
"nms_nbi/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))
|
||||
}
|
||||
Reference in New Issue
Block a user