Browse Source

feat: 网络配置相关功能优化和修复,包括NetworkConfig实体及相关命令/查询处理

feature/x1-owen-debug
root 4 weeks ago
parent
commit
057759fe64
  1. 5
      src/X1.Application/Features/NetworkConfigs/Commands/CreateNetworkConfig/CreateNetworkConfigCommand.cs
  2. 1
      src/X1.Application/Features/NetworkConfigs/Commands/CreateNetworkConfig/CreateNetworkConfigCommandHandler.cs
  3. 5
      src/X1.Application/Features/NetworkConfigs/Commands/UpdateNetworkConfig/UpdateNetworkConfigCommand.cs
  4. 1
      src/X1.Application/Features/NetworkConfigs/Commands/UpdateNetworkConfig/UpdateNetworkConfigCommandHandler.cs
  5. 1
      src/X1.Application/Features/NetworkConfigs/Queries/GetNetworkConfigById/GetNetworkConfigByIdQueryHandler.cs
  6. 5
      src/X1.Application/Features/NetworkConfigs/Queries/GetNetworkConfigById/GetNetworkConfigByIdResponse.cs
  7. 1
      src/X1.Application/Features/NetworkConfigs/Queries/GetNetworkConfigs/GetNetworkConfigsQueryHandler.cs
  8. 5
      src/X1.Application/Features/NetworkConfigs/Queries/GetNetworkConfigs/GetNetworkConfigsResponse.cs
  9. 39
      src/X1.Domain/Entities/Device/NetworkConfig.cs
  10. 12
      src/X1.Domain/Specifications/NetworkConfigSamples.json
  11. 4
      src/X1.Domain/Specifications/NetworkConfig_Test.http
  12. 15
      src/X1.Infrastructure/Configurations/Device/NetworkConfigConfiguration.cs
  13. 2
      src/X1.Infrastructure/Repositories/Device/NetworkConfigRepository.cs
  14. 1
      src/X1.Presentation/Controllers/NetworkConfigsController.cs

5
src/X1.Application/Features/NetworkConfigs/Commands/CreateNetworkConfig/CreateNetworkConfigCommand.cs

@ -22,11 +22,6 @@ public class CreateNetworkConfigCommand : IRequest<OperationResult<CreateNetwork
[MaxLength(100)] [MaxLength(100)]
public string Name { get; set; } = null!; public string Name { get; set; } = null!;
/// <summary>
/// 配置索引(仅对IMS和MME类型有效)
/// </summary>
public int? ConfigIndex { get; set; }
/// <summary> /// <summary>
/// PLMN字段(移动国家代码+移动网络代码) /// PLMN字段(移动国家代码+移动网络代码)
/// </summary> /// </summary>

1
src/X1.Application/Features/NetworkConfigs/Commands/CreateNetworkConfig/CreateNetworkConfigCommandHandler.cs

@ -54,7 +54,6 @@ public class CreateNetworkConfigCommandHandler : IRequestHandler<CreateNetworkCo
request.Name, request.Name,
request.ConfigContent, request.ConfigContent,
currentUser, currentUser,
request.ConfigIndex,
request.Plmn, request.Plmn,
request.Description, request.Description,
request.IsDisabled); request.IsDisabled);

5
src/X1.Application/Features/NetworkConfigs/Commands/UpdateNetworkConfig/UpdateNetworkConfigCommand.cs

@ -23,11 +23,6 @@ public class UpdateNetworkConfigCommand : IRequest<OperationResult<UpdateNetwork
[MaxLength(100)] [MaxLength(100)]
public string Name { get; set; } = null!; public string Name { get; set; } = null!;
/// <summary>
/// 配置索引(仅对IMS和MME类型有效)
/// </summary>
public int? ConfigIndex { get; set; }
/// <summary> /// <summary>
/// PLMN字段(移动国家代码+移动网络代码) /// PLMN字段(移动国家代码+移动网络代码)
/// </summary> /// </summary>

1
src/X1.Application/Features/NetworkConfigs/Commands/UpdateNetworkConfig/UpdateNetworkConfigCommandHandler.cs

@ -60,7 +60,6 @@ public class UpdateNetworkConfigCommandHandler : IRequestHandler<UpdateNetworkCo
request.Name, request.Name,
request.ConfigContent, request.ConfigContent,
currentUser, currentUser,
request.ConfigIndex,
request.Plmn, request.Plmn,
request.Description, request.Description,
request.IsDisabled); request.IsDisabled);

