ref: v3变更,,网元关联核心网

This commit is contained in:
TsMask
2025-09-16 17:44:09 +08:00
parent 38d2e2372a
commit f8bc5b662e
14 changed files with 241 additions and 38 deletions

View File

@@ -10,6 +10,7 @@ import (
"be.ems/src/framework/utils/parse"
"be.ems/src/modules/ne/model"
"be.ems/src/modules/ne/service"
coreService "be.ems/src/modules/ne_core/service"
neFetchlink "be.ems/src/modules/ne_data_nf/fetch_link"
"github.com/gin-gonic/gin"
@@ -17,14 +18,16 @@ import (
// 实例化控制层 NeInfoController 结构体
var NewNeInfo = &NeInfoController{
neInfoService: service.NewNeInfo,
neInfoService: service.NewNeInfo,
coreInfoService: coreService.NewCoreInfo,
}
// 网元信息请求
//
// PATH /info
type NeInfoController struct {
neInfoService *service.NeInfo // 网元信息服务
neInfoService *service.NeInfo // 网元信息服务
coreInfoService *coreService.CoreInfo
}
// neStateCacheMap 网元状态缓存最后一次成功的信息
@@ -122,6 +125,14 @@ func (s NeInfoController) Nf(c *gin.Context) {
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
return
}
// 关联核心网信息
coreInfo := s.coreInfoService.FindByCoreId(neInfo.CoreId)
if coreInfo.ID == neInfo.CoreId {
neInfo.CoreName = coreInfo.CoreName
neInfo.CoreUid = coreInfo.CoreUid
}
c.JSON(200, resp.OkData(neInfo))
}
@@ -143,8 +154,8 @@ func (s NeInfoController) Nf(c *gin.Context) {
func (s NeInfoController) ListAll(c *gin.Context) {
language := reqctx.AcceptLanguage(c)
var querys struct {
CoreId int64 `form:"coreId"` // 核心网唯一标识
NeUid string `form:"neUid"` // 网元唯一标识
CoreUid string `form:"coreUid"` // 核心网唯一标识
NeUid string `form:"neUid"` // 网元唯一标识
NeType string `form:"neType"`
BandStatus bool `form:"bandStatus"`
BandHost bool `form:"bandHost"`
@@ -157,8 +168,14 @@ func (s NeInfoController) ListAll(c *gin.Context) {
// 查询实体参数
ne := model.NeInfo{}
if querys.CoreId != 0 {
ne.CoreId = querys.CoreId
if querys.CoreUid != "" {
// 检查是否存在
coreInfo := s.coreInfoService.FindByCoreUid(querys.CoreUid)
if coreInfo.ID == 0 || coreInfo.CoreUid != querys.CoreUid {
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.noCoreInfo")))
return
}
ne.CoreId = coreInfo.ID
}
if querys.NeUid != "" {
ne.NeUid = querys.NeUid
@@ -172,9 +189,17 @@ func (s NeInfoController) ListAll(c *gin.Context) {
return
}
// 过滤屏蔽授权文件
// 过滤处理
arr := &neList
for i := range *arr {
// 关联核心网信息
coreId := (*arr)[i].CoreId
coreInfo := s.coreInfoService.FindByCoreId(coreId)
if coreInfo.ID == coreId {
(*arr)[i].CoreName = coreInfo.CoreName
(*arr)[i].CoreUid = coreInfo.CoreUid
}
// 过滤屏蔽授权文件
(*arr)[i].ActivationRequestCode = "-"
(*arr)[i].LicensePath = "-"
}
@@ -403,11 +428,27 @@ func (s NeInfoController) List(c *gin.Context) {
if v, ok := query["bandStatus"]; ok {
bandStatus = parse.Boolean(v)
}
if v, ok := query["coreUid"]; ok {
// 检查是否存在
coreInfo := s.coreInfoService.FindByCoreUid(v)
if coreInfo.ID != 0 && coreInfo.CoreUid == v {
query["coreId"] = fmt.Sprint(coreInfo.ID)
}
}
rows, total := s.neInfoService.FindByPage(query, bandStatus)
// 过滤屏蔽授权文件
// 过滤处理
arr := &rows
for i := range *arr {
// 关联核心网信息
coreId := (*arr)[i].CoreId
coreInfo := s.coreInfoService.FindByCoreId(coreId)
if coreInfo.ID == coreId {
(*arr)[i].CoreName = coreInfo.CoreName
(*arr)[i].CoreUid = coreInfo.CoreUid
}
// 过滤屏蔽授权文件
(*arr)[i].ActivationRequestCode = "-"
(*arr)[i].LicensePath = "-"
}
@@ -568,3 +609,56 @@ func (s NeInfoController) Remove(c *gin.Context) {
msg := i18n.TTemplate(language, "app.common.deleteSuccess", map[string]any{"num": rows})
c.JSON(200, resp.OkMsg(msg))
}
// 网元信息关联核心网
//
// PUT /
//
// @Tags network_element/info
// @Accept json
// @Produce json
// @Param data body object true "Request Param"
// @Success 200 {object} object "Response Results"
// @Security TokenAuth
// @Summary Network element information modification
// @Description Network element information modification
// @Router /ne/info/core [put]
func (s NeInfoController) Core(c *gin.Context) {
language := reqctx.AcceptLanguage(c)
var body struct {
NeUID string `json:"neUid" binding:"required"` // 网元唯一标识
CoreUID string `json:"coreUid" binding:"required"` // 核心网唯一标识
}
err := c.ShouldBindBodyWithJSON(&body)
if err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs))
return
}
// 查询网元获取IP
neInfo := s.neInfoService.FindByNeUid(body.NeUID)
if neInfo.ID == 0 || neInfo.NeUid != body.NeUID {
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
return
}
// 查询核心网ID
var coreId int64 = 0
if len(body.CoreUID) == 8 {
// 检查是否存在
coreInfo := s.coreInfoService.FindByCoreUid(body.CoreUID)
if coreInfo.ID == 0 || coreInfo.CoreUid != body.CoreUID {
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.noCoreInfo")))
return
}
coreId = coreInfo.ID
}
rows := s.neInfoService.UpdateCoreId(neInfo.ID, coreId)
if rows > 0 {
c.JSON(200, resp.Ok(nil))
return
}
c.JSON(200, resp.Err(nil))
}