fix: UDM用户数据删除多个imsi
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"ems.agt/src/framework/i18n"
|
||||
"ems.agt/src/framework/utils/ctx"
|
||||
"ems.agt/src/framework/utils/file"
|
||||
"ems.agt/src/framework/utils/parse"
|
||||
"ems.agt/src/framework/utils/ssh"
|
||||
"ems.agt/src/framework/vo/result"
|
||||
"ems.agt/src/modules/network_element/model"
|
||||
@@ -270,6 +271,14 @@ func (s *UDMAuthController) Remove(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 处理字符转id数组后去重
|
||||
imsiArr := strings.Split(imsi, ",")
|
||||
uniqueIDs := parse.RemoveDuplicates(imsiArr)
|
||||
if len(uniqueIDs) <= 0 {
|
||||
c.JSON(200, result.Err(nil))
|
||||
return
|
||||
}
|
||||
|
||||
// 查询网元获取IP
|
||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
||||
if neInfo.NeId != neId || neInfo.IP == "" {
|
||||
@@ -277,21 +286,24 @@ func (s *UDMAuthController) Remove(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
msg := fmt.Sprintf("del authdat:imsi=%s", imsi)
|
||||
resultData := map[string]string{}
|
||||
for _, imsi := range uniqueIDs {
|
||||
msg := fmt.Sprintf("del authdat:imsi=%s", imsi)
|
||||
|
||||
// 发送MML
|
||||
data, err := mmlclient.MMLSendMsgToString(neInfo.IP, msg)
|
||||
if err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
// 发送MML
|
||||
data, err := mmlclient.MMLSendMsgToString(neInfo.IP, msg)
|
||||
if err != nil {
|
||||
resultData[imsi] = err.Error()
|
||||
}
|
||||
// 命令ok时
|
||||
if strings.Contains(data, "ok") {
|
||||
neId = ""
|
||||
s.udmAuthService.Delete(neId, imsi)
|
||||
resultData[imsi] = data
|
||||
}
|
||||
}
|
||||
|
||||
// 命令ok时
|
||||
if strings.Contains(data, "ok") {
|
||||
neId = ""
|
||||
s.udmAuthService.Delete(neId, imsi)
|
||||
}
|
||||
c.JSON(200, result.OkData(data))
|
||||
c.JSON(200, result.OkData(resultData))
|
||||
}
|
||||
|
||||
// UDM鉴权用户-批量删除
|
||||
@@ -347,7 +359,7 @@ func (s *UDMAuthController) Export(c *gin.Context) {
|
||||
}
|
||||
|
||||
if !(body.Type == "csv" || body.Type == "txt") {
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "ne.udm.errImportFileFormat")))
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "ne.udm.errImportUserAuthFileFormat")))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"ems.agt/src/framework/i18n"
|
||||
"ems.agt/src/framework/utils/ctx"
|
||||
"ems.agt/src/framework/utils/file"
|
||||
"ems.agt/src/framework/utils/parse"
|
||||
"ems.agt/src/framework/utils/ssh"
|
||||
"ems.agt/src/framework/vo/result"
|
||||
"ems.agt/src/modules/network_element/model"
|
||||
@@ -346,6 +347,14 @@ func (s *UDMSubController) Remove(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 处理字符转id数组后去重
|
||||
imsiArr := strings.Split(imsi, ",")
|
||||
uniqueIDs := parse.RemoveDuplicates(imsiArr)
|
||||
if len(uniqueIDs) <= 0 {
|
||||
c.JSON(200, result.Err(nil))
|
||||
return
|
||||
}
|
||||
|
||||
// 查询网元获取IP
|
||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID("UDM", neId)
|
||||
if neInfo.NeId != neId || neInfo.IP == "" {
|
||||
@@ -353,21 +362,24 @@ func (s *UDMSubController) Remove(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
msg := fmt.Sprintf("del udmuser:imsi=%s", imsi)
|
||||
resultData := map[string]string{}
|
||||
for _, imsi := range uniqueIDs {
|
||||
msg := fmt.Sprintf("del udmuser:imsi=%s", imsi)
|
||||
|
||||
// 发送MML
|
||||
data, err := mmlclient.MMLSendMsgToString(neInfo.IP, msg)
|
||||
if err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
// 发送MML
|
||||
data, err := mmlclient.MMLSendMsgToString(neInfo.IP, msg)
|
||||
if err != nil {
|
||||
resultData[imsi] = err.Error()
|
||||
}
|
||||
// 命令ok时
|
||||
if strings.Contains(data, "ok") {
|
||||
neId = ""
|
||||
s.udmSubService.Delete(neId, imsi)
|
||||
resultData[imsi] = data
|
||||
}
|
||||
}
|
||||
|
||||
// 命令ok时
|
||||
if strings.Contains(data, "ok") {
|
||||
neId = ""
|
||||
s.udmSubService.Delete(neId, imsi)
|
||||
}
|
||||
c.JSON(200, result.OkData(data))
|
||||
c.JSON(200, result.OkData(resultData))
|
||||
}
|
||||
|
||||
// UDM签约用户-批量删除
|
||||
@@ -423,7 +435,7 @@ func (s *UDMSubController) Export(c *gin.Context) {
|
||||
}
|
||||
|
||||
if !(body.Type == "csv" || body.Type == "txt") {
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "ne.udm.errImportFileFormat")))
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "ne.udm.errImportUserSubFileFormat")))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user