1
src/X1.Application/Features/NetworkConfigs/Queries/GetNetworkConfigById/GetNetworkConfigByIdQueryHandler.cs

@ -41,7 +41,6 @@ public class GetNetworkConfigByIdQueryHandler : IRequestHandler<GetNetworkConfig
Id = networkConfig.Id, Id = networkConfig.Id,
ConfigType = networkConfig.ConfigType, ConfigType = networkConfig.ConfigType,
Name = networkConfig.Name, Name = networkConfig.Name,
ConfigIndex = networkConfig.ConfigIndex,
Plmn = networkConfig.Plmn, Plmn = networkConfig.Plmn,
ConfigContent = networkConfig.ConfigContent, ConfigContent = networkConfig.ConfigContent,
Description = networkConfig.Description, Description = networkConfig.Description,

5
src/X1.Application/Features/NetworkConfigs/Queries/GetNetworkConfigById/GetNetworkConfigByIdResponse.cs

@ -22,11 +22,6 @@ public class GetNetworkConfigByIdResponse
/// </summary> /// </summary>
public string Name { get; set; } = null!; public string Name { get; set; } = null!;
/// <summary>
/// 配置索引
/// </summary>
public int? ConfigIndex { get; set; }
/// <summary> /// <summary>
/// PLMN字段 /// PLMN字段
/// </summary> /// </summary>

1
src/X1.Application/Features/NetworkConfigs/Queries/GetNetworkConfigs/GetNetworkConfigsQueryHandler.cs

@ -69,7 +69,6 @@ public class GetNetworkConfigsQueryHandler : IRequestHandler<GetNetworkConfigsQu
Id = config.Id, Id = config.Id,
ConfigType = config.ConfigType, ConfigType = config.ConfigType,
Name = config.Name, Name = config.Name,
ConfigIndex = config.ConfigIndex,
Plmn = config.Plmn, Plmn = config.Plmn,
ConfigContent = config.ConfigContent, ConfigContent = config.ConfigContent,
Description = config.Description, Description = config.Description,

5
src/X1.Application/Features/NetworkConfigs/Queries/GetNetworkConfigs/GetNetworkConfigsResponse.cs

@ -22,11 +22,6 @@ public class NetworkConfigDto
/// </summary> /// </summary>
public string Name { get; set; } = null!; public string Name { get; set; } = null!;
/// <summary>
/// 配置索引
/// </summary>
public int? ConfigIndex { get; set; }
/// <summary> /// <summary>
/// PLMN字段 /// PLMN字段
/// </summary> /// </summary>

39
src/X1.Domain/Entities/Device/NetworkConfig.cs

