fix: UDM批量操作加载数据根据前缀重载

This commit is contained in:
TsMask
2025-10-11 09:49:49 +08:00
parent 4da212739e
commit 13b2ce3e64
10 changed files with 109 additions and 134 deletions

View File

@@ -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)
}
}