feat: support rest data return channel result

This commit is contained in:
zhangsz
2025-04-10 15:46:09 +08:00
parent a1eaaaebd7
commit a00a7da016
7 changed files with 88 additions and 74 deletions

View File

@@ -5,20 +5,20 @@ import (
"strconv"
"strings"
"be.ems/src/framework/redis"
neService "be.ems/src/modules/network_element/service"
"be.ems/features/ue/model"
"be.ems/features/ue/repository"
"be.ems/src/framework/redis"
neService "be.ems/src/modules/network_element/service"
)
// 实例化服务层 VoIPAuthService 结构体
var NewVoIPAuthService = &VoIPAuthService{
voipAuthRepository: repository.NewVoIPAuthRepository,
voipAuthRepository: repository.NewVoIPAuthRepository,
}
// VoLTE用户信息 服务层处理
type VoIPAuthService struct {
voipAuthRepository *repository.VoIPAuthRepository // VoLTE用户信息数据信息
voipAuthRepository *repository.VoIPAuthRepository // VoLTE用户信息数据信息
}
// dataByRedis UDM签约用户 db:0 中 volte:*
@@ -51,13 +51,13 @@ func (r *VoIPAuthService) dataByRedis(userName, neId string) []model.VoIPAuth {
var userName string
KeyParts := strings.Split(k, ":")
if len(KeyParts) > 1 {
userName = KeyParts[1]
}
userName = KeyParts[1]
}
a := model.VoIPAuth{
NeId: neId,
UserName: userName, // userName
Password: m["password"], //
NeId: neId,
UserName: userName, // userName
Password: m["password"], //
}
arr = append(arr, a)
}
@@ -168,3 +168,14 @@ func (r *VoIPAuthService) ParseCommandParams(item model.VoIPAuth) string {
return strings.Join(conditions, ",")
}
// ResetDataWithResult 重置鉴权用户数据清空数据库重新同步Redis数据
// 通过 channel 返回 ClearAndInsert 的执行结果
func (r *VoIPAuthService) ResetDataWithResult(neId string) chan int64 {
arr := r.dataByRedis("*", neId)
resultCh := make(chan int64, 1)
go func() {
resultCh <- r.voipAuthRepository.ClearAndInsert(neId, arr)
}()
return resultCh
}