diff --git a/src/X1.Application/Features/NetworkStackConfigs/Commands/CreateNetworkStackConfig/CreateNetworkStackConfigCommandHandler.cs b/src/X1.Application/Features/NetworkStackConfigs/Commands/CreateNetworkStackConfig/CreateNetworkStackConfigCommandHandler.cs index da0d4f3..907d481 100644 --- a/src/X1.Application/Features/NetworkStackConfigs/Commands/CreateNetworkStackConfig/CreateNetworkStackConfigCommandHandler.cs +++ b/src/X1.Application/Features/NetworkStackConfigs/Commands/CreateNetworkStackConfig/CreateNetworkStackConfigCommandHandler.cs @@ -108,8 +108,7 @@ public class CreateNetworkStackConfigCommandHandler : IRequestHandler public string IMSConfigId { get; set; } = null!; - - /// - /// 创建时间 - /// - public DateTime CreatedAt { get; set; } } \ No newline at end of file diff --git a/src/X1.Application/Features/NetworkStackConfigs/Commands/UpdateNetworkStackConfig/UpdateNetworkStackConfigCommandHandler.cs b/src/X1.Application/Features/NetworkStackConfigs/Commands/UpdateNetworkStackConfig/UpdateNetworkStackConfigCommandHandler.cs index 0fd15f5..b05b792 100644 --- a/src/X1.Application/Features/NetworkStackConfigs/Commands/UpdateNetworkStackConfig/UpdateNetworkStackConfigCommandHandler.cs +++ b/src/X1.Application/Features/NetworkStackConfigs/Commands/UpdateNetworkStackConfig/UpdateNetworkStackConfigCommandHandler.cs @@ -95,36 +95,62 @@ public class UpdateNetworkStackConfigCommandHandler : IRequestHandler b.Index == bindingItem.Index).ToList(); - if (conflictingBindings.Any()) + // 检查是否存在相同索引的现有绑定关系 + if (existingBindingDict.TryGetValue(bindingItem.Index, out var existingBinding)) { - _logger.LogWarning("栈与核心网/IMS绑定关系索引已存在,网络栈配置ID: {NetworkStackConfigId}, 索引: {Index}", - request.NetworkStackConfigId, bindingItem.Index); - return OperationResult.CreateFailure( - $"栈与核心网/IMS绑定关系索引已存在,网络栈配置ID: {request.NetworkStackConfigId}, 索引: {bindingItem.Index}"); + // 检查是否有实际变化 + if (existingBinding.CnId == bindingItem.CoreNetworkConfigId && + existingBinding.ImsId == bindingItem.IMSConfigId) + { + _logger.LogInformation("绑定关系无变化,跳过更新,索引: {Index}", bindingItem.Index); + continue; // 跳过无变化的绑定关系 + } + + // 更新现有的绑定关系 + 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); } - - // 创建绑定关系实体 - var binding = Stack_CoreIMS_Binding.Create( - networkStackConfigId: existingConfig.Id, - index: bindingItem.Index, - cnId: bindingItem.CoreNetworkConfigId, - imsId: bindingItem.IMSConfigId); - - // 保存绑定关系 - await _stackCoreIMSBindingRepository.AddBindingAsync(binding, cancellationToken); - - // 构建响应项 - bindingResponseItems.Add(new UpdateStackCoreIMSBindingResponseItem + else { - StackCoreIMSBindingId = binding.Id, - NetworkStackConfigId = binding.NetworkStackConfigId, - Index = binding.Index, - CoreNetworkConfigId = binding.CnId, - IMSConfigId = binding.ImsId, - CreatedAt = DateTime.UtcNow - }); + // 创建新的绑定关系 + var newBinding = Stack_CoreIMS_Binding.Create( + networkStackConfigId: existingConfig.Id, + index: bindingItem.Index, + cnId: bindingItem.CoreNetworkConfigId, + imsId: bindingItem.IMSConfigId); + + await _stackCoreIMSBindingRepository.AddBindingAsync(newBinding, cancellationToken); + + // 构建响应项 + bindingResponseItems.Add(new UpdateStackCoreIMSBindingResponseItem + { + 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 public bool IsActive { get; set; } - /// - /// 更新时间 - /// - public DateTime? UpdatedAt { get; set; } - /// /// 更新的栈与核心网/IMS绑定关系列表 /// @@ -70,14 +65,4 @@ public class UpdateStackCoreIMSBindingResponseItem /// IMS配置ID(外键) /// public string IMSConfigId { get; set; } = null!; - - /// - /// 创建时间 - /// - public DateTime CreatedAt { get; set; } - - /// - /// 更新时间 - /// - public DateTime? UpdatedAt { get; set; } } \ No newline at end of file diff --git a/src/X1.Application/Features/NetworkStackConfigs/Queries/GetNetworkStackConfigById/GetNetworkStackConfigByIdQueryHandler.cs b/src/X1.Application/Features/NetworkStackConfigs/Queries/GetNetworkStackConfigById/GetNetworkStackConfigByIdQueryHandler.cs index 647078f..47ec974 100644 --- a/src/X1.Application/Features/NetworkStackConfigs/Queries/GetNetworkStackConfigById/GetNetworkStackConfigByIdQueryHandler.cs +++ b/src/X1.Application/Features/NetworkStackConfigs/Queries/GetNetworkStackConfigById/GetNetworkStackConfigByIdQueryHandler.cs @@ -59,8 +59,7 @@ public class GetNetworkStackConfigByIdQueryHandler : IRequestHandler public string IMSConfigId { get; set; } = null!; - - /// - /// 创建时间 - /// - public DateTime CreatedAt { get; set; } - - /// - /// 更新时间 - /// - public DateTime? UpdatedAt { get; set; } } \ No newline at end of file diff --git a/src/X1.Application/Features/NetworkStackConfigs/Queries/GetNetworkStackConfigs/GetNetworkStackConfigsQueryHandler.cs b/src/X1.Application/Features/NetworkStackConfigs/Queries/GetNetworkStackConfigs/GetNetworkStackConfigsQueryHandler.cs index 63cd92e..ef5019c 100644 --- a/src/X1.Application/Features/NetworkStackConfigs/Queries/GetNetworkStackConfigs/GetNetworkStackConfigsQueryHandler.cs +++ b/src/X1.Application/Features/NetworkStackConfigs/Queries/GetNetworkStackConfigs/GetNetworkStackConfigsQueryHandler.cs @@ -65,8 +65,7 @@ public class GetNetworkStackConfigsQueryHandler : IRequestHandler public string IMSConfigId { get; set; } = null!; - - /// - /// 创建时间 - /// - public DateTime CreatedAt { get; set; } - - /// - /// 更新时间 - /// - public DateTime? UpdatedAt { get; set; } } \ No newline at end of file diff --git a/src/X1.Domain/Entities/NetworkProfile/NetworkStackConfig.cs b/src/X1.Domain/Entities/NetworkProfile/NetworkStackConfig.cs index 1a7206f..9c2829b 100644 --- a/src/X1.Domain/Entities/NetworkProfile/NetworkStackConfig.cs +++ b/src/X1.Domain/Entities/NetworkProfile/NetworkStackConfig.cs @@ -53,7 +53,7 @@ public class NetworkStackConfig : AuditableEntity { Id = Guid.NewGuid().ToString(), NetworkStackName = networkStackName, - RanId = ranId, + RanId = string.IsNullOrWhiteSpace(ranId)?null:ranId, Description = description, IsActive = isActive, CreatedAt = DateTime.UtcNow, diff --git a/src/modify.md b/src/modify.md index 2135366..68898af 100644 --- a/src/modify.md +++ b/src/modify.md @@ -2109,4 +2109,118 @@ const createResult = await coreNetworkConfigService.createCoreNetworkConfig({ 2. 验证搜索和过滤功能 3. 检查表格显示和分页功能 4. 确认表单验证和提交功能 -5. 测试栈与核心网/IMS绑定关系管理 \ No newline at end of file +5. 测试栈与核心网/IMS绑定关系管理 + +## 2025-01-29 - 代码提交和.gitignore更新 + +### 修改内容 +1. **代码提交和推送** + - 提交了网络栈配置管理功能的重构代码 + - 推送代码到远程仓库 `feature/x1-web-request` 分支 + - 同步远程分支更新 + +2. **更新.gitignore文件** + - 添加 `X1.WebAPI/logs/` 目录到忽略列表 + - 添加 `*.log` 文件模式到忽略列表 + - 从版本控制中移除已跟踪的日志文件 + - 提交并推送.gitignore更新 + +### 技术细节 +- 使用 `git add .` 添加所有修改文件 +- 使用 `git commit -m` 提交代码,包含详细的提交信息 +- 使用 `git push origin feature/x1-web-request` 推送到远程分支 +- 使用 `git rm --cached` 从版本控制中移除日志文件 +- 更新.gitignore文件以忽略日志文件 + +### 提交信息 +``` +feat: 重构网络栈配置管理功能 +- 修复networkStackConfigService.ts接口不匹配问题 +- 删除未使用的stackCoreIMSBindingService.ts +- 重构NetworkStackConfigForm为NetworkStackConfigDrawer +- 实现RAN配置下拉框,支持搜索功能 +- 移除激活配置复选框,默认激活 +- 修复loadRANConfigurations使用正确服务 +- 实现核心网和IMS配置下拉框 +- 优化绑定关系布局和滚动条显示 +- 添加标签右对齐样式 +- 修复下拉框定位和点击交互问题 +- 实现下拉框互斥控制和自动关闭 +- 添加完整的表单校验逻辑 +- 实现内联错误提示替代弹窗 + +chore: 更新.gitignore忽略日志文件 +- 添加X1.WebAPI/logs/目录到忽略列表 +- 添加*.log文件模式到忽略列表 +- 从版本控制中移除已跟踪的日志文件 +``` + +### 状态 +✅ 完成 - 所有代码已成功提交、推送和同步到远程仓库 + +## 2024-12-19 修复网络栈配置更新命令处理器绑定关系更新逻辑 + +### 修改概述 +修复了 `UpdateNetworkStackConfigCommandHandler` 中绑定关系更新逻辑的问题。原代码总是创建新的绑定关系,但实际上应该根据索引是否存在来决定是更新现有绑定关系还是创建新的绑定关系,并且应该跳过无变化的绑定关系。同时移除了响应类中不必要的时间字段。 + +### 修改的文件 + +#### 1. `X1.Application/Features/NetworkStackConfigs/Commands/UpdateNetworkStackConfig/UpdateNetworkStackConfigCommandHandler.cs` +- **问题描述**:原代码总是创建新的绑定关系,无法处理用户只想修改现有绑定关系的 `cnId` 或 `imsId` 的场景,也没有检查是否有实际变化 +- **修复内容**: + - 检查是否存在相同索引的现有绑定关系 + - 如果存在,检查是否有实际变化(`cnId` 和 `imsId` 是否相同) + - 如果无变化,跳过更新并记录日志 + - 如果有变化,则更新现有的绑定关系(使用 `Update` 方法) + - 如果不存在,则创建新的绑定关系 + - 修复了 `CreatedAt` 属性访问错误(实体没有该属性) + +#### 2. `X1.Application/Features/NetworkStackConfigs/Commands/UpdateNetworkStackConfig/UpdateNetworkStackConfigResponse.cs` +- **问题描述**:响应类中包含不必要的时间字段 +- **修复内容**: + - 移除了 `UpdateNetworkStackConfigResponse` 中的 `UpdatedAt` 字段 + - 移除了 `UpdateStackCoreIMSBindingResponseItem` 中的 `CreatedAt` 和 `UpdatedAt` 字段 + +#### 3. `X1.Application/Features/NetworkStackConfigs/Commands/CreateNetworkStackConfig/CreateNetworkStackConfigResponse.cs` +- **问题描述**:响应类中包含不必要的时间字段 +- **修复内容**: + - 移除了 `CreateStackCoreIMSBindingResponseItem` 中的 `CreatedAt` 字段 + +#### 4. `X1.Application/Features/NetworkStackConfigs/Commands/CreateNetworkStackConfig/CreateNetworkStackConfigCommandHandler.cs` +- **问题描述**:命令处理器中设置了不必要的时间字段 +- **修复内容**: + - 移除了构建响应项时的 `CreatedAt` 字段设置 + +#### 5. `X1.Application/Features/NetworkStackConfigs/Queries/GetNetworkStackConfigs/GetNetworkStackConfigsResponse.cs` +- **问题描述**:响应类中包含不必要的时间字段 +- **修复内容**: + - 移除了 `GetNetworkStackConfigsBindingResponseItem` 中的 `CreatedAt` 和 `UpdatedAt` 字段 + +#### 6. `X1.Application/Features/NetworkStackConfigs/Queries/GetNetworkStackConfigs/GetNetworkStackConfigsQueryHandler.cs` +- **问题描述**:查询处理器中设置了不必要的时间字段 +- **修复内容**: + - 移除了构建响应项时的 `CreatedAt` 字段设置 + +#### 7. `X1.Application/Features/NetworkStackConfigs/Queries/GetNetworkStackConfigById/GetNetworkStackConfigByIdResponse.cs` +- **问题描述**:响应类中包含不必要的时间字段 +- **修复内容**: + - 移除了 `GetNetworkStackConfigByIdBindingResponseItem` 中的 `CreatedAt` 和 `UpdatedAt` 字段 + +#### 8. `X1.Application/Features/NetworkStackConfigs/Queries/GetNetworkStackConfigById/GetNetworkStackConfigByIdQueryHandler.cs` +- **问题描述**:查询处理器中设置了不必要的时间字段 +- **修复内容**: + - 移除了构建响应项时的 `CreatedAt` 字段设置 + +### 技术细节 +- **更新策略**:根据索引是否存在决定更新或创建 +- **变化检测**:比较现有绑定关系的 `cnId` 和 `imsId` 与请求中的值 +- **业务逻辑**:支持修改现有绑定关系的核心网配置ID或IMS配置ID +- **数据完整性**:保持索引唯一性约束,避免不必要的更新操作 +- **响应优化**:移除不必要的时间字段,简化响应结构 + +### 影响范围 +- **功能修复**:修复了网络栈配置更新功能中的绑定关系更新逻辑 +- **性能优化**:避免不必要的数据库更新操作 +- **业务逻辑**:支持部分更新绑定关系的场景 +- **用户体验**:允许用户只修改绑定关系的部分字段 +- **响应优化**:简化了响应结构,移除了不必要的时间字段 \ No newline at end of file