@ -44,11 +44,6 @@ public class NetworkConfig : AuditableEntity
[MaxLength(100)] [MaxLength(100)]
public string Name { get; private set; } = null!; public string Name { get; private set; } = null!;
/// <summary>
/// 配置索引(仅对IMS和MME类型有效)
/// </summary>
public int? ConfigIndex { get; private set; }
/// <summary> /// <summary>
/// PLMN字段(移动国家代码+移动网络代码) /// PLMN字段(移动国家代码+移动网络代码)
/// </summary> /// </summary>
@ -80,20 +75,18 @@ public class NetworkConfig : AuditableEntity
string name, string name,
string configContent, string configContent,
string createdBy, string createdBy,
int? configIndex = null,
string? plmn = null, string? plmn = null,
string? description = null, string? description = null,
bool isDisabled = false) bool isDisabled = false)
{ {
// 验证业务规则 // 验证业务规则
ValidateCreateParameters(configType, configIndex, plmn); ValidateCreateParameters(configType, plmn);
var networkConfig = new NetworkConfig var networkConfig = new NetworkConfig
{ {
Id = Guid.NewGuid().ToString(), Id = Guid.NewGuid().ToString(),
ConfigType = configType, ConfigType = configType,
Name = name, Name = name,
ConfigIndex = configIndex,
Plmn = plmn, Plmn = plmn,
ConfigContent = configContent, ConfigContent = configContent,
Description = description, Description = description,
@ -114,16 +107,14 @@ public class NetworkConfig : AuditableEntity
string name, string name,
string configContent, string configContent,
string updatedBy, string updatedBy,
int? configIndex = null,
string? plmn = null, string? plmn = null,
string? description = null, string? description = null,
bool isDisabled = false) bool isDisabled = false)
{ {
// 验证业务规则 // 验证业务规则
ValidateUpdateParameters(ConfigType, configIndex, plmn); ValidateUpdateParameters(ConfigType, plmn);
Name = name; Name = name;
ConfigIndex = configIndex;
Plmn = plmn; Plmn = plmn;
ConfigContent = configContent; ConfigContent = configContent;
Description = description; Description = description;
@ -153,7 +144,7 @@ public class NetworkConfig : AuditableEntity
/// <summary> /// <summary>
/// 验证创建参数 /// 验证创建参数
/// </summary> /// </summary>
private static void ValidateCreateParameters(NetworkConfigType configType, int? configIndex, string? plmn) private static void ValidateCreateParameters(NetworkConfigType configType, string? plmn)
{ {
// 验证PLMN字段的必填性 // 验证PLMN字段的必填性
if (configType == NetworkConfigType.IMS || configType == NetworkConfigType.MME) if (configType == NetworkConfigType.IMS || configType == NetworkConfigType.MME)
@ -163,23 +154,12 @@ public class NetworkConfig : AuditableEntity
throw new ArgumentException($"PLMN字段对于{configType}类型是必填的"); throw new ArgumentException($"PLMN字段对于{configType}类型是必填的");
} }
} }
// 验证配置索引
if (configType == NetworkConfigType.RAN && configIndex.HasValue)
{
throw new ArgumentException("RAN类型不支持配置索引");
}
if ((configType == NetworkConfigType.IMS || configType == NetworkConfigType.MME) && !configIndex.HasValue)
{
throw new ArgumentException($"{configType}类型必须提供配置索引");
}
} }
/// <summary> /// <summary>
/// 验证更新参数 /// 验证更新参数
/// </summary> /// </summary>
private static void ValidateUpdateParameters(NetworkConfigType configType, int? configIndex, string? plmn) private static void ValidateUpdateParameters(NetworkConfigType configType, string? plmn)
{ {
// 验证PLMN字段的必填性 // 验证PLMN字段的必填性
if (configType == NetworkConfigType.IMS || configType == NetworkConfigType.MME) if (configType == NetworkConfigType.IMS || configType == NetworkConfigType.MME)
@ -189,16 +169,5 @@ public class NetworkConfig : AuditableEntity
throw new ArgumentException($"PLMN字段对于{configType}类型是必填的"); throw new ArgumentException($"PLMN字段对于{configType}类型是必填的");
} }
} }
// 验证配置索引
if (configType == NetworkConfigType.RAN && configIndex.HasValue)
{
throw new ArgumentException("RAN类型不支持配置索引");
}
if ((configType == NetworkConfigType.IMS || configType == NetworkConfigType.MME) && !configIndex.HasValue)
{
throw new ArgumentException($"{configType}类型必须提供配置索引");
}
} }
} }

12
src/X1.Domain/Specifications/NetworkConfigSamples.json

