ref: v3变更,,表结构变更coreId/neId
This commit is contained in:
@@ -38,9 +38,7 @@ var mutex sync.Mutex
|
||||
// @Tags network_element/info
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param coreUid query string true "CoreUID" default(8I73Y01Z)
|
||||
// @Param neUid query string true "NeUID" default(5AKF59BZ)
|
||||
// @Success 200 {object} object "Response Results"
|
||||
// @Param neUid query string true "NE UID" default(8I73Y01Z)// @Success 200 {object} object "Response Results"
|
||||
// @Security TokenAuth
|
||||
// @Summary Network element information state
|
||||
// @Description Network element information state
|
||||
@@ -48,8 +46,7 @@ var mutex sync.Mutex
|
||||
func (s NeInfoController) State(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var query struct {
|
||||
CoreUID string `form:"coreUid" binding:"required"` // 核心网唯一标识
|
||||
NeUID string `form:"neUid" binding:"required"` // 网元唯一标识
|
||||
NeUID string `form:"neUid" binding:"required"` // 网元唯一标识
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
@@ -57,12 +54,12 @@ func (s NeInfoController) State(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
neInfo := s.neInfoService.FindByCoreUidAndNeUid(query.CoreUID, query.NeUID)
|
||||
if neInfo.CoreUID != query.CoreUID || neInfo.NeUID != query.NeUID {
|
||||
neInfo := s.neInfoService.FindByNeUid(query.NeUID)
|
||||
if neInfo.ID == 0 || neInfo.NeUid != query.NeUID {
|
||||
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
|
||||
return
|
||||
}
|
||||
neKey := fmt.Sprintf("%s_%s", neInfo.CoreUID, neInfo.NeUID)
|
||||
neKey := fmt.Sprintf("%s_%s", neInfo.NeUid, neInfo.NeType)
|
||||
|
||||
// 网元直连
|
||||
resData, err := neFetchlink.NeState(neInfo)
|
||||
@@ -74,12 +71,13 @@ func (s NeInfoController) State(c *gin.Context) {
|
||||
resDataCache.(map[string]any)["online"] = false
|
||||
} else {
|
||||
resDataCache = map[string]any{
|
||||
"online": false,
|
||||
"coreUid": neInfo.CoreUID,
|
||||
"neUid": neInfo.NeUID,
|
||||
"neType": neInfo.NeType,
|
||||
"neName": neInfo.NeName,
|
||||
"ipAddr": neInfo.IPAddr,
|
||||
"online": false,
|
||||
"coreId": neInfo.CoreId,
|
||||
"neId": neInfo.ID,
|
||||
"neUid": neInfo.NeUid,
|
||||
"neType": neInfo.NeType,
|
||||
"neName": neInfo.NeName,
|
||||
"ipAddr": neInfo.IpAddr,
|
||||
}
|
||||
}
|
||||
neStateCacheMap.Store(neKey, resDataCache)
|
||||
@@ -103,9 +101,7 @@ func (s NeInfoController) State(c *gin.Context) {
|
||||
// @Tags network_element/info
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param coreUid query string true "CoreUID" default(8I73Y01Z)
|
||||
// @Param neUid query string true "NeUID" default(5AKF59BZ)
|
||||
// @Success 200 {object} object "Response Results"
|
||||
// @Param neUid query string true "NE UID" default(8I73Y01Z)// @Success 200 {object} object "Response Results"
|
||||
// @Security TokenAuth
|
||||
// @Summary Network element neType and neID queries
|
||||
// @Description Network element neType and neID queries
|
||||
@@ -113,8 +109,7 @@ func (s NeInfoController) State(c *gin.Context) {
|
||||
func (s NeInfoController) Nf(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var query struct {
|
||||
CoreUID string `form:"coreUid" binding:"required"` // 核心网唯一标识
|
||||
NeUID string `form:"neUid" binding:"required"` // 网元唯一标识
|
||||
NeUID string `form:"neUid" binding:"required"` // 网元唯一标识
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
@@ -122,8 +117,8 @@ func (s NeInfoController) Nf(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
neInfo := s.neInfoService.FindByCoreUidAndNeUid(query.CoreUID, query.NeUID)
|
||||
if neInfo.CoreUID != query.CoreUID || neInfo.NeUID != query.NeUID {
|
||||
neInfo := s.neInfoService.FindByNeUid(query.NeUID)
|
||||
if neInfo.ID == 0 || neInfo.NeUid != query.NeUID {
|
||||
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
|
||||
return
|
||||
}
|
||||
@@ -137,9 +132,7 @@ func (s NeInfoController) Nf(c *gin.Context) {
|
||||
// @Tags network_element/info
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param coreUid query string true "CoreUID" default(8I73Y01Z)
|
||||
// @Param neUid query string true "NeUID" default(5AKF59BZ)
|
||||
// @Param neType query string true "NE Type"
|
||||
// @Param neUid query string true "NE UID" default(8I73Y01Z)// @Param neType query string true "NE Type"
|
||||
// @Param bandStatus query boolean true "With status information"
|
||||
// @Param bandHost query boolean true "With host information"
|
||||
// @Success 200 {object} object "Response Results"
|
||||
@@ -150,8 +143,8 @@ func (s NeInfoController) Nf(c *gin.Context) {
|
||||
func (s NeInfoController) ListAll(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var querys struct {
|
||||
CoreUID string `form:"coreUid" binding:"required"` // 核心网唯一标识
|
||||
NeUID string `form:"neUid"` // 网元唯一标识
|
||||
CoreId int64 `form:"coreId"` // 核心网唯一标识
|
||||
NeUid string `form:"neUid"` // 网元唯一标识
|
||||
NeType string `form:"neType"`
|
||||
BandStatus bool `form:"bandStatus"`
|
||||
BandHost bool `form:"bandHost"`
|
||||
@@ -164,11 +157,11 @@ func (s NeInfoController) ListAll(c *gin.Context) {
|
||||
|
||||
// 查询实体参数
|
||||
ne := model.NeInfo{}
|
||||
if querys.CoreUID != "" {
|
||||
ne.CoreUID = querys.CoreUID
|
||||
if querys.CoreId != 0 {
|
||||
ne.CoreId = querys.CoreId
|
||||
}
|
||||
if querys.NeUID != "" {
|
||||
ne.NeUID = querys.NeUID
|
||||
if querys.NeUid != "" {
|
||||
ne.NeUid = querys.NeUid
|
||||
}
|
||||
if querys.NeType != "" {
|
||||
ne.NeType = querys.NeType
|
||||
@@ -178,9 +171,121 @@ func (s NeInfoController) ListAll(c *gin.Context) {
|
||||
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
|
||||
return
|
||||
}
|
||||
|
||||
// 过滤屏蔽授权文件
|
||||
arr := &neList
|
||||
for i := range *arr {
|
||||
(*arr)[i].ActivationRequestCode = "-"
|
||||
(*arr)[i].LicensePath = "-"
|
||||
}
|
||||
|
||||
c.JSON(200, resp.OkData(neList))
|
||||
}
|
||||
|
||||
// 网元授权激活授权申请码
|
||||
//
|
||||
// GET /license/code
|
||||
//
|
||||
// @Tags network_element/license
|
||||
// @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)
|
||||
// @Param neId query string true "NE ID" default(001)
|
||||
// @Success 200 {object} object "Response Results"
|
||||
// @Security TokenAuth
|
||||
// @Summary Network Element License Activation License Application Code
|
||||
// @Description Network Element License Activation License Application Code
|
||||
// @Router /ne/info/license/code [get]
|
||||
func (s NeInfoController) LicenseCode(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var query struct {
|
||||
NeUID string `form:"neUid" binding:"required"` // 网元唯一标识
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
// 查询网元获取IP
|
||||
neInfo := s.neInfoService.FindByNeUid(query.NeUID)
|
||||
if neInfo.ID == 0 || neInfo.NeUid != query.NeUID {
|
||||
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
|
||||
return
|
||||
}
|
||||
|
||||
// 读取授权码
|
||||
code, licensePath := s.neInfoService.NeConfLicenseRead(neInfo)
|
||||
// 更新授权码
|
||||
if code != "" && licensePath != "" && neInfo.ActivationRequestCode != code {
|
||||
// 检查是否存在
|
||||
neInfo = s.neInfoService.FindById(neInfo.ID, false)
|
||||
if neInfo.ID == 0 || neInfo.NeUid == "" {
|
||||
// 没有可访问网元信息数据!
|
||||
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "neInfo.noData")))
|
||||
return
|
||||
}
|
||||
neInfo.ActivationRequestCode = code
|
||||
neInfo.LicensePath = licensePath
|
||||
neInfo.UpdateBy = reqctx.LoginUserToUserName(c)
|
||||
s.neInfoService.Update(neInfo)
|
||||
}
|
||||
c.JSON(200, resp.OkData(code))
|
||||
}
|
||||
|
||||
// 网元授权激活授权文件替换
|
||||
//
|
||||
// POST /license/update
|
||||
//
|
||||
// @Tags network_element/license
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param data body object true "Request Param"
|
||||
// @Success 200 {object} object "Response Results"
|
||||
// @Security TokenAuth
|
||||
// @Summary Network element authorization activation status
|
||||
// @Description Network element authorization activation status
|
||||
// @Router /ne/license/update [post]
|
||||
func (s NeInfoController) LicenseUpdate(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var body struct {
|
||||
NeUID string `json:"neUid" binding:"required"` // 网元唯一标识
|
||||
LicensePath string `json:"licensePath"` // 上传的文件路径
|
||||
Reload bool `json:"reload"` // 刷新重启网元
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); 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
|
||||
}
|
||||
// 进行上传替换
|
||||
neInfo.LicensePath = body.LicensePath
|
||||
err := s.neInfoService.NeConfLicenseUpload(neInfo, body.Reload)
|
||||
if err != nil {
|
||||
c.JSON(200, resp.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否存在
|
||||
neInfo = s.neInfoService.FindById(neInfo.ID, false)
|
||||
if neInfo.ID == 0 || neInfo.NeUid == "" {
|
||||
// 没有可访问网元信息数据!
|
||||
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "neInfo.noData")))
|
||||
return
|
||||
}
|
||||
neInfo.LicensePath = body.LicensePath
|
||||
neInfo.UpdateBy = reqctx.LoginUserToUserName(c)
|
||||
s.neInfoService.Update(neInfo)
|
||||
c.JSON(200, resp.Ok(nil))
|
||||
}
|
||||
|
||||
// 网元端Para5G配置文件读取
|
||||
//
|
||||
// GET /file/para5g
|
||||
@@ -199,7 +304,7 @@ func (s NeInfoController) Para5GFileRead(c *gin.Context) {
|
||||
func (s NeInfoController) Para5GFileWrite(c *gin.Context) {
|
||||
var body struct {
|
||||
Content map[string]any `json:"content" binding:"required"` // 内容
|
||||
SyncNE []string `json:"syncNe"` // 同步到网元
|
||||
SyncNE []string `json:"syncNe"` // 同步到网元neUid,neUid网元唯一标识
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
@@ -219,17 +324,24 @@ func (s NeInfoController) Para5GFileWrite(c *gin.Context) {
|
||||
//
|
||||
// GET /file/oam
|
||||
func (s NeInfoController) OAMFileRead(c *gin.Context) {
|
||||
var querys struct {
|
||||
CoreUID string `form:"coreUid" binding:"required"` // 核心网唯一标识
|
||||
NeUID string `form:"neUid" binding:"required"` // 网元唯一标识
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var query struct {
|
||||
NeUID string `form:"neUid" binding:"required"` // 网元唯一标识
|
||||
}
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
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
|
||||
}
|
||||
|
||||
data, err := s.neInfoService.NeConfOAMReadSync(querys.CoreUID, querys.NeUID)
|
||||
// 查询网元获取IP
|
||||
neInfo := s.neInfoService.FindByNeUid(query.NeUID)
|
||||
if neInfo.ID == 0 || neInfo.NeUid != query.NeUID {
|
||||
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
|
||||
return
|
||||
}
|
||||
|
||||
data, err := s.neInfoService.NeConfOAMReadSync(neInfo)
|
||||
if err != nil {
|
||||
c.JSON(200, resp.ErrMsg(err.Error()))
|
||||
return
|
||||
@@ -243,8 +355,7 @@ func (s NeInfoController) OAMFileRead(c *gin.Context) {
|
||||
func (s NeInfoController) OAMFileWrite(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var body struct {
|
||||
CoreUID string `json:"coreUid" binding:"required"` // 核心网唯一标识
|
||||
NeUID string `json:"neUid" binding:"required"` // 网元唯一标识
|
||||
NeUID string `form:"neUid" binding:"required"` // 网元唯一标识
|
||||
Content map[string]any `json:"content" binding:"required"` // 内容
|
||||
Sync bool `json:"sync"` // 同步到网元
|
||||
}
|
||||
@@ -255,8 +366,8 @@ func (s NeInfoController) OAMFileWrite(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 查询网元获取IP
|
||||
neInfo := s.neInfoService.FindByCoreUidAndNeUid(body.CoreUID, body.NeUID)
|
||||
if neInfo.CoreUID != body.CoreUID || neInfo.NeUID != body.NeUID {
|
||||
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
|
||||
}
|
||||
@@ -288,16 +399,19 @@ func (s NeInfoController) OAMFileWrite(c *gin.Context) {
|
||||
// @Router /ne/info/list [get]
|
||||
func (s NeInfoController) List(c *gin.Context) {
|
||||
query := reqctx.QueryMap(c)
|
||||
coreUid, coreUidOk := query["coreUid"]
|
||||
if !coreUidOk || coreUid == "" {
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: coreUid is empty"))
|
||||
return
|
||||
}
|
||||
bandStatus := false
|
||||
if v, ok := query["bandStatus"]; ok {
|
||||
bandStatus = parse.Boolean(v)
|
||||
}
|
||||
rows, total := s.neInfoService.FindByPage(query, bandStatus)
|
||||
|
||||
// 过滤屏蔽授权文件
|
||||
arr := &rows
|
||||
for i := range *arr {
|
||||
(*arr)[i].ActivationRequestCode = "-"
|
||||
(*arr)[i].LicensePath = "-"
|
||||
}
|
||||
|
||||
c.JSON(200, resp.OkData(map[string]any{"rows": rows, "total": total}))
|
||||
}
|
||||
|
||||
@@ -317,8 +431,7 @@ func (s NeInfoController) List(c *gin.Context) {
|
||||
func (s NeInfoController) Info(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var query struct {
|
||||
CoreUID string `form:"coreUid" binding:"required"` // 核心网唯一标识
|
||||
ID int64 `form:"id" binding:"required"` // ID
|
||||
ID int64 `form:"id" binding:"required"` // ID
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
@@ -327,7 +440,7 @@ func (s NeInfoController) Info(c *gin.Context) {
|
||||
}
|
||||
|
||||
info := s.neInfoService.FindById(query.ID, true)
|
||||
if info.ID != query.ID || info.CoreUID != query.CoreUID {
|
||||
if info.ID != query.ID {
|
||||
// 没有可访问网元信息数据!
|
||||
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "neInfo.noData")))
|
||||
return
|
||||
@@ -361,10 +474,6 @@ func (s NeInfoController) Add(c *gin.Context) {
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id not is empty"))
|
||||
return
|
||||
}
|
||||
if body.CoreUID == "" {
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: coreUid is empty"))
|
||||
return
|
||||
}
|
||||
|
||||
body.CreateBy = reqctx.LoginUserToUserName(c)
|
||||
insertId := s.neInfoService.Insert(body)
|
||||
@@ -410,8 +519,6 @@ func (s NeInfoController) Edit(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
body.CoreUID = neInfo.CoreUID
|
||||
body.NeUID = neInfo.NeUID
|
||||
body.UpdateBy = reqctx.LoginUserToUserName(c)
|
||||
rows := s.neInfoService.Update(body)
|
||||
if rows > 0 {
|
||||
@@ -423,7 +530,7 @@ func (s NeInfoController) Edit(c *gin.Context) {
|
||||
|
||||
// 网元信息删除
|
||||
//
|
||||
// DELETE /:id
|
||||
// DELETE /
|
||||
//
|
||||
// @Tags network_element/info
|
||||
// @Accept json
|
||||
@@ -437,9 +544,7 @@ func (s NeInfoController) Edit(c *gin.Context) {
|
||||
func (s NeInfoController) Remove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var query struct {
|
||||
CoreUID string `form:"coreUid" binding:"required"` // 核心网唯一标识
|
||||
NeUID string `form:"neUid" binding:"required"` // 网元唯一标识
|
||||
ID string `form:"id" binding:"required"` // 记录ID 批量多个逗号分隔
|
||||
ID string `form:"id" binding:"required"` // 记录ID 批量多个逗号分隔
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
@@ -455,7 +560,7 @@ func (s NeInfoController) Remove(c *gin.Context) {
|
||||
ids = append(ids, parse.Number(v))
|
||||
}
|
||||
|
||||
rows, err := s.neInfoService.DeleteByIds(ids, query.CoreUID, query.NeUID)
|
||||
rows, err := s.neInfoService.DeleteByIds(ids)
|
||||
if err != nil {
|
||||
c.JSON(200, resp.ErrMsg(i18n.TKey(language, err.Error())))
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user