diff --git a/InterfaceForward.sln b/InterfaceForward.sln index 24b090f..d7add9a 100644 --- a/InterfaceForward.sln +++ b/InterfaceForward.sln @@ -17,6 +17,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution items", "solution EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InterfaceForward.Domain", "src\InterfaceForward.Domain\InterfaceForward.Domain.csproj", "{AB53F0CC-DE7A-4AE9-B6AA-2A8283B4EB23}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InterfaceForward.Infrastructure", "src\InterfaceForward.Infrastructure\InterfaceForward.Infrastructure.csproj", "{5FF71C79-8BD4-45AE-B999-8481F32BC2C0}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -39,11 +41,16 @@ Global {AB53F0CC-DE7A-4AE9-B6AA-2A8283B4EB23}.Debug|Any CPU.Build.0 = Debug|Any CPU {AB53F0CC-DE7A-4AE9-B6AA-2A8283B4EB23}.Release|Any CPU.ActiveCfg = Release|Any CPU {AB53F0CC-DE7A-4AE9-B6AA-2A8283B4EB23}.Release|Any CPU.Build.0 = Release|Any CPU + {5FF71C79-8BD4-45AE-B999-8481F32BC2C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5FF71C79-8BD4-45AE-B999-8481F32BC2C0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5FF71C79-8BD4-45AE-B999-8481F32BC2C0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5FF71C79-8BD4-45AE-B999-8481F32BC2C0}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {9609CC2D-CC83-4C01-BE36-C0429A06B238} = {EA8DF4A8-7618-4C28-BEDC-21629B8B219B} {6DAA9CF1-155A-4FC7-9EAE-7E8FA22CD23A} = {EA8DF4A8-7618-4C28-BEDC-21629B8B219B} {0E2F3A09-4EC4-4A61-85DC-9F9F770C3B65} = {EA8DF4A8-7618-4C28-BEDC-21629B8B219B} {AB53F0CC-DE7A-4AE9-B6AA-2A8283B4EB23} = {EA8DF4A8-7618-4C28-BEDC-21629B8B219B} + {5FF71C79-8BD4-45AE-B999-8481F32BC2C0} = {EA8DF4A8-7618-4C28-BEDC-21629B8B219B} EndGlobalSection EndGlobal diff --git a/src/InterfaceForward.Domain/DictionaryAggregate/DictionaryEntity.cs b/src/InterfaceForward.Domain/DictionaryAggregate/DictionaryEntity.cs new file mode 100644 index 0000000..8efed1e --- /dev/null +++ b/src/InterfaceForward.Domain/DictionaryAggregate/DictionaryEntity.cs @@ -0,0 +1,19 @@ +using System; +using Fake.DomainDrivenDesign.Entities.Auditing; + +namespace InterfaceForward.Domain.DictionaryAggregate; + +public class DictionaryEntity:FullAuditedAggregate +{ + public string Name { get; private set; } + public string Code { get; private set; } + public string? Description { get; private set; } + + + public DictionaryEntity(string name, string code, string? description) + { + Name = name; + Code = code; + Description = description; + } +} \ No newline at end of file diff --git a/src/InterfaceForward.Domain/DictionaryAggregate/DictionaryItemEntity.cs b/src/InterfaceForward.Domain/DictionaryAggregate/DictionaryItemEntity.cs new file mode 100644 index 0000000..6663a64 --- /dev/null +++ b/src/InterfaceForward.Domain/DictionaryAggregate/DictionaryItemEntity.cs @@ -0,0 +1,22 @@ +using System; +using Fake.DomainDrivenDesign.Entities.Auditing; + +namespace InterfaceForward.Domain.DictionaryAggregate; + +public class DictionaryItemEntity : FullAuditedEntity +{ + public DictionaryItemEntity(Guid dictionaryId, string name, int value, int sort, string? description = null) + { + DictionaryId = dictionaryId; + Name = name; + Value = value; + Sort = sort; + Description = description; + } + + public Guid DictionaryId { get; private set; } + public string Name { get; private set; } + public int Value { get; private set; } + public int Sort { get; private set; } + public string? Description { get; private set; } +} \ No newline at end of file diff --git a/src/InterfaceForward.Domain/InterfaceAggregate/InterfaceEntity.cs b/src/InterfaceForward.Domain/InterfaceAggregate/InterfaceEntity.cs new file mode 100644 index 0000000..a8b68e3 --- /dev/null +++ b/src/InterfaceForward.Domain/InterfaceAggregate/InterfaceEntity.cs @@ -0,0 +1,78 @@ +using System; +using Fake.DomainDrivenDesign.Entities.Auditing; +using InterfaceForward.Domain.UpStreamInterfaceAggregate; + +namespace InterfaceForward.Domain.InterfaceAggregate; + +public class InterfaceEntity : FullAuditedAggregate +{ + public int? ServiceProviderId { get; private set; } + + public string Name { get; private set; } + + public string Code { get; private set; } + + public string? Description { get; private set; } + + public string? RequestAddress { get; private set; } + + public int? RequestMethod { get; private set; } + + public RequestContentType? RequestContentType { get; private set; } + + public ResponseContentType? ResponseContentType { get; private set; } + + public string? FlowCode { get; private set; } + + public int? Timeout { get; private set; } + + /// + /// 接口单次请求数量上限 + /// + public int? Limit { get; private set; } + + /// + /// 接口qps限制 + /// + public int? Qps { get; private set; } + + /// + /// 入参根节点类型 + /// + public ParameterType InParamRootType { get; private set; } + + /// + /// 出参根节点类型 + /// + public ParameterType OutParamRootType { get; private set; } + + public InterfaceEntity(string name, string code, string? description, ParameterType inParamRootType, + ParameterType outParamRootType) + { + Name = name; + Code = code; + Description = description; + InParamRootType = inParamRootType; + OutParamRootType = outParamRootType; + } + + public InterfaceEntity(int serviceProviderId, string name, string code, string? description, string requestAddress, + int requestMethod, RequestContentType requestContentType, ResponseContentType responseContentType, + string? flowCode, int timeout, int limit, int qps, ParameterType inParamRootType, ParameterType outParamRootType) + { + ServiceProviderId = serviceProviderId; + Name = name; + Code = code; + Description = description; + RequestAddress = requestAddress; + RequestMethod = requestMethod; + RequestContentType = requestContentType; + ResponseContentType = responseContentType; + FlowCode = flowCode; + Timeout = timeout; + Limit = limit; + Qps = qps; + InParamRootType = inParamRootType; + OutParamRootType = outParamRootType; + } +} \ No newline at end of file diff --git a/src/InterfaceForward.Domain/InterfaceAggregate/InterfaceParamEntity.cs b/src/InterfaceForward.Domain/InterfaceAggregate/InterfaceParamEntity.cs new file mode 100644 index 0000000..105b007 --- /dev/null +++ b/src/InterfaceForward.Domain/InterfaceAggregate/InterfaceParamEntity.cs @@ -0,0 +1,74 @@ +using System; +using Fake.DomainDrivenDesign.Entities.Auditing; +using InterfaceForward.Domain.UpStreamInterfaceAggregate; + +namespace InterfaceForward.Domain.InterfaceAggregate; + +public class InterfaceParamEntity : FullAuditedEntity +{ + /// + /// 接口ID + /// + public Guid InterfaceId { get; private set; } + + /// + /// 父ID + /// + public Guid? PId { get; private set; } + + /// + /// 参数名 + /// + public string Name { get; private set; } + + /// + /// 参数路径 + /// + public string Path { get; private set; } + + /// + /// 参数名(中文) + /// + public string? CnName { get; private set; } + + /// + /// 参数类型 + /// + public ParameterType Type { get; private set; } + + /// + /// 是否必填 + /// + public bool IsRequired { get; private set; } + + /// + /// 是否入参 + /// + public bool IsInParam { get; private set; } + + /// + /// 参数描述 + /// + public string? Description { get; private set; } + + /// + /// 序列 + /// + public string Sort { get; private set; } + + + public InterfaceParamEntity(Guid interfaceId, Guid? pId, string name, string path, string? cnName, + ParameterType type, bool isRequired, bool isInParam, string? description, string sort) + { + InterfaceId = interfaceId; + PId = pId; + Name = name; + Path = path; + CnName = cnName; + Type = type; + IsRequired = isRequired; + IsInParam = isInParam; + Description = description; + Sort = sort; + } +} \ No newline at end of file diff --git a/src/InterfaceForward.Domain/InterfaceAggregate/ParameterType.cs b/src/InterfaceForward.Domain/InterfaceAggregate/ParameterType.cs new file mode 100644 index 0000000..c5b68e0 --- /dev/null +++ b/src/InterfaceForward.Domain/InterfaceAggregate/ParameterType.cs @@ -0,0 +1,12 @@ +namespace InterfaceForward.Domain.UpStreamInterfaceAggregate; + +public enum ParameterType +{ + String = 1, + Float = 2, + Object = 4, + Boolean = 8, + Array = 16, + Integer = 32, + Date = 64, +} \ No newline at end of file diff --git a/src/InterfaceForward.Domain/InterfaceAggregate/RequestContentType.cs b/src/InterfaceForward.Domain/InterfaceAggregate/RequestContentType.cs new file mode 100644 index 0000000..d3ef56e --- /dev/null +++ b/src/InterfaceForward.Domain/InterfaceAggregate/RequestContentType.cs @@ -0,0 +1,17 @@ +namespace InterfaceForward.Domain.InterfaceAggregate; + +public enum RequestContentType +{ + /// + /// "application/json" + /// + Json = 1, + /// + /// "application/xml" + /// + Xml = 2, + /// + /// application/x-www-form-urlencoded + /// + FormUrlEncoded = 4, +} \ No newline at end of file diff --git a/src/InterfaceForward.Domain/InterfaceAggregate/ResponseContentType.cs b/src/InterfaceForward.Domain/InterfaceAggregate/ResponseContentType.cs new file mode 100644 index 0000000..66bfdab --- /dev/null +++ b/src/InterfaceForward.Domain/InterfaceAggregate/ResponseContentType.cs @@ -0,0 +1,9 @@ +namespace InterfaceForward.Domain.InterfaceAggregate; + +public enum ResponseContentType +{ + Json = 1, + Xml = 2, + Pdf = 4, + Base64 = 8, +} \ No newline at end of file diff --git a/src/InterfaceForward.Domain/InterfaceAggregate/ServiceType.cs b/src/InterfaceForward.Domain/InterfaceAggregate/ServiceType.cs new file mode 100644 index 0000000..b333f18 --- /dev/null +++ b/src/InterfaceForward.Domain/InterfaceAggregate/ServiceType.cs @@ -0,0 +1,7 @@ +namespace InterfaceForward.Domain.InterfaceAggregate; + +public enum ServiceType +{ + ServiceProvider = 1, + Platform = 2 +} \ No newline at end of file diff --git a/src/InterfaceForward.Domain/InterfaceForward.Domain.csproj b/src/InterfaceForward.Domain/InterfaceForward.Domain.csproj index f551815..4cb4a29 100644 --- a/src/InterfaceForward.Domain/InterfaceForward.Domain.csproj +++ b/src/InterfaceForward.Domain/InterfaceForward.Domain.csproj @@ -7,7 +7,7 @@ - + diff --git a/src/InterfaceForward.Domain/InterfaceMapAggregate/InterfaceMapDetailsEntity.cs b/src/InterfaceForward.Domain/InterfaceMapAggregate/InterfaceMapDetailsEntity.cs new file mode 100644 index 0000000..63298df --- /dev/null +++ b/src/InterfaceForward.Domain/InterfaceMapAggregate/InterfaceMapDetailsEntity.cs @@ -0,0 +1,27 @@ +using System; +using Fake.DomainDrivenDesign.Entities.Auditing; + +namespace InterfaceForward.Domain.InterfaceMapAggregate; + +public class InterfaceMapDetailsEntity : FullAuditedEntity +{ + /// + /// 接口映射id + /// + public Guid InterfaceMapId { get; set; } + + /// + /// 参数id + /// + public Guid ParamId { get; set; } + + /// + /// 映射参数ID + /// + public Guid? MappedParamId { get; set; } + + /// + /// 是否入参映射 + /// + public bool IsInParam { get; set; } +} \ No newline at end of file diff --git a/src/InterfaceForward.Domain/InterfaceMapAggregate/InterfaceMapEntity.cs b/src/InterfaceForward.Domain/InterfaceMapAggregate/InterfaceMapEntity.cs new file mode 100644 index 0000000..12291e9 --- /dev/null +++ b/src/InterfaceForward.Domain/InterfaceMapAggregate/InterfaceMapEntity.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using Fake.DomainDrivenDesign.Entities; +using Fake.DomainDrivenDesign.Entities.Auditing; + +namespace InterfaceForward.Domain.InterfaceMapAggregate; + +/// +/// 上游接口映射服务商接口(1:1:N) +/// +public class InterfaceMapEntity : CreateAuditedEntity, IAggregateRoot, ISoftDelete +{ + public InterfaceMapEntity(string upStreamInterfaceCode, string serviceProviderCode, List serviceProviderInterfaceCodes) + { + if (serviceProviderInterfaceCodes.Count == 0) + { + throw new DomainException("至少需要一个映射服务商接口"); + } + + UpStreamInterfaceCode = upStreamInterfaceCode; + ServiceProviderCode = serviceProviderCode; + ServiceProviderInterfaceCodes = serviceProviderInterfaceCodes; + } + + /// + /// 上游接口代码 + /// + public string UpStreamInterfaceCode { get; private set; } + + /// + /// 映射服务商代码 + /// + public string ServiceProviderCode { get; private set; } + + /// + /// 映射服务商接口代码(多个) + /// + public List ServiceProviderInterfaceCodes { get; private set; } + + /// + /// 当前线上版本 + /// + public string? OnlineVersion { get; set; } + + /// + /// 前置脚本 + /// + public string? PrefixScript { get; set; } + + /// + /// 后置脚本 + /// + public string? PostfixScript { get; set; } + + public bool IsDeleted { get; } +} \ No newline at end of file diff --git a/src/InterfaceForward.Domain/ServiceProviderAggregate/ServiceProviderAggregate.cs b/src/InterfaceForward.Domain/ServiceProviderAggregate/ServiceProviderEntity.cs similarity index 88% rename from src/InterfaceForward.Domain/ServiceProviderAggregate/ServiceProviderAggregate.cs rename to src/InterfaceForward.Domain/ServiceProviderAggregate/ServiceProviderEntity.cs index c306397..236ec8e 100644 --- a/src/InterfaceForward.Domain/ServiceProviderAggregate/ServiceProviderAggregate.cs +++ b/src/InterfaceForward.Domain/ServiceProviderAggregate/ServiceProviderEntity.cs @@ -3,7 +3,7 @@ using Fake.DomainDrivenDesign.Entities.Auditing; namespace InterfaceForward.Domain.ServiceProviderAggregate; -public class ServiceProviderAggregate(string name, string code, string description, string? flowCode = null) +public class ServiceProviderEntity(string name, string code, string description, string? flowCode = null) : FullAuditedAggregate { /// diff --git a/src/InterfaceForward.Domain/ServiceProviderAggregate/ServiceProviderInterfaceEntity.cs b/src/InterfaceForward.Domain/ServiceProviderAggregate/ServiceProviderInterfaceEntity.cs index d71efb0..567aef7 100644 --- a/src/InterfaceForward.Domain/ServiceProviderAggregate/ServiceProviderInterfaceEntity.cs +++ b/src/InterfaceForward.Domain/ServiceProviderAggregate/ServiceProviderInterfaceEntity.cs @@ -1,46 +1,61 @@ using System; using Fake.DomainDrivenDesign.Entities.Auditing; +using InterfaceForward.Domain.InterfaceAggregate; using InterfaceForward.Domain.UpStreamInterfaceAggregate; namespace InterfaceForward.Domain.ServiceProviderAggregate; -public class ServiceProviderInterfaceEntity : FullAuditedEntity +public class ServiceProviderInterfaceEntity( + int serviceProviderId, + string name, + string code, + string description, + string requestAddress, + string requestMethod, + RequestContentType requestContentType, + ResponseContentType responseContentType, + string? flowCode, + int timeout = 20, + int limit = 1, + int qps = 0, + ParameterType mappedType = ParameterType.Object) + : FullAuditedEntity { - public int ServiceProviderId { get; private set; } + public int ServiceProviderId { get; private set; } = serviceProviderId; - public string Name { get; private set; } + public string Name { get; private set; } = name; + + public string Code { get; private set; } = code; - public string Code { get; private set; } - /// /// 描述 /// - public string Description { get; set; } + public string Description { get; set; } = description; - public string RequestAddress { get; private set; } + public string RequestAddress { get; private set; } = requestAddress; - public string RequestMethod { get; private set; } + public string RequestMethod { get; private set; } = requestMethod; - public RequestContentType RequestContentType { get; private set; } + public RequestContentType RequestContentType { get; private set; } = requestContentType; - public ResponseContentType ResponseContentType { get; private set; } + public ResponseContentType ResponseContentType { get; private set; } = responseContentType; - public string FlowCode { get; private set; } + public string? FlowCode { get; private set; } = flowCode; - public int Timeout { get; private set; } = 20; + public int Timeout { get; private set; } = timeout; /// /// 接口单次请求数量上限,默认是1,表示不支持批量处理 /// - public int Limit { get; private set; } = 1; + public int Limit { get; private set; } = limit; /// - /// 默认0,无限制 + /// 接口qps默认0,无限制 /// - public int Qps { get; private set; } + public int Qps { get; private set; } = qps; /// /// 映射后的数据类型 /// - public ParameterType MappedType { get; set; } = ParameterType.Object; + public ParameterType MappedType { get; set; } = mappedType; } \ No newline at end of file diff --git a/src/InterfaceForward.Domain/UpStreamInterfaceAggregate/InterfaceMapEntity.cs b/src/InterfaceForward.Domain/UpStreamInterfaceAggregate/InterfaceMapEntity.cs deleted file mode 100644 index 91804c9..0000000 --- a/src/InterfaceForward.Domain/UpStreamInterfaceAggregate/InterfaceMapEntity.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using Fake.DomainDrivenDesign.Entities.Auditing; - -namespace InterfaceForward.Domain.UpStreamInterfaceAggregate; - -/// -/// 上游接口映射服务商接口(1:N) -/// -public class InterfaceMapEntity: CreateAuditedEntity, ISoftDelete -{ - /// - /// 上游接口代码 - /// - public string UpStreamInterfaceCode { get; private set; } - - /// - /// 映射服务商代码 - /// - public string ServiceProviderCode { get; private set; } - - /// - /// 映射服务商接口代码 - /// - public string ServiceProviderInterfaceCode { get; private set; } - - /// - /// 当前线上版本 - /// - public string PublishedVersion { get; set; } - - /// - /// 前置脚本 - /// - public string PrefixScript { get; set; } - - /// - /// 后置脚本 - /// - public string PostfixScript { get; set; } - - public bool IsDeleted { get; } -} \ No newline at end of file diff --git a/src/InterfaceForward.Domain/UpStreamInterfaceAggregate/ParameterType.cs b/src/InterfaceForward.Domain/UpStreamInterfaceAggregate/ParameterType.cs deleted file mode 100644 index e37daab..0000000 --- a/src/InterfaceForward.Domain/UpStreamInterfaceAggregate/ParameterType.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace InterfaceForward.Domain.UpStreamInterfaceAggregate; - -public class ParameterType(int id, string name) : Enumeration(id, name) -{ - public static ParameterType String = new(1, "String"); - public static ParameterType Float = new(2, "Float"); - public static ParameterType Object = new(3, "Object"); - public static ParameterType Boolean = new(4, "Boolean"); - public static ParameterType Array = new(5, "Array"); - public static ParameterType Integer = new(6, "Integer"); - public static ParameterType Date = new(7, "Date"); -} \ No newline at end of file diff --git a/src/InterfaceForward.Domain/UpStreamInterfaceAggregate/RequestContentType.cs b/src/InterfaceForward.Domain/UpStreamInterfaceAggregate/RequestContentType.cs deleted file mode 100644 index c6d2b92..0000000 --- a/src/InterfaceForward.Domain/UpStreamInterfaceAggregate/RequestContentType.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace InterfaceForward.Domain.UpStreamInterfaceAggregate; - -public class RequestContentType(int id, string name) : Enumeration(id, name) -{ - public static RequestContentType Json = new(1, "application/json"); - public static RequestContentType Xml = new(2, "application/xml"); - public static RequestContentType FormUrlEncoded = new(3, "application/x-www-form-urlencoded"); -} \ No newline at end of file diff --git a/src/InterfaceForward.Domain/UpStreamInterfaceAggregate/ResponseContentType.cs b/src/InterfaceForward.Domain/UpStreamInterfaceAggregate/ResponseContentType.cs deleted file mode 100644 index c0a8aac..0000000 --- a/src/InterfaceForward.Domain/UpStreamInterfaceAggregate/ResponseContentType.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace InterfaceForward.Domain.UpStreamInterfaceAggregate; - -public class ResponseContentType(int id, string name) : Enumeration(id, name) -{ - -} \ No newline at end of file diff --git a/src/InterfaceForward.Domain/UpStreamInterfaceAggregate/ServiceType.cs b/src/InterfaceForward.Domain/UpStreamInterfaceAggregate/ServiceType.cs deleted file mode 100644 index ed7bf46..0000000 --- a/src/InterfaceForward.Domain/UpStreamInterfaceAggregate/ServiceType.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace InterfaceForward.Domain.UpStreamInterfaceAggregate; - -public class ServiceType(int id, string name) : Enumeration(id, name) -{ - public static ServiceType ServiceProvider = new(1, "服务商"); - public static ServiceType Platform = new(2, "平台"); -} \ No newline at end of file diff --git a/src/InterfaceForward.Domain/UpStreamInterfaceAggregate/UpStreamInterfaceAggregate.cs b/src/InterfaceForward.Domain/UpStreamInterfaceAggregate/UpStreamInterfaceAggregate.cs deleted file mode 100644 index 7a7124d..0000000 --- a/src/InterfaceForward.Domain/UpStreamInterfaceAggregate/UpStreamInterfaceAggregate.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using Fake.DomainDrivenDesign.Entities.Auditing; - -namespace InterfaceForward.Domain.UpStreamInterfaceAggregate; - -public class UpStreamInterfaceAggregate(string name, string code) : FullAuditedAggregate -{ - public string Name { get; private set; } = name; - - public string Code { get; private set; } = code; - - /// - /// 描述 - /// - public string? Description { get; set; } -} diff --git a/src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceMapDetailsEntityTypeConfiguration.cs b/src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceMapDetailsEntityTypeConfiguration.cs new file mode 100644 index 0000000..be4fdbc --- /dev/null +++ b/src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceMapDetailsEntityTypeConfiguration.cs @@ -0,0 +1,18 @@ +using InterfaceForward.Domain.InterfaceMapAggregate; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace InterfaceForward.Infrastructure.EntityConfigurations; + +public class InterfaceMapDetailsEntityTypeConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("interface_map_details", InterfaceForwardContext.DefaultSchema); + builder.HasKey(x => x.Id); + builder.Property(x => x.InterfaceMapId).IsRequired(); + builder.Property(x => x.ParamId).IsRequired(); + builder.Property(x => x.MappedParamId); + builder.Property(x => x.IsInParam).IsRequired(); + } +} \ No newline at end of file diff --git a/src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceMapEntityTypeConfiguration.cs b/src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceMapEntityTypeConfiguration.cs new file mode 100644 index 0000000..5fc4575 --- /dev/null +++ b/src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceMapEntityTypeConfiguration.cs @@ -0,0 +1,28 @@ +using System; +using System.Linq; +using InterfaceForward.Domain.InterfaceMapAggregate; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace InterfaceForward.Infrastructure.EntityConfigurations; + +public class InterfaceMapEntityTypeConfiguration: IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("interface_map", InterfaceForwardContext.DefaultSchema); + builder.HasKey(x => x.Id); + builder.Property(x => x.UpStreamInterfaceCode).HasMaxLength(50).IsRequired(); + builder.Property(x => x.ServiceProviderCode).HasMaxLength(50).IsRequired(); + builder.Property(x => x.ServiceProviderInterfaceCodes) + .IsRequired() + .HasConversion( + v => string.Join(',', v), + v => v.Split(',', StringSplitOptions.RemoveEmptyEntries).ToList() + ); + builder.Property(x => x.OnlineVersion).HasMaxLength(50); + builder.Property(x => x.PrefixScript); + builder.Property(x => x.PostfixScript); + builder.Property(x => x.IsDeleted).HasDefaultValue(false); + } +} \ No newline at end of file diff --git a/src/InterfaceForward.Infrastructure/InterfaceForwardContext.cs b/src/InterfaceForward.Infrastructure/InterfaceForwardContext.cs new file mode 100644 index 0000000..abf0601 --- /dev/null +++ b/src/InterfaceForward.Infrastructure/InterfaceForwardContext.cs @@ -0,0 +1,20 @@ +using Fake.EntityFrameworkCore; +using InterfaceForward.Domain.InterfaceAggregate; +using InterfaceForward.Domain.ServiceProviderAggregate; +using Microsoft.EntityFrameworkCore; + +namespace InterfaceForward.Infrastructure; + +public class InterfaceForwardContext : FakeDbContext +{ + public const string DefaultSchema = "forward"; + + public DbSet Interfaces { get; set; } + + public DbSet ServiceProviders { get; set; } + + public InterfaceForwardContext(DbContextOptions options) : base(options) + { + System.Diagnostics.Debug.WriteLine("InterfaceForwardContext::ctor ->" + base.GetHashCode()); + } +} \ No newline at end of file