@ -3,7 +3,6 @@
{ {
"configType": "RAN", "configType": "RAN",
"name": "RAN_Config_Default", "name": "RAN_Config_Default",
"configIndex": null,
"plmn": null, "plmn": null,
"configContent": { "configContent": {
"frequencyBands": ["B1", "B3", "B5", "B8"], "frequencyBands": ["B1", "B3", "B5", "B8"],
@ -30,7 +29,6 @@
{ {
"configType": "IMS", "configType": "IMS",
"name": "IMS_Config_ChinaMobile", "name": "IMS_Config_ChinaMobile",
"configIndex": 0,
"plmn": "46000", "plmn": "46000",
"configContent": { "configContent": {
"pCscfServers": [ "pCscfServers": [
@ -85,7 +83,6 @@
{ {
"configType": "IMS", "configType": "IMS",
"name": "IMS_Config_ChinaUnicom", "name": "IMS_Config_ChinaUnicom",
"configIndex": 1,
"plmn": "46001", "plmn": "46001",
"configContent": { "configContent": {
"pCscfServers": [ "pCscfServers": [
@ -135,7 +132,6 @@
{ {
"configType": "MME", "configType": "MME",
"name": "MME_Config_Primary", "name": "MME_Config_Primary",
"configIndex": 0,
"plmn": "46000", "plmn": "46000",
"configContent": { "configContent": {
"mmeCode": "001", "mmeCode": "001",
@ -188,7 +184,6 @@
{ {
"configType": "MME", "configType": "MME",
"name": "MME_Config_Secondary", "name": "MME_Config_Secondary",
"configIndex": 1,
"plmn": "46000", "plmn": "46000",
"configContent": { "configContent": {
"mmeCode": "002", "mmeCode": "002",
@ -213,13 +208,6 @@
"transport": "SCTP" "transport": "SCTP"
} }
], ],
"sgsnServers": [
{
"address": "10.7.2.100",
"port": 2123,
"transport": "SCTP"
}
],
"securitySettings": { "securitySettings": {
"integrityAlgorithm": ["EIA1", "EIA2", "EIA3"], "integrityAlgorithm": ["EIA1", "EIA2", "EIA3"],
"cipheringAlgorithm": ["EEA1", "EEA2", "EEA3"], "cipheringAlgorithm": ["EEA1", "EEA2", "EEA3"],

4
src/X1.Domain/Specifications/NetworkConfig_Test.http

@ -8,7 +8,6 @@ Authorization: Bearer {{token}}
{ {
"configType": 1, "configType": 1,
"name": "RAN_Config_Test", "name": "RAN_Config_Test",
"configIndex": null,
"plmn": null, "plmn": null,
"configContent": "{\"frequencyBands\":[\"B1\",\"B3\"],\"bandwidth\":\"20MHz\",\"powerControl\":{\"maxPower\":43,\"minPower\":23}}", "configContent": "{\"frequencyBands\":[\"B1\",\"B3\"],\"bandwidth\":\"20MHz\",\"powerControl\":{\"maxPower\":43,\"minPower\":23}}",
"description": "测试RAN配置", "description": "测试RAN配置",
@ -23,7 +22,6 @@ Authorization: Bearer {{token}}
{ {
"configType": 2, "configType": 2,
"name": "IMS_Config_Test", "name": "IMS_Config_Test",
"configIndex": 0,
"plmn": "46000", "plmn": "46000",
"configContent": "{\"pCscfServers\":[{\"address\":\"10.1.1.100\",\"port\":5060,\"transport\":\"UDP\"}],\"sCscfServers\":[{\"address\":\"10.2.1.100\",\"port\":5060,\"transport\":\"UDP\"}]}", "configContent": "{\"pCscfServers\":[{\"address\":\"10.1.1.100\",\"port\":5060,\"transport\":\"UDP\"}],\"sCscfServers\":[{\"address\":\"10.2.1.100\",\"port\":5060,\"transport\":\"UDP\"}]}",
"description": "测试IMS配置", "description": "测试IMS配置",
@ -38,7 +36,6 @@ Authorization: Bearer {{token}}
{ {
"configType": 3, "configType": 3,
"name": "MME_Config_Test", "name": "MME_Config_Test",
"configIndex": 0,
"plmn": "46000", "plmn": "46000",
"configContent": "{\"mmeCode\":\"001\",\"mmeGroupId\":\"001\",\"tacList\":[\"0001\",\"0002\"],\"servingGwList\":[{\"address\":\"10.5.1.100\",\"weight\":100}]}", "configContent": "{\"mmeCode\":\"001\",\"mmeGroupId\":\"001\",\"tacList\":[\"0001\",\"0002\"],\"servingGwList\":[{\"address\":\"10.5.1.100\",\"weight\":100}]}",
"description": "测试MME配置", "description": "测试MME配置",
@ -77,7 +74,6 @@ Authorization: Bearer {{token}}
{ {
"networkConfigId": "{{networkConfigId}}", "networkConfigId": "{{networkConfigId}}",
"name": "RAN_Config_Updated", "name": "RAN_Config_Updated",
"configIndex": null,
"plmn": null, "plmn": null,
"configContent": "{\"frequencyBands\":[\"B1\",\"B3\",\"B5\"],\"bandwidth\":\"40MHz\",\"powerControl\":{\"maxPower\":46,\"minPower\":20}}", "configContent": "{\"frequencyBands\":[\"B1\",\"B3\",\"B5\"],\"bandwidth\":\"40MHz\",\"powerControl\":{\"maxPower\":46,\"minPower\":20}}",
"description": "更新后的RAN配置", "description": "更新后的RAN配置",

15
src/X1.Infrastructure/Configurations/Device/NetworkConfigConfiguration.cs

@ -30,9 +30,6 @@ public class NetworkConfigConfiguration : IEntityTypeConfiguration<NetworkConfig
.HasMaxLength(100) .HasMaxLength(100)
.IsRequired(); .IsRequired();
builder.Property(x => x.ConfigIndex)
.IsRequired(false);
builder.Property(x => x.Plmn) builder.Property(x => x.Plmn)
.HasMaxLength(10) .HasMaxLength(10)
.IsRequired(false); .IsRequired(false);
@ -74,9 +71,6 @@ public class NetworkConfigConfiguration : IEntityTypeConfiguration<NetworkConfig
builder.HasIndex(x => x.Plmn) builder.HasIndex(x => x.Plmn)
.HasDatabaseName("IX_NetworkConfigs_Plmn"); .HasDatabaseName("IX_NetworkConfigs_Plmn");
builder.HasIndex(x => x.ConfigIndex)
.HasDatabaseName("IX_NetworkConfigs_ConfigIndex");
builder.HasIndex(x => x.IsDisabled) builder.HasIndex(x => x.IsDisabled)
.HasDatabaseName("IX_NetworkConfigs_IsDisabled"); .HasDatabaseName("IX_NetworkConfigs_IsDisabled");
@ -84,16 +78,7 @@ public class NetworkConfigConfiguration : IEntityTypeConfiguration<NetworkConfig
builder.HasIndex(x => new { x.ConfigType, x.Plmn }) builder.HasIndex(x => new { x.ConfigType, x.Plmn })
.HasDatabaseName("IX_NetworkConfigs_ConfigType_Plmn"); .HasDatabaseName("IX_NetworkConfigs_ConfigType_Plmn");
builder.HasIndex(x => new { x.ConfigType, x.ConfigIndex })
.HasDatabaseName("IX_NetworkConfigs_ConfigType_ConfigIndex");
// 约束配置 // 约束配置
builder.HasCheckConstraint("CK_NetworkConfigs_ConfigIndex_RAN",
"NOT (\"ConfigType\" = 1 AND \"ConfigIndex\" IS NOT NULL)");
builder.HasCheckConstraint("CK_NetworkConfigs_ConfigIndex_IMS_MME",
"NOT (\"ConfigType\" IN (2, 3) AND \"ConfigIndex\" IS NULL)");
builder.HasCheckConstraint("CK_NetworkConfigs_Plmn_IMS_MME", builder.HasCheckConstraint("CK_NetworkConfigs_Plmn_IMS_MME",
"NOT (\"ConfigType\" IN (2, 3) AND \"Plmn\" IS NULL)"); "NOT (\"ConfigType\" IN (2, 3) AND \"Plmn\" IS NULL)");

2
src/X1.Infrastructure/Repositories/Device/NetworkConfigRepository.cs

@ -98,7 +98,7 @@ public class NetworkConfigRepository : BaseRepository<NetworkConfig>, INetworkCo
public async Task<IList<NetworkConfig>> GetNetworkConfigsByTypeAndPlmnAsync(NetworkConfigType configType, string plmn, CancellationToken cancellationToken = default) public async Task<IList<NetworkConfig>> GetNetworkConfigsByTypeAndPlmnAsync(NetworkConfigType configType, string plmn, CancellationToken cancellationToken = default)
{ {
var networkConfigs = await QueryRepository.FindAsync(x => x.ConfigType == configType && x.Plmn == plmn, cancellationToken: cancellationToken); var networkConfigs = await QueryRepository.FindAsync(x => x.ConfigType == configType && x.Plmn == plmn, cancellationToken: cancellationToken);
return networkConfigs.OrderBy(x => x.ConfigIndex).ThenBy(x => x.Name).ToList(); return networkConfigs.OrderBy(x => x.Name).ToList();
} }
/// <summary> /// <summary>

1
src/X1.Presentation/Controllers/NetworkConfigsController.cs

@ -138,7 +138,6 @@ public class NetworkConfigsController : ApiController
/// { /// {
/// "configType": 1, /// "configType": 1,
/// "name": "RAN_Config_Default", /// "name": "RAN_Config_Default",
/// "configIndex": null,
/// "plmn": null, /// "plmn": null,
/// "configContent": "{\"frequencyBands\":[\"B1\",\"B3\"]}", /// "configContent": "{\"frequencyBands\":[\"B1\",\"B3\"]}",
/// "description": "默认RAN配置", /// "description": "默认RAN配置",

Loading…
Cancel
Save