Refactor network element state management - Removed the NE state endpoint and related service logic from the network_data module. - Introduced a new NEStateController to handle network element state records. - Implemented NEState service and repository for managing state records in the database. - Updated NEInfo and NeLicense controllers to utilize the new NEState service for fetching and saving state information. - Enhanced state handling in the websocket processor to reflect the latest state of network elements. - Added caching logic for network element states using Redis. - Improved error handling and response formatting for state queries.
59 lines
2.0 KiB
Go
59 lines
2.0 KiB
Go
package controller
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"be.ems/src/framework/resp"
|
|
"be.ems/src/modules/network_element/model"
|
|
neService "be.ems/src/modules/network_element/service"
|
|
)
|
|
|
|
// 实例化控制层 NEStateController 结构体
|
|
var NewNEState = &NEStateController{
|
|
neInfoService: neService.NewNeInfo,
|
|
neStateService: neService.NewNEState,
|
|
}
|
|
|
|
// 网元状态记录
|
|
//
|
|
// PATH /ne/state
|
|
type NEStateController struct {
|
|
neInfoService *neService.NeInfo // 网元信息服务
|
|
neStateService *neService.NEState // 网元状态服务
|
|
}
|
|
|
|
// 网元状态记录-内存/CPU/磁盘列表
|
|
//
|
|
// GET /list
|
|
//
|
|
// @Tags network_data
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param neType query string true "NE Type" Enums(IMS,AMF,AUSF,UDM,SMF,PCF,NSSF,NRF,UPF,MME,CBC,OMC,SGWC,SMSC) default(AMF)
|
|
// @Param neId query string true "NE ID" default(001)
|
|
// @Param pageNum query number true "pageNum" default(1)
|
|
// @Param pageSize query number true "pageSize" default(10)
|
|
// @Param startTime query number false "Start time (timestamped milliseconds)" default(1729162507596)
|
|
// @Param endTime query number false "End time (timestamped milliseconds)" default(1729164187611)
|
|
// @Param sortField query string false "Sort fields, fill in result fields" Enums(id,create_time) default(id)
|
|
// @Param sortOrder query string false "Sort by ascending or descending order" Enums(asc,desc) default(asc)
|
|
// @Success 200 {object} object "Response Results"
|
|
// @Security TokenAuth
|
|
// @Summary NE Status Record - Memory/CPU/Disk List
|
|
// @Description NE Status Record - Memory/CPU/Disk List
|
|
// @Router /ne/state/list [get]
|
|
func (s NEStateController) List(c *gin.Context) {
|
|
var query model.NEStateQuery
|
|
if err := c.ShouldBindQuery(&query); err != nil {
|
|
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
|
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs))
|
|
return
|
|
}
|
|
|
|
// 查询数据
|
|
rows, total := s.neStateService.FindByPage(query)
|
|
c.JSON(200, resp.OkData(map[string]any{"rows": rows, "total": total}))
|
|
}
|