|
|
@ -95,36 +95,62 @@ public class UpdateNetworkStackConfigCommandHandler : IRequestHandler<UpdateNetw |
|
|
|
|
|
|
|
foreach (var bindingItem in request.StackCoreIMSBindings) |
|
|
|
{ |
|
|
|
// 检查索引是否与其他绑定关系冲突(排除当前索引)
|
|
|
|
var conflictingBindings = existingBindings.Where(b => b.Index == bindingItem.Index).ToList(); |
|
|
|
if (conflictingBindings.Any()) |
|
|
|
{ |
|
|
|
_logger.LogWarning("栈与核心网/IMS绑定关系索引已存在,网络栈配置ID: {NetworkStackConfigId}, 索引: {Index}", |
|
|
|
request.NetworkStackConfigId, bindingItem.Index); |
|
|
|
return OperationResult<UpdateNetworkStackConfigResponse>.CreateFailure( |
|
|
|
$"栈与核心网/IMS绑定关系索引已存在,网络栈配置ID: {request.NetworkStackConfigId}, 索引: {bindingItem.Index}"); |
|
|
|
// 检查是否存在相同索引的现有绑定关系
|
|
|
|
if (existingBindingDict.TryGetValue(bindingItem.Index, out var existingBinding)) |
|
|
|
{ |
|
|
|
// 检查是否有实际变化
|
|
|
|
if (existingBinding.CnId == bindingItem.CoreNetworkConfigId && |
|
|
|
existingBinding.ImsId == bindingItem.IMSConfigId) |
|
|
|
{ |
|
|
|
_logger.LogInformation("绑定关系无变化,跳过更新,索引: {Index}", bindingItem.Index); |
|
|
|
continue; // 跳过无变化的绑定关系
|
|
|
|
} |
|
|
|
|
|
|
|
// 创建绑定关系实体
|
|
|
|
var binding = Stack_CoreIMS_Binding.Create( |
|
|
|
// 更新现有的绑定关系
|
|
|
|
existingBinding.Update( |
|
|
|
index: bindingItem.Index, |
|
|
|
cnId: bindingItem.CoreNetworkConfigId, |
|
|
|
imsId: bindingItem.IMSConfigId); |
|
|
|
|
|
|
|
_stackCoreIMSBindingRepository.UpdateBinding(existingBinding); |
|
|
|
|
|
|
|
// 构建响应项
|
|
|
|
bindingResponseItems.Add(new UpdateStackCoreIMSBindingResponseItem |
|
|
|
{ |
|
|
|
StackCoreIMSBindingId = existingBinding.Id, |
|
|
|
NetworkStackConfigId = existingBinding.NetworkStackConfigId, |
|
|
|
Index = existingBinding.Index, |
|
|
|
CoreNetworkConfigId = existingBinding.CnId, |
|
|
|
IMSConfigId = existingBinding.ImsId |
|
|
|
}); |
|
|
|
|
|
|
|
_logger.LogInformation("更新现有绑定关系,索引: {Index}, 核心网配置ID: {CnId}, IMS配置ID: {ImsId}", |
|
|
|
bindingItem.Index, bindingItem.CoreNetworkConfigId, bindingItem.IMSConfigId); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
// 创建新的绑定关系
|
|
|
|
var newBinding = Stack_CoreIMS_Binding.Create( |
|
|
|
networkStackConfigId: existingConfig.Id, |
|
|
|
index: bindingItem.Index, |
|
|
|
cnId: bindingItem.CoreNetworkConfigId, |
|
|
|
imsId: bindingItem.IMSConfigId); |
|
|
|
|
|
|
|
// 保存绑定关系
|
|
|
|
await _stackCoreIMSBindingRepository.AddBindingAsync(binding, cancellationToken); |
|
|
|
await _stackCoreIMSBindingRepository.AddBindingAsync(newBinding, cancellationToken); |
|
|
|
|
|
|
|
// 构建响应项
|
|
|
|
bindingResponseItems.Add(new UpdateStackCoreIMSBindingResponseItem |
|
|
|
{ |
|
|
|
StackCoreIMSBindingId = binding.Id, |
|
|
|
NetworkStackConfigId = binding.NetworkStackConfigId, |
|
|
|
Index = binding.Index, |
|
|
|
CoreNetworkConfigId = binding.CnId, |
|
|
|
IMSConfigId = binding.ImsId, |
|
|
|
CreatedAt = DateTime.UtcNow |
|
|
|
StackCoreIMSBindingId = newBinding.Id, |
|
|
|
NetworkStackConfigId = newBinding.NetworkStackConfigId, |
|
|
|
Index = newBinding.Index, |
|
|
|
CoreNetworkConfigId = newBinding.CnId, |
|
|
|
IMSConfigId = newBinding.ImsId |
|
|
|
}); |
|
|
|
|
|
|
|
_logger.LogInformation("创建新绑定关系,索引: {Index}, 核心网配置ID: {CnId}, IMS配置ID: {ImsId}", |
|
|
|
bindingItem.Index, bindingItem.CoreNetworkConfigId, bindingItem.IMSConfigId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
_logger.LogInformation("成功更新 {BindingCount} 个栈与核心网/IMS绑定关系", bindingResponseItems.Count); |
|
|
@ -141,7 +167,6 @@ public class UpdateNetworkStackConfigCommandHandler : IRequestHandler<UpdateNetw |
|
|
|
RanId = existingConfig.RanId, |
|
|
|
Description = existingConfig.Description, |
|
|
|
IsActive = existingConfig.IsActive, |
|
|
|
UpdatedAt = existingConfig.UpdatedAt, |
|
|
|
StackCoreIMSBindings = bindingResponseItems |
|
|
|
}; |
|
|
|
|
|
|
|