62 lines
1.8 KiB
Go
62 lines
1.8 KiB
Go
package controller
|
|
|
|
import (
|
|
"be.ems/src/framework/i18n"
|
|
"be.ems/src/framework/utils/ctx"
|
|
"be.ems/src/framework/vo/result"
|
|
neDataService "be.ems/src/modules/network_data/service"
|
|
neService "be.ems/src/modules/network_element/service"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// 实例化控制层 UPFController 结构体
|
|
var NewUPF = &UPFController{
|
|
neInfoService: neService.NewNeInfo,
|
|
perfKPIService: neDataService.NewPerfKPI,
|
|
}
|
|
|
|
// 网元UPF
|
|
//
|
|
// PATH /upf
|
|
type UPFController struct {
|
|
neInfoService *neService.NeInfo // 网元信息服务
|
|
perfKPIService *neDataService.PerfKPI // 统计信息服务
|
|
}
|
|
|
|
// 总流量数 N3上行 N6下行
|
|
// 单位 比特(bit)
|
|
//
|
|
// GET /totalFlow
|
|
//
|
|
// @Tags network_data/upf
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param neId query string true "NE ID" default(001)
|
|
// @Param day query number true "Statistical time a few days before" Enums(0, 7, 30)
|
|
// @Success 200 {object} object "Response Results"
|
|
// @Security TokenAuth
|
|
// @Summary Total number of flows N3 upstream N6 downstream
|
|
// @Description Total number of flows N3 upstream N6 downstream
|
|
// @Router /neData/upf/totalFlow [get]
|
|
func (s *UPFController) TotalFlow(c *gin.Context) {
|
|
language := ctx.AcceptLanguage(c)
|
|
var querys struct {
|
|
NeID string `form:"neId" binding:"required"`
|
|
Day int `form:"day"`
|
|
}
|
|
if err := c.ShouldBindQuery(&querys); querys.Day < 0 || err != nil {
|
|
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
|
return
|
|
}
|
|
|
|
// 查询网元获取IP
|
|
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UPF", querys.NeID)
|
|
if neInfo.NeId != querys.NeID || neInfo.IP == "" {
|
|
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
|
|
return
|
|
}
|
|
|
|
up, down := s.perfKPIService.UPFTodayFlowFind(neInfo.RmUID, querys.Day)
|
|
c.JSON(200, result.OkData(map[string]int64{"up": up, "down": down}))
|
|
}
|