fix: UDM批量操作加载数据根据前缀重载
This commit is contained in:
@@ -2,7 +2,6 @@ package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -186,20 +185,13 @@ func (r *IMSUserService) Delete(neId, imsi string) int64 {
|
||||
|
||||
// LoadData 重新加载从imsi开始num的数据
|
||||
func (r *IMSUserService) LoadData(neId, imsiOrMsisdn, num string) {
|
||||
startIMSIOrMsisdn, _ := strconv.ParseInt(imsiOrMsisdn, 10, 64)
|
||||
subNum, _ := strconv.ParseInt(num, 10, 64)
|
||||
var i int64
|
||||
for i = 0; i < subNum; i++ {
|
||||
keyIMSI := fmt.Sprintf("%015d", startIMSIOrMsisdn+i)
|
||||
if !strings.HasPrefix(imsiOrMsisdn, "0") {
|
||||
keyIMSI = fmt.Sprintf("%d", startIMSIOrMsisdn+i)
|
||||
}
|
||||
// 删除原数据
|
||||
r.imsUserRepository.Delete(keyIMSI, neId)
|
||||
arr := r.dataByRedis(keyIMSI+":*", neId)
|
||||
if len(arr) < 1 {
|
||||
continue
|
||||
}
|
||||
// 直接删除前缀的记录
|
||||
index := len(imsiOrMsisdn) - len(num) - 1
|
||||
prefix := imsiOrMsisdn[:index]
|
||||
r.imsUserRepository.DeletePrefixByIMSI(prefix, neId)
|
||||
// 加载数据
|
||||
arr := r.dataByRedis(prefix+"*", neId)
|
||||
if len(arr) > 0 {
|
||||
r.imsUserRepository.Inserts(arr)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -163,18 +162,14 @@ func (r *VoIPAuthService) Delete(neId, userName string) int64 {
|
||||
}
|
||||
|
||||
// LoadData 重新加载从userName开始num的数据
|
||||
func (r *VoIPAuthService) LoadData(neId, userName, num string) {
|
||||
startUserName, _ := strconv.ParseInt(userName, 10, 64)
|
||||
subNum, _ := strconv.ParseInt(num, 10, 64)
|
||||
var i int64
|
||||
for i = 0; i < subNum; i++ {
|
||||
keyUserName := fmt.Sprintf("%d", startUserName+i)
|
||||
// 删除原数据
|
||||
r.voipAuthRepository.Delete(keyUserName, neId)
|
||||
arr := r.dataByRedis(keyUserName, neId)
|
||||
if len(arr) < 1 {
|
||||
continue
|
||||
}
|
||||
func (r *VoIPAuthService) LoadData(neId, username, num string) {
|
||||
// 直接删除前缀的记录
|
||||
index := len(username) - len(num) - 1
|
||||
prefix := username[:index]
|
||||
r.voipAuthRepository.DeletePrefixByUserName(prefix, neId)
|
||||
// 加载数据
|
||||
arr := r.dataByRedis(prefix+"*", neId)
|
||||
if len(arr) > 0 {
|
||||
r.voipAuthRepository.Inserts(arr)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user