From a686d5d3a37bfa1040e7db49a17145511a0d2388 Mon Sep 17 00:00:00 2001 From: xiaolipro <2357729423@qq.com> Date: Fri, 22 Mar 2024 14:08:52 +0800 Subject: [PATCH] 1 --- InterfaceForward.sln | 16 +++ .../Enums/AuthParameterFlag.cs | 13 ++ .../Enums/FieldOwner.cs | 8 ++ .../Enums/FieldPositionType.cs | 13 ++ .../Enums/InterfaceReturnConfigType.cs | 22 ++++ .../ForwardService/ForwardCoreContext.cs | 115 ++++++++++++++++++ .../ForwardService/IForwardFlow.cs | 29 +++++ .../InterfaceForward.Api.Contract.csproj | 13 ++ .../Models/FixedFieldWithValueDto.cs | 32 +++++ .../Models/ForwardCoreContextCache.cs | 95 +++++++++++++++ .../Models/InterfaceDto.cs | 82 +++++++++++++ .../Models/InterfaceFormFieldDto.cs | 19 +++ .../Models/InterfaceParameterMapDto.cs | 46 +++++++ .../Models/InterfaceReturnConfigDto.cs | 30 +++++ .../Models/ParameterNode.cs | 8 ++ .../Models/RequestLogDto.cs | 78 ++++++++++++ .../RequestServiceProviderFailedCommon.cs | 19 +++ ...ServiceProviderAccountFieldWithValueDto.cs | 14 +++ .../Models/ServiceProviderDto.cs | 39 ++++++ .../Controllers/InterfaceController.cs | 21 ++++ .../InterfaceForward.Api.csproj | 2 + .../InterfaceForwardApiModule.cs | 4 + .../DictionaryAggregate/DictionaryEntity.cs | 2 +- .../DictionaryItemEntity.cs | 2 +- .../IInterfaceRepository.cs | 6 + .../InterfaceAggregate/InterfaceEntity.cs | 46 +++++++ .../InterfaceParamEntity.cs | 4 +- .../ServiceProviderInterfaceEntity.cs | 4 +- .../InterfaceMapDetailsEntity.cs | 2 +- .../InterfaceMapEntity.cs | 2 +- .../ServiceProviderEntity.cs | 2 +- .../DTOs/Common/PagedResultDto.cs | 12 ++ .../DTOs/Common/UnifiedResult.cs | 12 ++ .../DTOs/Interfaces/InterfaceSummary.cs | 6 + .../Enums/InterfaceType.cs | 7 ++ .../ParameterType.cs | 2 +- .../RequestContentType.cs | 0 .../ResponseContentType.cs | 0 .../ServiceType.cs | 0 .../InterfaceAggregate/InterfaceEntity.cs | 78 ------------ .../InterfaceForward.Domain.csproj | 4 + .../InterfaceEntityTypeConfiguration.cs | 28 +++++ ...erfaceMapDetailsEntityTypeConfiguration.cs | 2 +- .../InterfaceMapEntityTypeConfiguration.cs | 2 +- .../InterfaceParamEntityTypeConfiguration.cs | 16 +++ .../InterfaceForwardContext.cs | 3 +- 46 files changed, 869 insertions(+), 91 deletions(-) create mode 100644 src/InterfaceForward.Api.Contract/Enums/AuthParameterFlag.cs create mode 100644 src/InterfaceForward.Api.Contract/Enums/FieldOwner.cs create mode 100644 src/InterfaceForward.Api.Contract/Enums/FieldPositionType.cs create mode 100644 src/InterfaceForward.Api.Contract/Enums/InterfaceReturnConfigType.cs create mode 100644 src/InterfaceForward.Api.Contract/ForwardService/ForwardCoreContext.cs create mode 100644 src/InterfaceForward.Api.Contract/ForwardService/IForwardFlow.cs create mode 100644 src/InterfaceForward.Api.Contract/InterfaceForward.Api.Contract.csproj create mode 100644 src/InterfaceForward.Api.Contract/Models/FixedFieldWithValueDto.cs create mode 100644 src/InterfaceForward.Api.Contract/Models/ForwardCoreContextCache.cs create mode 100644 src/InterfaceForward.Api.Contract/Models/InterfaceDto.cs create mode 100644 src/InterfaceForward.Api.Contract/Models/InterfaceFormFieldDto.cs create mode 100644 src/InterfaceForward.Api.Contract/Models/InterfaceParameterMapDto.cs create mode 100644 src/InterfaceForward.Api.Contract/Models/InterfaceReturnConfigDto.cs create mode 100644 src/InterfaceForward.Api.Contract/Models/ParameterNode.cs create mode 100644 src/InterfaceForward.Api.Contract/Models/RequestLogDto.cs create mode 100644 src/InterfaceForward.Api.Contract/Models/RequestServiceProviderFailedCommon.cs create mode 100644 src/InterfaceForward.Api.Contract/Models/ServiceProviderAccountFieldWithValueDto.cs create mode 100644 src/InterfaceForward.Api.Contract/Models/ServiceProviderDto.cs create mode 100644 src/InterfaceForward.Api/Controllers/InterfaceController.cs rename src/InterfaceForward.Domain/{ => Aggregates}/DictionaryAggregate/DictionaryEntity.cs (87%) rename src/InterfaceForward.Domain/{ => Aggregates}/DictionaryAggregate/DictionaryItemEntity.cs (90%) create mode 100644 src/InterfaceForward.Domain/Aggregates/InterfaceAggregate/IInterfaceRepository.cs create mode 100644 src/InterfaceForward.Domain/Aggregates/InterfaceAggregate/InterfaceEntity.cs rename src/InterfaceForward.Domain/{ => Aggregates}/InterfaceAggregate/InterfaceParamEntity.cs (93%) rename src/InterfaceForward.Domain/{ServiceProviderAggregate => Aggregates/InterfaceAggregate}/ServiceProviderInterfaceEntity.cs (93%) rename src/InterfaceForward.Domain/{ => Aggregates}/InterfaceMapAggregate/InterfaceMapDetailsEntity.cs (88%) rename src/InterfaceForward.Domain/{ => Aggregates}/InterfaceMapAggregate/InterfaceMapEntity.cs (95%) rename src/InterfaceForward.Domain/{ => Aggregates}/ServiceProviderAggregate/ServiceProviderEntity.cs (92%) create mode 100644 src/InterfaceForward.Domain/DTOs/Common/PagedResultDto.cs create mode 100644 src/InterfaceForward.Domain/DTOs/Common/UnifiedResult.cs create mode 100644 src/InterfaceForward.Domain/DTOs/Interfaces/InterfaceSummary.cs create mode 100644 src/InterfaceForward.Domain/Enums/InterfaceType.cs rename src/InterfaceForward.Domain/{InterfaceAggregate => Enums}/ParameterType.cs (68%) rename src/InterfaceForward.Domain/{InterfaceAggregate => Enums}/RequestContentType.cs (100%) rename src/InterfaceForward.Domain/{InterfaceAggregate => Enums}/ResponseContentType.cs (100%) rename src/InterfaceForward.Domain/{InterfaceAggregate => Enums}/ServiceType.cs (100%) delete mode 100644 src/InterfaceForward.Domain/InterfaceAggregate/InterfaceEntity.cs create mode 100644 src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceEntityTypeConfiguration.cs create mode 100644 src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceParamEntityTypeConfiguration.cs diff --git a/InterfaceForward.sln b/InterfaceForward.sln index d7add9a..5f904dd 100644 --- a/InterfaceForward.sln +++ b/InterfaceForward.sln @@ -19,6 +19,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InterfaceForward.Domain", " EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InterfaceForward.Infrastructure", "src\InterfaceForward.Infrastructure\InterfaceForward.Infrastructure.csproj", "{5FF71C79-8BD4-45AE-B999-8481F32BC2C0}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{E78C7664-0AED-43DB-8169-5414EBD945E7}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InterfaceForward.Domain.Tests", "tests\InterfaceForward.Domain.Tests\InterfaceForward.Domain.Tests.csproj", "{9B4C8DC1-748B-43EF-BC69-F75AF621CBB9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InterfaceForward.Api.Contract", "src\InterfaceForward.Api.Contract\InterfaceForward.Api.Contract.csproj", "{4FE95CF4-F22A-45D6-B7DA-5B9DAE39ECED}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -45,6 +51,14 @@ Global {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 + {9B4C8DC1-748B-43EF-BC69-F75AF621CBB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9B4C8DC1-748B-43EF-BC69-F75AF621CBB9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9B4C8DC1-748B-43EF-BC69-F75AF621CBB9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9B4C8DC1-748B-43EF-BC69-F75AF621CBB9}.Release|Any CPU.Build.0 = Release|Any CPU + {4FE95CF4-F22A-45D6-B7DA-5B9DAE39ECED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4FE95CF4-F22A-45D6-B7DA-5B9DAE39ECED}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4FE95CF4-F22A-45D6-B7DA-5B9DAE39ECED}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4FE95CF4-F22A-45D6-B7DA-5B9DAE39ECED}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {9609CC2D-CC83-4C01-BE36-C0429A06B238} = {EA8DF4A8-7618-4C28-BEDC-21629B8B219B} @@ -52,5 +66,7 @@ Global {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} + {9B4C8DC1-748B-43EF-BC69-F75AF621CBB9} = {E78C7664-0AED-43DB-8169-5414EBD945E7} + {4FE95CF4-F22A-45D6-B7DA-5B9DAE39ECED} = {EA8DF4A8-7618-4C28-BEDC-21629B8B219B} EndGlobalSection EndGlobal diff --git a/src/InterfaceForward.Api.Contract/Enums/AuthParameterFlag.cs b/src/InterfaceForward.Api.Contract/Enums/AuthParameterFlag.cs new file mode 100644 index 0000000..ea4b7e2 --- /dev/null +++ b/src/InterfaceForward.Api.Contract/Enums/AuthParameterFlag.cs @@ -0,0 +1,13 @@ +namespace InterfaceForward.Api.Contract.Enums; + +/// +/// 参数标识,1入参,2授权令牌,3有效时间,4固定有效时间,5脚本 +/// +public enum AuthParameterFlag +{ + InParameter = 1, + Token = 2, + EffectTime = 3, + FixedEffectTime = 4, + Script = 5 +} \ No newline at end of file diff --git a/src/InterfaceForward.Api.Contract/Enums/FieldOwner.cs b/src/InterfaceForward.Api.Contract/Enums/FieldOwner.cs new file mode 100644 index 0000000..fc14183 --- /dev/null +++ b/src/InterfaceForward.Api.Contract/Enums/FieldOwner.cs @@ -0,0 +1,8 @@ +namespace InterfaceForward.Api.Contract.Enums; + +public enum FieldOwner +{ + ServiceProvider, + Interface, + AuthConfig +} \ No newline at end of file diff --git a/src/InterfaceForward.Api.Contract/Enums/FieldPositionType.cs b/src/InterfaceForward.Api.Contract/Enums/FieldPositionType.cs new file mode 100644 index 0000000..fcb7e37 --- /dev/null +++ b/src/InterfaceForward.Api.Contract/Enums/FieldPositionType.cs @@ -0,0 +1,13 @@ +namespace InterfaceForward.Api.Contract.Enums; + +/// +/// 服务商字段位置 +/// +public enum FieldPositionType +{ + Header = 1, + Body = 2, + Query = 4, + Url = 8, + Nothing = 16 //不处理 +} \ No newline at end of file diff --git a/src/InterfaceForward.Api.Contract/Enums/InterfaceReturnConfigType.cs b/src/InterfaceForward.Api.Contract/Enums/InterfaceReturnConfigType.cs new file mode 100644 index 0000000..bba3471 --- /dev/null +++ b/src/InterfaceForward.Api.Contract/Enums/InterfaceReturnConfigType.cs @@ -0,0 +1,22 @@ +using System.ComponentModel; + +namespace InterfaceForward.Api.Contract.Enums; + +public enum InterfaceReturnConfigType +{ + /// + /// 状态码 + /// + [Description("状态码")] + StatusCode = 1, + /// + /// PDF标签上传 + /// + [Description("PDF标签上传")] + PdfLabel = 2, + /// + /// 错误信息返回 + /// + [Description("错误信息返回")] + ErrorMsg = 4, +} \ No newline at end of file diff --git a/src/InterfaceForward.Api.Contract/ForwardService/ForwardCoreContext.cs b/src/InterfaceForward.Api.Contract/ForwardService/ForwardCoreContext.cs new file mode 100644 index 0000000..3af5ee4 --- /dev/null +++ b/src/InterfaceForward.Api.Contract/ForwardService/ForwardCoreContext.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using InterfaceForward.Api.Contract.Enums; +using InterfaceForward.Api.Contract.Models; +using InterfaceForward.Domain.Enums; + +namespace InterfaceForward.Api.Contract.ForwardService; + +public class ForwardCoreContext +{ + /// + /// 目标服务商接口 + /// + public InterfaceDto TargetInterface { get; set; } = null!; + + /// + /// 服务商接口固定字段列表 + /// + public List FixedFieldList { get; set; } = null!; + + /// + /// 服务商账户字段列表 + /// + public List AccountFieldList { get; set; } = null!; + + /// + /// 服务商接口返回配置列表 + /// + public List ReturnConfigList { get; set; } = null!; + + /// + /// 表单字段列表 + /// + public List FormFieldList { get; set; } = null!; + + /// + /// 入参映射列表(树形结构) + /// + public List? InParamTreeList { get; set; } + + /// + /// 出参映射列表(树形结构) + /// + public List? OutParamTreeList { get; set; } + + /// + /// 请求前置脚本 + /// + public string? PrefixScript { get; set; } + + /// + /// 请求后置脚本 + /// + public string? PostfixScript { get; set; } + + #region 携带参数,计算量 + + /// + /// 业务系统传参json + /// + public JsonTokenType OriginalInterfaceInput { get; set; } + + /// + /// 业务系统传参映射后的json + /// + public JsonTokenType OriginalInterfaceMappedInput { get; set; } + + /// + /// 目标接口返回的json + /// + public JsonTokenType TargetInterfaceOutput { get; set; } + + /// + /// 请求服务商接口真实传参字符串 + /// + public string TargetInterfaceInput { get; set; } = null!; + + /// + /// 服务商日志 + /// + public RequestLogDto ServiceProviderRequestLog { get; set; } = null!; + #endregion + + public bool AddHeader(string key, string value) + { + if (FixedFieldList.Any(x => x.FieldName == key && x.FieldPosition == FieldPositionType.Header)) + { + return false; + } + FixedFieldList.Add(new FixedFieldWithValueDto + { + FieldName = key, + FieldValue = value, + FieldPosition = FieldPositionType.Header, + }); + + return true; + } + + public string? GetAccountFieldValueOrNull(string fieldName) + { + return AccountFieldList + .FirstOrDefault(x => x.FieldName.Equals(fieldName, StringComparison.OrdinalIgnoreCase)) + ?.FieldValue; + } + + public string? GetFixedFieldValueOrNull(string fieldName) + { + return FixedFieldList + .FirstOrDefault(x => x.FieldName.Equals(fieldName, StringComparison.OrdinalIgnoreCase)) + ?.FieldValue; + } +} \ No newline at end of file diff --git a/src/InterfaceForward.Api.Contract/ForwardService/IForwardFlow.cs b/src/InterfaceForward.Api.Contract/ForwardService/IForwardFlow.cs new file mode 100644 index 0000000..32f4e0a --- /dev/null +++ b/src/InterfaceForward.Api.Contract/ForwardService/IForwardFlow.cs @@ -0,0 +1,29 @@ +using System.Text.Json; +using System.Threading.Tasks; + +namespace InterfaceForward.Api.Contract.ForwardService; + +public interface IForwardFlow +{ + /// + /// 入参重构 + /// + /// + /// 返回入参json映射后的json + Task InParamRestructure(ForwardCoreContext context); + + /// + /// 转发核心 + /// + /// + /// 返回服务商响应结果序列化后的json + Task ForwardAsync(ForwardCoreContext context); + + /// + /// 出参重构 + /// + /// + /// 服务商返参(已经被处理成json) + /// 返回服务商json映射后的json + Task OutParamRestructure(ForwardCoreContext context, JsonTokenType jToken); +} \ No newline at end of file diff --git a/src/InterfaceForward.Api.Contract/InterfaceForward.Api.Contract.csproj b/src/InterfaceForward.Api.Contract/InterfaceForward.Api.Contract.csproj new file mode 100644 index 0000000..3dd9166 --- /dev/null +++ b/src/InterfaceForward.Api.Contract/InterfaceForward.Api.Contract.csproj @@ -0,0 +1,13 @@ + + + + + + netstandard2.1 + + + + + + + diff --git a/src/InterfaceForward.Api.Contract/Models/FixedFieldWithValueDto.cs b/src/InterfaceForward.Api.Contract/Models/FixedFieldWithValueDto.cs new file mode 100644 index 0000000..919a808 --- /dev/null +++ b/src/InterfaceForward.Api.Contract/Models/FixedFieldWithValueDto.cs @@ -0,0 +1,32 @@ +using InterfaceForward.Api.Contract.Enums; +using InterfaceForward.Domain.Enums; + +namespace InterfaceForward.Api.Contract.Models; + +public class FixedFieldWithValueDto +{ + /// + /// 字段所属 + /// + public FieldOwner FieldOwner { get; set; } + + /// + /// 字段名称 + /// + public string FieldName { get; set; } = null!; + + /// + /// 字段值 + /// + public string FieldValue { get; set; } = null!; + + /// + /// 字段位置 + /// + public FieldPositionType FieldPosition { get; set; } + + /// + /// 字段描述 + /// + public string? Description { get; set; } +} \ No newline at end of file diff --git a/src/InterfaceForward.Api.Contract/Models/ForwardCoreContextCache.cs b/src/InterfaceForward.Api.Contract/Models/ForwardCoreContextCache.cs new file mode 100644 index 0000000..9095880 --- /dev/null +++ b/src/InterfaceForward.Api.Contract/Models/ForwardCoreContextCache.cs @@ -0,0 +1,95 @@ +using System.Collections.Generic; +using InterfaceForward.Api.Contract.Enums; +using InterfaceForward.Domain.Enums; + +namespace InterfaceForward.Api.Contract.Models; + +public class ForwardCoreContextCache +{ + /// + /// 业务接口 + /// + public InterfaceDto OriginalInterface { get; set; } = null!; + + /// + /// 目标服务商 + /// + public ServiceProviderDto TargetServiceProvider { get; set; } = null!; + + /// + /// 目标服务商接口集合 + /// + public List TargetInterfaces { get; set; } = new(); + + /// + /// 出参映射列表(树形结构) + /// + public List OutParamTreeList { get; set; } = null!; + + /// + /// 目标服务商授权接口 + /// + public TargetInterfaceSummary ServiceProviderAuthInterface { get; set; } = null!; + + /// + /// 目标服务商授权配置 + /// + public List ServiceProviderAuthConfigs { get; set; } = null!; +} + +public class ServiceProviderAuthConfigDto +{ + /// + /// 参数标识,1入参,2授权令牌,3有效时间,4固定有效时间,5脚本 + /// + public AuthParameterFlag Flag { get; set; } + + /// + /// 参数路径 + /// + public string ParameterAlias { get; set; } = null!; + + public string? Value1 { get; set; } + + public string? Value2 { get; set; } + + public string? Value3 { get; set; } +} + +public class TargetInterfaceSummary +{ + /// + /// 目标服务商接口 + /// + public InterfaceDto TargetInterface { get; set; } = null!; + + /// + /// 请求前置脚本 + /// + public string? PrefixScript { get; set; } + + /// + /// 请求后置脚本 + /// + public string? PostfixScript { get; set; } + + /// + /// 入参映射列表(树形结构) + /// + public List InParamTreeList { get; set; } = null!; + + /// + /// 固定值列表 + /// + public List FixedFieldList { get; set; } = null!; + + /// + /// 返回配置列表 + /// + public List ReturnConfigList { get; set; } = null!; + + /// + /// 表单字段列表 + /// + public List FormFieldList { get; set; } = null!; +} \ No newline at end of file diff --git a/src/InterfaceForward.Api.Contract/Models/InterfaceDto.cs b/src/InterfaceForward.Api.Contract/Models/InterfaceDto.cs new file mode 100644 index 0000000..9ccf51e --- /dev/null +++ b/src/InterfaceForward.Api.Contract/Models/InterfaceDto.cs @@ -0,0 +1,82 @@ +using InterfaceForward.Domain.Enums; +using InterfaceForward.Domain.InterfaceAggregate; + +namespace InterfaceForward.Api.Contract.Models; + +public class InterfaceDto +{ + /// + /// 接口Id + /// + public int Id { get; set; } + + /// + /// 接口名 + /// + public string Name { get; set; } = null!; + + /// + /// 服务商id + /// + public int ServiceProviderId { get; set; } + + /// + /// 接口代码 + /// + public string Code { get; set; } = null!; + + /// + /// 请求地址 + /// + public string? RequestAddress { get; set; } + + /// + /// 请求方式 + /// + public string? RequestMethod { get; set; } + + /// + /// 内容类型 + /// + public RequestContentType ContentType { get; set; } + + /// + /// 返回内容类型 + /// + public ResponseContentType ResponseContentType { get; set; } + + /// + /// 是否支持批量处理 + /// + public bool IsBatch { get; set; } + + /// + /// 批量处理上限 + /// + public int Limit { get; set; } + + /// + /// qps + /// + public int Qps { get; set; } + + /// + /// 流程代码 + /// + public string? FlowCode { get; set; } + + /// + /// 是否禁用授权 + /// + public bool IsDisableAuth { get; set; } + + /// + /// 请求超时(s) + /// + public int? Timeout { get; set; } + + /// + /// 映射后参数类型(默认Object) + /// + public ParameterType MappedParamType { get; set; } +} \ No newline at end of file diff --git a/src/InterfaceForward.Api.Contract/Models/InterfaceFormFieldDto.cs b/src/InterfaceForward.Api.Contract/Models/InterfaceFormFieldDto.cs new file mode 100644 index 0000000..b386798 --- /dev/null +++ b/src/InterfaceForward.Api.Contract/Models/InterfaceFormFieldDto.cs @@ -0,0 +1,19 @@ +namespace InterfaceForward.Api.Contract.Models; + +public class InterfaceFormFieldDto +{ + /// + /// 参数名 + /// + public string Name { get; set; } = null!; + + /// + /// 参数值 + /// + public string Value { get; set; } = null!; + + /// + /// 参数描述 + /// + public string? Description { get; set; } +} \ No newline at end of file diff --git a/src/InterfaceForward.Api.Contract/Models/InterfaceParameterMapDto.cs b/src/InterfaceForward.Api.Contract/Models/InterfaceParameterMapDto.cs new file mode 100644 index 0000000..7386038 --- /dev/null +++ b/src/InterfaceForward.Api.Contract/Models/InterfaceParameterMapDto.cs @@ -0,0 +1,46 @@ +using InterfaceForward.Domain.Enums; + +namespace InterfaceForward.Api.Contract.Models; + +public class InterfaceParameterMapDto +{ + /// + /// 接口ID + /// + public int InterfaceId { get; set; } + + /// + /// 参数Id + /// + public int Id { get; set; } + + /// + /// 父级Id + /// + public int PId { get; set; } + + /// + /// 参数名 + /// + public string Name { get; set; } = null!; + + /// + /// 参数别名(要构建的) + /// + public string Alias { get; set; } = null!; + + /// + /// 映射参数别名(被重构的) + /// + public string MapAlias { get; set; } = null!; + + /// + /// 参数类型 + /// + public ParameterType Type { get; set; } + + /// + /// 必填的 + /// + public bool IsRequired { get; set; } +} \ No newline at end of file diff --git a/src/InterfaceForward.Api.Contract/Models/InterfaceReturnConfigDto.cs b/src/InterfaceForward.Api.Contract/Models/InterfaceReturnConfigDto.cs new file mode 100644 index 0000000..af9fde3 --- /dev/null +++ b/src/InterfaceForward.Api.Contract/Models/InterfaceReturnConfigDto.cs @@ -0,0 +1,30 @@ +using InterfaceForward.Api.Contract.Enums; +using InterfaceForward.Domain.Enums; + +namespace InterfaceForward.Api.Contract.Models; + +/// +/// +/// +public class InterfaceReturnConfigDto +{ + /// + /// 接口ID + /// + public int InterfaceId { get; set; } + + /// + /// 配置类型 + /// + public InterfaceReturnConfigType ConfigType { get; set; } + + /// + /// 路径 + /// + public string Path { get; set; } = null!; + + /// + /// 值 + /// + public string? Value { get; set; } +} \ No newline at end of file diff --git a/src/InterfaceForward.Api.Contract/Models/ParameterNode.cs b/src/InterfaceForward.Api.Contract/Models/ParameterNode.cs new file mode 100644 index 0000000..a56b94a --- /dev/null +++ b/src/InterfaceForward.Api.Contract/Models/ParameterNode.cs @@ -0,0 +1,8 @@ +using System.Collections.Generic; + +namespace InterfaceForward.Api.Contract.Models; + +public class ParameterNode : InterfaceParameterMapDto +{ + public List Children { get; set; } = null!; +} \ No newline at end of file diff --git a/src/InterfaceForward.Api.Contract/Models/RequestLogDto.cs b/src/InterfaceForward.Api.Contract/Models/RequestLogDto.cs new file mode 100644 index 0000000..18c1f81 --- /dev/null +++ b/src/InterfaceForward.Api.Contract/Models/RequestLogDto.cs @@ -0,0 +1,78 @@ +using System; + +namespace InterfaceForward.Api.Contract.Models; + +public class RequestLogDto(Guid requestId) +{ + public const string Init = "未能请求成功"; + + /// + /// 请求Id + /// + public Guid RequestId { get; set; } = requestId; + + /// + /// 请求时间(务必设置) + /// + public DateTime RequestTime { get; set; } + + /// + /// false:服务商 true:应用 + /// + public bool IsApp { get; set; } + + /// + /// 应用/服务商名称 + /// + public string? Name { get; set; } + + /// + /// 发起请求IP + /// + public string? ClientIP { get; set; } + + /// + /// 接口代码 + /// + public string? InterfaceCode { get; set; } + + /// + /// 请求接口名称 + /// + public string? InterfaceName { get; set; } + + /// + /// 请求地址 + /// + public string? Address { get; set; } + + /// + /// 请求头 + /// + public string? Headers { get; set; } + + /// + /// 请求体 + /// + public string? Content { get; set; } + + /// + /// 响应耗时ms + /// + public int Cost { get; set; } + + /// + /// 响应结果 + /// + public string? Response { get; set; } = Init; + + /// + /// 是否成功调用 + /// + public bool IsSuccess { get; set; } + + /// + /// 异常 + /// + public string? Exception { get; set; } +} \ No newline at end of file diff --git a/src/InterfaceForward.Api.Contract/Models/RequestServiceProviderFailedCommon.cs b/src/InterfaceForward.Api.Contract/Models/RequestServiceProviderFailedCommon.cs new file mode 100644 index 0000000..f87bd3a --- /dev/null +++ b/src/InterfaceForward.Api.Contract/Models/RequestServiceProviderFailedCommon.cs @@ -0,0 +1,19 @@ +namespace InterfaceForward.Api.Contract.Models; + +public static class RequestServiceProviderFailedCommon +{ + public const string RequestServiceProviderFailedSubscribeName = "SJZY.InterfaceRelay.RequestServiceProviderFailed"; + + public static string RequestFailedCode = "4001"; + + public static string DeSerializeFailedCode = "4002"; + + public static string VerifyStatusFailedCode = "4003"; + + public static string HeaderInsertFailed = "4004"; + + public static bool IsRequestServiceProviderFailed(string code) + { + return code == RequestFailedCode || code == DeSerializeFailedCode || code == VerifyStatusFailedCode || code == HeaderInsertFailed; + } +} \ No newline at end of file diff --git a/src/InterfaceForward.Api.Contract/Models/ServiceProviderAccountFieldWithValueDto.cs b/src/InterfaceForward.Api.Contract/Models/ServiceProviderAccountFieldWithValueDto.cs new file mode 100644 index 0000000..cffbe79 --- /dev/null +++ b/src/InterfaceForward.Api.Contract/Models/ServiceProviderAccountFieldWithValueDto.cs @@ -0,0 +1,14 @@ +namespace InterfaceForward.Api.Contract.Models; + +public class ServiceProviderAccountFieldWithValueDto +{ + /// + /// 字段名称 + /// + public string FieldName { get; set; } = null!; + + /// + /// 字段值 + /// + public string FieldValue { get; set; } = null!; +} \ No newline at end of file diff --git a/src/InterfaceForward.Api.Contract/Models/ServiceProviderDto.cs b/src/InterfaceForward.Api.Contract/Models/ServiceProviderDto.cs new file mode 100644 index 0000000..0ee39aa --- /dev/null +++ b/src/InterfaceForward.Api.Contract/Models/ServiceProviderDto.cs @@ -0,0 +1,39 @@ +namespace InterfaceForward.Api.Contract.Models; + +public class ServiceProviderDto +{ + /// + /// Id + /// + public int Id { get; set; } + + /// + /// 服务商名称 + /// + public string Name { get; set; } = null!; + + /// + /// 服务商代码 + /// + public string Code { get; set; } = null!; + + /// + /// 是否禁用授权 + /// + public bool IsDisableAuth { get; set; } + + /// + /// 流程代码 + /// + public string? FlowCode { get; set; } + + /// + /// 授权接口Code + /// + public string? AuthInterfaceCode { get; set; } + + /// + /// 请求超时(s) + /// + public int? Timeout { get; set; } +} \ No newline at end of file diff --git a/src/InterfaceForward.Api/Controllers/InterfaceController.cs b/src/InterfaceForward.Api/Controllers/InterfaceController.cs new file mode 100644 index 0000000..90b7372 --- /dev/null +++ b/src/InterfaceForward.Api/Controllers/InterfaceController.cs @@ -0,0 +1,21 @@ +using Fake.Users; +using InterfaceForward.Domain.DTOs.Common; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace InterfaceForward.Api.Controllers; + +[Route("Interface")] +public class InterfaceController: ControllerBase +{ + /// + /// 系统接口分页列表 + /// + /// + /// + [HttpPost("/SystemInterfacePaginatedList")] + public async Task> SystemInterfacePaginatedListAsync(SystemInterfacePaginatedInputObjectValue input) + { + return await _interfaceRepository.GetSystemInterfacePaginatedListAsync(input); + } +} \ No newline at end of file diff --git a/src/InterfaceForward.Api/InterfaceForward.Api.csproj b/src/InterfaceForward.Api/InterfaceForward.Api.csproj index 40443ed..a251e8e 100644 --- a/src/InterfaceForward.Api/InterfaceForward.Api.csproj +++ b/src/InterfaceForward.Api/InterfaceForward.Api.csproj @@ -14,7 +14,9 @@ + + diff --git a/src/InterfaceForward.Api/InterfaceForwardApiModule.cs b/src/InterfaceForward.Api/InterfaceForwardApiModule.cs index a75bd46..96c79aa 100644 --- a/src/InterfaceForward.Api/InterfaceForwardApiModule.cs +++ b/src/InterfaceForward.Api/InterfaceForwardApiModule.cs @@ -1,9 +1,13 @@ using Fake.AspNetCore; using Fake.Modularity; +using InterfaceForward.Api.Contract; +using InterfaceForward.Domain; namespace InterfaceForward.Api; [DependsOn(typeof(FakeAspNetCoreModule))] +[DependsOn(typeof(InterfaceForwardDomainModule))] +[DependsOn(typeof(InterfaceForwardApiContractModule))] public class InterfaceForwardApiModule : FakeModule { public override void ConfigureServices(ServiceConfigurationContext context) diff --git a/src/InterfaceForward.Domain/DictionaryAggregate/DictionaryEntity.cs b/src/InterfaceForward.Domain/Aggregates/DictionaryAggregate/DictionaryEntity.cs similarity index 87% rename from src/InterfaceForward.Domain/DictionaryAggregate/DictionaryEntity.cs rename to src/InterfaceForward.Domain/Aggregates/DictionaryAggregate/DictionaryEntity.cs index 8efed1e..357655b 100644 --- a/src/InterfaceForward.Domain/DictionaryAggregate/DictionaryEntity.cs +++ b/src/InterfaceForward.Domain/Aggregates/DictionaryAggregate/DictionaryEntity.cs @@ -1,7 +1,7 @@ using System; using Fake.DomainDrivenDesign.Entities.Auditing; -namespace InterfaceForward.Domain.DictionaryAggregate; +namespace InterfaceForward.Domain.Aggregates.DictionaryAggregate; public class DictionaryEntity:FullAuditedAggregate { diff --git a/src/InterfaceForward.Domain/DictionaryAggregate/DictionaryItemEntity.cs b/src/InterfaceForward.Domain/Aggregates/DictionaryAggregate/DictionaryItemEntity.cs similarity index 90% rename from src/InterfaceForward.Domain/DictionaryAggregate/DictionaryItemEntity.cs rename to src/InterfaceForward.Domain/Aggregates/DictionaryAggregate/DictionaryItemEntity.cs index 6663a64..968a595 100644 --- a/src/InterfaceForward.Domain/DictionaryAggregate/DictionaryItemEntity.cs +++ b/src/InterfaceForward.Domain/Aggregates/DictionaryAggregate/DictionaryItemEntity.cs @@ -1,7 +1,7 @@ using System; using Fake.DomainDrivenDesign.Entities.Auditing; -namespace InterfaceForward.Domain.DictionaryAggregate; +namespace InterfaceForward.Domain.Aggregates.DictionaryAggregate; public class DictionaryItemEntity : FullAuditedEntity { diff --git a/src/InterfaceForward.Domain/Aggregates/InterfaceAggregate/IInterfaceRepository.cs b/src/InterfaceForward.Domain/Aggregates/InterfaceAggregate/IInterfaceRepository.cs new file mode 100644 index 0000000..2472a0a --- /dev/null +++ b/src/InterfaceForward.Domain/Aggregates/InterfaceAggregate/IInterfaceRepository.cs @@ -0,0 +1,6 @@ +namespace InterfaceForward.Domain.Aggregates.InterfaceAggregate; + +public interface IInterfaceRepository +{ + +} \ No newline at end of file diff --git a/src/InterfaceForward.Domain/Aggregates/InterfaceAggregate/InterfaceEntity.cs b/src/InterfaceForward.Domain/Aggregates/InterfaceAggregate/InterfaceEntity.cs new file mode 100644 index 0000000..4f873ed --- /dev/null +++ b/src/InterfaceForward.Domain/Aggregates/InterfaceAggregate/InterfaceEntity.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Collections.ObjectModel; +using System.Linq; +using Fake.DomainDrivenDesign.Entities.Auditing; +using InterfaceForward.Domain.Enums; + +namespace InterfaceForward.Domain.Aggregates.InterfaceAggregate; + +public class InterfaceEntity( + InterfaceType interfaceType, + string name, + string code, + string? description, + ParameterType inParamRootType, + ParameterType outParamRootType) + : FullAuditedAggregate +{ + public InterfaceType InterfaceType { get; private set; } = interfaceType; + + public string Code { get; private set; } = code; + + public string Name { get; private set; } = name; + + public string? Description { get; private set; } = description; + + /// + /// 入参根节点类型 + /// + public ParameterType InParamRootType { get; private set; } = inParamRootType; + + /// + /// 出参根节点类型 + /// + public ParameterType OutParamRootType { get; private set; } = outParamRootType; + + private readonly List _params = []; + public IReadOnlyCollection InParams => _params.Where(x => x.IsInParam).ToImmutableList(); + public IReadOnlyCollection OutParams => _params.Where(x => !x.IsInParam).ToImmutableList(); + + public void AddInParams(IEnumerable inParams) + { + _params.AddRange(inParams); + } +} \ No newline at end of file diff --git a/src/InterfaceForward.Domain/InterfaceAggregate/InterfaceParamEntity.cs b/src/InterfaceForward.Domain/Aggregates/InterfaceAggregate/InterfaceParamEntity.cs similarity index 93% rename from src/InterfaceForward.Domain/InterfaceAggregate/InterfaceParamEntity.cs rename to src/InterfaceForward.Domain/Aggregates/InterfaceAggregate/InterfaceParamEntity.cs index 105b007..ae2af59 100644 --- a/src/InterfaceForward.Domain/InterfaceAggregate/InterfaceParamEntity.cs +++ b/src/InterfaceForward.Domain/Aggregates/InterfaceAggregate/InterfaceParamEntity.cs @@ -1,8 +1,8 @@ using System; using Fake.DomainDrivenDesign.Entities.Auditing; -using InterfaceForward.Domain.UpStreamInterfaceAggregate; +using InterfaceForward.Domain.Enums; -namespace InterfaceForward.Domain.InterfaceAggregate; +namespace InterfaceForward.Domain.Aggregates.InterfaceAggregate; public class InterfaceParamEntity : FullAuditedEntity { diff --git a/src/InterfaceForward.Domain/ServiceProviderAggregate/ServiceProviderInterfaceEntity.cs b/src/InterfaceForward.Domain/Aggregates/InterfaceAggregate/ServiceProviderInterfaceEntity.cs similarity index 93% rename from src/InterfaceForward.Domain/ServiceProviderAggregate/ServiceProviderInterfaceEntity.cs rename to src/InterfaceForward.Domain/Aggregates/InterfaceAggregate/ServiceProviderInterfaceEntity.cs index 567aef7..b9db71c 100644 --- a/src/InterfaceForward.Domain/ServiceProviderAggregate/ServiceProviderInterfaceEntity.cs +++ b/src/InterfaceForward.Domain/Aggregates/InterfaceAggregate/ServiceProviderInterfaceEntity.cs @@ -1,9 +1,9 @@ using System; using Fake.DomainDrivenDesign.Entities.Auditing; +using InterfaceForward.Domain.Enums; using InterfaceForward.Domain.InterfaceAggregate; -using InterfaceForward.Domain.UpStreamInterfaceAggregate; -namespace InterfaceForward.Domain.ServiceProviderAggregate; +namespace InterfaceForward.Domain.Aggregates.InterfaceAggregate; public class ServiceProviderInterfaceEntity( int serviceProviderId, diff --git a/src/InterfaceForward.Domain/InterfaceMapAggregate/InterfaceMapDetailsEntity.cs b/src/InterfaceForward.Domain/Aggregates/InterfaceMapAggregate/InterfaceMapDetailsEntity.cs similarity index 88% rename from src/InterfaceForward.Domain/InterfaceMapAggregate/InterfaceMapDetailsEntity.cs rename to src/InterfaceForward.Domain/Aggregates/InterfaceMapAggregate/InterfaceMapDetailsEntity.cs index 63298df..0f76cab 100644 --- a/src/InterfaceForward.Domain/InterfaceMapAggregate/InterfaceMapDetailsEntity.cs +++ b/src/InterfaceForward.Domain/Aggregates/InterfaceMapAggregate/InterfaceMapDetailsEntity.cs @@ -1,7 +1,7 @@ using System; using Fake.DomainDrivenDesign.Entities.Auditing; -namespace InterfaceForward.Domain.InterfaceMapAggregate; +namespace InterfaceForward.Domain.Aggregates.InterfaceMapAggregate; public class InterfaceMapDetailsEntity : FullAuditedEntity { diff --git a/src/InterfaceForward.Domain/InterfaceMapAggregate/InterfaceMapEntity.cs b/src/InterfaceForward.Domain/Aggregates/InterfaceMapAggregate/InterfaceMapEntity.cs similarity index 95% rename from src/InterfaceForward.Domain/InterfaceMapAggregate/InterfaceMapEntity.cs rename to src/InterfaceForward.Domain/Aggregates/InterfaceMapAggregate/InterfaceMapEntity.cs index 12291e9..eec7e45 100644 --- a/src/InterfaceForward.Domain/InterfaceMapAggregate/InterfaceMapEntity.cs +++ b/src/InterfaceForward.Domain/Aggregates/InterfaceMapAggregate/InterfaceMapEntity.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using Fake.DomainDrivenDesign.Entities; using Fake.DomainDrivenDesign.Entities.Auditing; -namespace InterfaceForward.Domain.InterfaceMapAggregate; +namespace InterfaceForward.Domain.Aggregates.InterfaceMapAggregate; /// /// 上游接口映射服务商接口(1:1:N) diff --git a/src/InterfaceForward.Domain/ServiceProviderAggregate/ServiceProviderEntity.cs b/src/InterfaceForward.Domain/Aggregates/ServiceProviderAggregate/ServiceProviderEntity.cs similarity index 92% rename from src/InterfaceForward.Domain/ServiceProviderAggregate/ServiceProviderEntity.cs rename to src/InterfaceForward.Domain/Aggregates/ServiceProviderAggregate/ServiceProviderEntity.cs index 236ec8e..31e4110 100644 --- a/src/InterfaceForward.Domain/ServiceProviderAggregate/ServiceProviderEntity.cs +++ b/src/InterfaceForward.Domain/Aggregates/ServiceProviderAggregate/ServiceProviderEntity.cs @@ -1,7 +1,7 @@ using System; using Fake.DomainDrivenDesign.Entities.Auditing; -namespace InterfaceForward.Domain.ServiceProviderAggregate; +namespace InterfaceForward.Domain.Aggregates.ServiceProviderAggregate; public class ServiceProviderEntity(string name, string code, string description, string? flowCode = null) : FullAuditedAggregate diff --git a/src/InterfaceForward.Domain/DTOs/Common/PagedResultDto.cs b/src/InterfaceForward.Domain/DTOs/Common/PagedResultDto.cs new file mode 100644 index 0000000..0c75ccc --- /dev/null +++ b/src/InterfaceForward.Domain/DTOs/Common/PagedResultDto.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace InterfaceForward.Domain.DTOs.Common; + +public class PagedResultDto(List items, int pageIndex, int pageSize, int total) +{ + public int PageIndex { get; } = pageIndex; + public int PageSize { get; } = pageSize; + public int Total { get; } = total; + + public List Items { get; } = items; +} \ No newline at end of file diff --git a/src/InterfaceForward.Domain/DTOs/Common/UnifiedResult.cs b/src/InterfaceForward.Domain/DTOs/Common/UnifiedResult.cs new file mode 100644 index 0000000..d7f7bb0 --- /dev/null +++ b/src/InterfaceForward.Domain/DTOs/Common/UnifiedResult.cs @@ -0,0 +1,12 @@ +using System.Net; + +namespace InterfaceForward.Domain.DTOs.Common; + +public class UnifiedResult(HttpStatusCode code = HttpStatusCode.OK, string message = "成功", T? data = default) +{ + public HttpStatusCode Code { get; set; } = code; + + public string Message { get; set; } = message; + + public T? Data { get; set; } = data; +} \ No newline at end of file diff --git a/src/InterfaceForward.Domain/DTOs/Interfaces/InterfaceSummary.cs b/src/InterfaceForward.Domain/DTOs/Interfaces/InterfaceSummary.cs new file mode 100644 index 0000000..a882b74 --- /dev/null +++ b/src/InterfaceForward.Domain/DTOs/Interfaces/InterfaceSummary.cs @@ -0,0 +1,6 @@ +namespace InterfaceForward.Domain.DTOs.Interfaces; + +public class InterfaceSummary +{ + +} \ No newline at end of file diff --git a/src/InterfaceForward.Domain/Enums/InterfaceType.cs b/src/InterfaceForward.Domain/Enums/InterfaceType.cs new file mode 100644 index 0000000..6d093d5 --- /dev/null +++ b/src/InterfaceForward.Domain/Enums/InterfaceType.cs @@ -0,0 +1,7 @@ +namespace InterfaceForward.Domain.Enums; + +public enum InterfaceType +{ + ServiceProvider = 1, + Platform = 2 +} \ No newline at end of file diff --git a/src/InterfaceForward.Domain/InterfaceAggregate/ParameterType.cs b/src/InterfaceForward.Domain/Enums/ParameterType.cs similarity index 68% rename from src/InterfaceForward.Domain/InterfaceAggregate/ParameterType.cs rename to src/InterfaceForward.Domain/Enums/ParameterType.cs index c5b68e0..ba4dcf1 100644 --- a/src/InterfaceForward.Domain/InterfaceAggregate/ParameterType.cs +++ b/src/InterfaceForward.Domain/Enums/ParameterType.cs @@ -1,4 +1,4 @@ -namespace InterfaceForward.Domain.UpStreamInterfaceAggregate; +namespace InterfaceForward.Domain.Enums; public enum ParameterType { diff --git a/src/InterfaceForward.Domain/InterfaceAggregate/RequestContentType.cs b/src/InterfaceForward.Domain/Enums/RequestContentType.cs similarity index 100% rename from src/InterfaceForward.Domain/InterfaceAggregate/RequestContentType.cs rename to src/InterfaceForward.Domain/Enums/RequestContentType.cs diff --git a/src/InterfaceForward.Domain/InterfaceAggregate/ResponseContentType.cs b/src/InterfaceForward.Domain/Enums/ResponseContentType.cs similarity index 100% rename from src/InterfaceForward.Domain/InterfaceAggregate/ResponseContentType.cs rename to src/InterfaceForward.Domain/Enums/ResponseContentType.cs diff --git a/src/InterfaceForward.Domain/InterfaceAggregate/ServiceType.cs b/src/InterfaceForward.Domain/Enums/ServiceType.cs similarity index 100% rename from src/InterfaceForward.Domain/InterfaceAggregate/ServiceType.cs rename to src/InterfaceForward.Domain/Enums/ServiceType.cs diff --git a/src/InterfaceForward.Domain/InterfaceAggregate/InterfaceEntity.cs b/src/InterfaceForward.Domain/InterfaceAggregate/InterfaceEntity.cs deleted file mode 100644 index a8b68e3..0000000 --- a/src/InterfaceForward.Domain/InterfaceAggregate/InterfaceEntity.cs +++ /dev/null @@ -1,78 +0,0 @@ -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/InterfaceForward.Domain.csproj b/src/InterfaceForward.Domain/InterfaceForward.Domain.csproj index 4cb4a29..ed1f667 100644 --- a/src/InterfaceForward.Domain/InterfaceForward.Domain.csproj +++ b/src/InterfaceForward.Domain/InterfaceForward.Domain.csproj @@ -10,4 +10,8 @@ + + + + diff --git a/src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceEntityTypeConfiguration.cs b/src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceEntityTypeConfiguration.cs new file mode 100644 index 0000000..6e6ed74 --- /dev/null +++ b/src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceEntityTypeConfiguration.cs @@ -0,0 +1,28 @@ +using System.Linq; +using InterfaceForward.Domain.Aggregates.InterfaceAggregate; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace InterfaceForward.Infrastructure.EntityConfigurations; + +public class InterfaceEntityTypeConfiguration: IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("t_interface", InterfaceForwardContext.DefaultSchema); + + builder.HasKey(x => x.Id); + builder.Property(x => x.InterfaceType).IsRequired(); + builder.Property(x => x.Code).HasMaxLength(50).IsRequired(); + builder.Property(x => x.Name).HasMaxLength(100).IsRequired(); + builder.Property(x => x.Description).HasMaxLength(500); + + builder.HasMany(typeof(InterfaceParamEntity), "_params") + .WithOne() + .HasForeignKey(nameof(InterfaceParamEntity.InterfaceId)) + .IsRequired(); + + builder.Ignore(s => s.InParams); + builder.Ignore(s => s.OutParams); + } +} \ No newline at end of file diff --git a/src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceMapDetailsEntityTypeConfiguration.cs b/src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceMapDetailsEntityTypeConfiguration.cs index be4fdbc..c855f33 100644 --- a/src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceMapDetailsEntityTypeConfiguration.cs +++ b/src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceMapDetailsEntityTypeConfiguration.cs @@ -1,4 +1,4 @@ -using InterfaceForward.Domain.InterfaceMapAggregate; +using InterfaceForward.Domain.Aggregates.InterfaceMapAggregate; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceMapEntityTypeConfiguration.cs b/src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceMapEntityTypeConfiguration.cs index 5fc4575..16d83d3 100644 --- a/src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceMapEntityTypeConfiguration.cs +++ b/src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceMapEntityTypeConfiguration.cs @@ -1,6 +1,6 @@ using System; using System.Linq; -using InterfaceForward.Domain.InterfaceMapAggregate; +using InterfaceForward.Domain.Aggregates.InterfaceMapAggregate; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceParamEntityTypeConfiguration.cs b/src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceParamEntityTypeConfiguration.cs new file mode 100644 index 0000000..f99d3a7 --- /dev/null +++ b/src/InterfaceForward.Infrastructure/EntityConfigurations/InterfaceParamEntityTypeConfiguration.cs @@ -0,0 +1,16 @@ +using InterfaceForward.Domain.Aggregates.InterfaceAggregate; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace InterfaceForward.Infrastructure.EntityConfigurations; + +public class InterfaceParamEntityTypeConfiguration: IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("t_interface_params", InterfaceForwardContext.DefaultSchema); + + builder.HasKey(x => x.Id); + + } +} \ No newline at end of file diff --git a/src/InterfaceForward.Infrastructure/InterfaceForwardContext.cs b/src/InterfaceForward.Infrastructure/InterfaceForwardContext.cs index 8be63c1..eab50dd 100644 --- a/src/InterfaceForward.Infrastructure/InterfaceForwardContext.cs +++ b/src/InterfaceForward.Infrastructure/InterfaceForwardContext.cs @@ -1,6 +1,7 @@ using Fake.EntityFrameworkCore; +using InterfaceForward.Domain.Aggregates.InterfaceAggregate; +using InterfaceForward.Domain.Aggregates.ServiceProviderAggregate; using InterfaceForward.Domain.InterfaceAggregate; -using InterfaceForward.Domain.ServiceProviderAggregate; using Microsoft.EntityFrameworkCore; namespace InterfaceForward.Infrastructure;