1
This commit is contained in:
parent
f079a34c36
commit
a686d5d3a3
@ -19,6 +19,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InterfaceForward.Domain", "
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InterfaceForward.Infrastructure", "src\InterfaceForward.Infrastructure\InterfaceForward.Infrastructure.csproj", "{5FF71C79-8BD4-45AE-B999-8481F32BC2C0}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InterfaceForward.Infrastructure", "src\InterfaceForward.Infrastructure\InterfaceForward.Infrastructure.csproj", "{5FF71C79-8BD4-45AE-B999-8481F32BC2C0}"
|
||||||
EndProject
|
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
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
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}.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.ActiveCfg = Release|Any CPU
|
||||||
{5FF71C79-8BD4-45AE-B999-8481F32BC2C0}.Release|Any CPU.Build.0 = 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
|
EndGlobalSection
|
||||||
GlobalSection(NestedProjects) = preSolution
|
GlobalSection(NestedProjects) = preSolution
|
||||||
{9609CC2D-CC83-4C01-BE36-C0429A06B238} = {EA8DF4A8-7618-4C28-BEDC-21629B8B219B}
|
{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}
|
{0E2F3A09-4EC4-4A61-85DC-9F9F770C3B65} = {EA8DF4A8-7618-4C28-BEDC-21629B8B219B}
|
||||||
{AB53F0CC-DE7A-4AE9-B6AA-2A8283B4EB23} = {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}
|
{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
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
13
src/InterfaceForward.Api.Contract/Enums/AuthParameterFlag.cs
Normal file
13
src/InterfaceForward.Api.Contract/Enums/AuthParameterFlag.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
namespace InterfaceForward.Api.Contract.Enums;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 参数标识,1入参,2授权令牌,3有效时间,4固定有效时间,5脚本
|
||||||
|
/// </summary>
|
||||||
|
public enum AuthParameterFlag
|
||||||
|
{
|
||||||
|
InParameter = 1,
|
||||||
|
Token = 2,
|
||||||
|
EffectTime = 3,
|
||||||
|
FixedEffectTime = 4,
|
||||||
|
Script = 5
|
||||||
|
}
|
||||||
8
src/InterfaceForward.Api.Contract/Enums/FieldOwner.cs
Normal file
8
src/InterfaceForward.Api.Contract/Enums/FieldOwner.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
namespace InterfaceForward.Api.Contract.Enums;
|
||||||
|
|
||||||
|
public enum FieldOwner
|
||||||
|
{
|
||||||
|
ServiceProvider,
|
||||||
|
Interface,
|
||||||
|
AuthConfig
|
||||||
|
}
|
||||||
13
src/InterfaceForward.Api.Contract/Enums/FieldPositionType.cs
Normal file
13
src/InterfaceForward.Api.Contract/Enums/FieldPositionType.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
namespace InterfaceForward.Api.Contract.Enums;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 服务商字段位置
|
||||||
|
/// </summary>
|
||||||
|
public enum FieldPositionType
|
||||||
|
{
|
||||||
|
Header = 1,
|
||||||
|
Body = 2,
|
||||||
|
Query = 4,
|
||||||
|
Url = 8,
|
||||||
|
Nothing = 16 //不处理
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace InterfaceForward.Api.Contract.Enums;
|
||||||
|
|
||||||
|
public enum InterfaceReturnConfigType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 状态码
|
||||||
|
/// </summary>
|
||||||
|
[Description("状态码")]
|
||||||
|
StatusCode = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// PDF标签上传
|
||||||
|
/// </summary>
|
||||||
|
[Description("PDF标签上传")]
|
||||||
|
PdfLabel = 2,
|
||||||
|
/// <summary>
|
||||||
|
/// 错误信息返回
|
||||||
|
/// </summary>
|
||||||
|
[Description("错误信息返回")]
|
||||||
|
ErrorMsg = 4,
|
||||||
|
}
|
||||||
@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 目标服务商接口
|
||||||
|
/// </summary>
|
||||||
|
public InterfaceDto TargetInterface { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 服务商接口固定字段列表
|
||||||
|
/// </summary>
|
||||||
|
public List<FixedFieldWithValueDto> FixedFieldList { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 服务商账户字段列表
|
||||||
|
/// </summary>
|
||||||
|
public List<ServiceProviderAccountFieldWithValueDto> AccountFieldList { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 服务商接口返回配置列表
|
||||||
|
/// </summary>
|
||||||
|
public List<InterfaceReturnConfigDto> ReturnConfigList { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 表单字段列表
|
||||||
|
/// </summary>
|
||||||
|
public List<InterfaceFormFieldDto> FormFieldList { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 入参映射列表(树形结构)
|
||||||
|
/// </summary>
|
||||||
|
public List<ParameterNode>? InParamTreeList { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 出参映射列表(树形结构)
|
||||||
|
/// </summary>
|
||||||
|
public List<ParameterNode>? OutParamTreeList { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 请求前置脚本
|
||||||
|
/// </summary>
|
||||||
|
public string? PrefixScript { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 请求后置脚本
|
||||||
|
/// </summary>
|
||||||
|
public string? PostfixScript { get; set; }
|
||||||
|
|
||||||
|
#region 携带参数,计算量
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 业务系统传参json
|
||||||
|
/// </summary>
|
||||||
|
public JsonTokenType OriginalInterfaceInput { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 业务系统传参映射后的json
|
||||||
|
/// </summary>
|
||||||
|
public JsonTokenType OriginalInterfaceMappedInput { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 目标接口返回的json
|
||||||
|
/// </summary>
|
||||||
|
public JsonTokenType TargetInterfaceOutput { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 请求服务商接口真实传参字符串
|
||||||
|
/// </summary>
|
||||||
|
public string TargetInterfaceInput { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 服务商日志
|
||||||
|
/// </summary>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace InterfaceForward.Api.Contract.ForwardService;
|
||||||
|
|
||||||
|
public interface IForwardFlow
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 入参重构
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context"></param>
|
||||||
|
/// <returns>返回入参json映射后的json</returns>
|
||||||
|
Task<JsonTokenType> InParamRestructure(ForwardCoreContext context);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 转发核心
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context"></param>
|
||||||
|
/// <returns>返回服务商响应结果序列化后的json</returns>
|
||||||
|
Task<JsonTokenType> ForwardAsync(ForwardCoreContext context);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 出参重构
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context"></param>
|
||||||
|
/// <param name="jToken">服务商返参(已经被处理成json)</param>
|
||||||
|
/// <returns>返回服务商json映射后的json</returns>
|
||||||
|
Task<JsonTokenType> OutParamRestructure(ForwardCoreContext context, JsonTokenType jToken);
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<Import Project="../../common.props" />
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netstandard2.1</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\InterfaceForward.Domain\InterfaceForward.Domain.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
using InterfaceForward.Api.Contract.Enums;
|
||||||
|
using InterfaceForward.Domain.Enums;
|
||||||
|
|
||||||
|
namespace InterfaceForward.Api.Contract.Models;
|
||||||
|
|
||||||
|
public class FixedFieldWithValueDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 字段所属
|
||||||
|
/// </summary>
|
||||||
|
public FieldOwner FieldOwner { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 字段名称
|
||||||
|
/// </summary>
|
||||||
|
public string FieldName { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 字段值
|
||||||
|
/// </summary>
|
||||||
|
public string FieldValue { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 字段位置
|
||||||
|
/// </summary>
|
||||||
|
public FieldPositionType FieldPosition { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 字段描述
|
||||||
|
///</summary>
|
||||||
|
public string? Description { get; set; }
|
||||||
|
}
|
||||||
@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 业务接口
|
||||||
|
/// </summary>
|
||||||
|
public InterfaceDto OriginalInterface { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 目标服务商
|
||||||
|
/// </summary>
|
||||||
|
public ServiceProviderDto TargetServiceProvider { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 目标服务商接口集合
|
||||||
|
/// </summary>
|
||||||
|
public List<TargetInterfaceSummary> TargetInterfaces { get; set; } = new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 出参映射列表(树形结构)
|
||||||
|
/// </summary>
|
||||||
|
public List<ParameterNode> OutParamTreeList { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 目标服务商授权接口
|
||||||
|
/// </summary>
|
||||||
|
public TargetInterfaceSummary ServiceProviderAuthInterface { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 目标服务商授权配置
|
||||||
|
/// </summary>
|
||||||
|
public List<ServiceProviderAuthConfigDto> ServiceProviderAuthConfigs { get; set; } = null!;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ServiceProviderAuthConfigDto
|
||||||
|
{
|
||||||
|
///<summary>
|
||||||
|
/// 参数标识,1入参,2授权令牌,3有效时间,4固定有效时间,5脚本
|
||||||
|
///</summary>
|
||||||
|
public AuthParameterFlag Flag { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 参数路径
|
||||||
|
///</summary>
|
||||||
|
public string ParameterAlias { get; set; } = null!;
|
||||||
|
|
||||||
|
public string? Value1 { get; set; }
|
||||||
|
|
||||||
|
public string? Value2 { get; set; }
|
||||||
|
|
||||||
|
public string? Value3 { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TargetInterfaceSummary
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 目标服务商接口
|
||||||
|
/// </summary>
|
||||||
|
public InterfaceDto TargetInterface { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 请求前置脚本
|
||||||
|
/// </summary>
|
||||||
|
public string? PrefixScript { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 请求后置脚本
|
||||||
|
/// </summary>
|
||||||
|
public string? PostfixScript { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 入参映射列表(树形结构)
|
||||||
|
/// </summary>
|
||||||
|
public List<ParameterNode> InParamTreeList { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 固定值列表
|
||||||
|
/// </summary>
|
||||||
|
public List<FixedFieldWithValueDto> FixedFieldList { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回配置列表
|
||||||
|
/// </summary>
|
||||||
|
public List<InterfaceReturnConfigDto> ReturnConfigList { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 表单字段列表
|
||||||
|
/// </summary>
|
||||||
|
public List<InterfaceFormFieldDto> FormFieldList { get; set; } = null!;
|
||||||
|
}
|
||||||
82
src/InterfaceForward.Api.Contract/Models/InterfaceDto.cs
Normal file
82
src/InterfaceForward.Api.Contract/Models/InterfaceDto.cs
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
using InterfaceForward.Domain.Enums;
|
||||||
|
using InterfaceForward.Domain.InterfaceAggregate;
|
||||||
|
|
||||||
|
namespace InterfaceForward.Api.Contract.Models;
|
||||||
|
|
||||||
|
public class InterfaceDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 接口Id
|
||||||
|
/// </summary>
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 接口名
|
||||||
|
///</summary>
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 服务商id
|
||||||
|
/// </summary>
|
||||||
|
public int ServiceProviderId { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 接口代码
|
||||||
|
///</summary>
|
||||||
|
public string Code { get; set; } = null!;
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 请求地址
|
||||||
|
///</summary>
|
||||||
|
public string? RequestAddress { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 请求方式
|
||||||
|
///</summary>
|
||||||
|
public string? RequestMethod { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 内容类型
|
||||||
|
///</summary>
|
||||||
|
public RequestContentType ContentType { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 返回内容类型
|
||||||
|
///</summary>
|
||||||
|
public ResponseContentType ResponseContentType { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 是否支持批量处理
|
||||||
|
///</summary>
|
||||||
|
public bool IsBatch { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 批量处理上限
|
||||||
|
/// </summary>
|
||||||
|
public int Limit { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// qps
|
||||||
|
/// </summary>
|
||||||
|
public int Qps { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 流程代码
|
||||||
|
///</summary>
|
||||||
|
public string? FlowCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否禁用授权
|
||||||
|
/// </summary>
|
||||||
|
public bool IsDisableAuth { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 请求超时(s)
|
||||||
|
///</summary>
|
||||||
|
public int? Timeout { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 映射后参数类型(默认Object)
|
||||||
|
/// </summary>
|
||||||
|
public ParameterType MappedParamType { get; set; }
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
namespace InterfaceForward.Api.Contract.Models;
|
||||||
|
|
||||||
|
public class InterfaceFormFieldDto
|
||||||
|
{
|
||||||
|
///<summary>
|
||||||
|
/// 参数名
|
||||||
|
///</summary>
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 参数值
|
||||||
|
///</summary>
|
||||||
|
public string Value { get; set; } = null!;
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 参数描述
|
||||||
|
///</summary>
|
||||||
|
public string? Description { get; set; }
|
||||||
|
}
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
using InterfaceForward.Domain.Enums;
|
||||||
|
|
||||||
|
namespace InterfaceForward.Api.Contract.Models;
|
||||||
|
|
||||||
|
public class InterfaceParameterMapDto
|
||||||
|
{
|
||||||
|
///<summary>
|
||||||
|
/// 接口ID
|
||||||
|
///</summary>
|
||||||
|
public int InterfaceId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 参数Id
|
||||||
|
/// </summary>
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 父级Id
|
||||||
|
/// </summary>
|
||||||
|
public int PId { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 参数名
|
||||||
|
///</summary>
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 参数别名(要构建的)
|
||||||
|
///</summary>
|
||||||
|
public string Alias { get; set; } = null!;
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 映射参数别名(被重构的)
|
||||||
|
///</summary>
|
||||||
|
public string MapAlias { get; set; } = null!;
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 参数类型
|
||||||
|
///</summary>
|
||||||
|
public ParameterType Type { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 必填的
|
||||||
|
/// </summary>
|
||||||
|
public bool IsRequired { get; set; }
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
using InterfaceForward.Api.Contract.Enums;
|
||||||
|
using InterfaceForward.Domain.Enums;
|
||||||
|
|
||||||
|
namespace InterfaceForward.Api.Contract.Models;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class InterfaceReturnConfigDto
|
||||||
|
{
|
||||||
|
///<summary>
|
||||||
|
/// 接口ID
|
||||||
|
///</summary>
|
||||||
|
public int InterfaceId { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 配置类型
|
||||||
|
///</summary>
|
||||||
|
public InterfaceReturnConfigType ConfigType { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 路径
|
||||||
|
///</summary>
|
||||||
|
public string Path { get; set; } = null!;
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 值
|
||||||
|
///</summary>
|
||||||
|
public string? Value { get; set; }
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace InterfaceForward.Api.Contract.Models;
|
||||||
|
|
||||||
|
public class ParameterNode : InterfaceParameterMapDto
|
||||||
|
{
|
||||||
|
public List<ParameterNode> Children { get; set; } = null!;
|
||||||
|
}
|
||||||
78
src/InterfaceForward.Api.Contract/Models/RequestLogDto.cs
Normal file
78
src/InterfaceForward.Api.Contract/Models/RequestLogDto.cs
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace InterfaceForward.Api.Contract.Models;
|
||||||
|
|
||||||
|
public class RequestLogDto(Guid requestId)
|
||||||
|
{
|
||||||
|
public const string Init = "未能请求成功";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 请求Id
|
||||||
|
/// </summary>
|
||||||
|
public Guid RequestId { get; set; } = requestId;
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 请求时间(务必设置)
|
||||||
|
///</summary>
|
||||||
|
public DateTime RequestTime { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// false:服务商 true:应用
|
||||||
|
///</summary>
|
||||||
|
public bool IsApp { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 应用/服务商名称
|
||||||
|
///</summary>
|
||||||
|
public string? Name { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 发起请求IP
|
||||||
|
///</summary>
|
||||||
|
public string? ClientIP { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 接口代码
|
||||||
|
///</summary>
|
||||||
|
public string? InterfaceCode { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 请求接口名称
|
||||||
|
///</summary>
|
||||||
|
public string? InterfaceName { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 请求地址
|
||||||
|
///</summary>
|
||||||
|
public string? Address { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 请求头
|
||||||
|
///</summary>
|
||||||
|
public string? Headers { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 请求体
|
||||||
|
///</summary>
|
||||||
|
public string? Content { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 响应耗时ms
|
||||||
|
///</summary>
|
||||||
|
public int Cost { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 响应结果
|
||||||
|
///</summary>
|
||||||
|
public string? Response { get; set; } = Init;
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 是否成功调用
|
||||||
|
///</summary>
|
||||||
|
public bool IsSuccess { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异常
|
||||||
|
/// </summary>
|
||||||
|
public string? Exception { get; set; }
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
namespace InterfaceForward.Api.Contract.Models;
|
||||||
|
|
||||||
|
public class ServiceProviderAccountFieldWithValueDto
|
||||||
|
{
|
||||||
|
///<summary>
|
||||||
|
/// 字段名称
|
||||||
|
///</summary>
|
||||||
|
public string FieldName { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 字段值
|
||||||
|
/// </summary>
|
||||||
|
public string FieldValue { get; set; } = null!;
|
||||||
|
}
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
namespace InterfaceForward.Api.Contract.Models;
|
||||||
|
|
||||||
|
public class ServiceProviderDto
|
||||||
|
{
|
||||||
|
///<summary>
|
||||||
|
/// Id
|
||||||
|
///</summary>
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 服务商名称
|
||||||
|
///</summary>
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 服务商代码
|
||||||
|
///</summary>
|
||||||
|
public string Code { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否禁用授权
|
||||||
|
/// </summary>
|
||||||
|
public bool IsDisableAuth { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 流程代码
|
||||||
|
///</summary>
|
||||||
|
public string? FlowCode { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 授权接口Code
|
||||||
|
///</summary>
|
||||||
|
public string? AuthInterfaceCode { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 请求超时(s)
|
||||||
|
///</summary>
|
||||||
|
public int? Timeout { get; set; }
|
||||||
|
}
|
||||||
21
src/InterfaceForward.Api/Controllers/InterfaceController.cs
Normal file
21
src/InterfaceForward.Api/Controllers/InterfaceController.cs
Normal file
@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 系统接口分页列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("/SystemInterfacePaginatedList")]
|
||||||
|
public async Task<PagedResultDto<>> SystemInterfacePaginatedListAsync(SystemInterfacePaginatedInputObjectValue input)
|
||||||
|
{
|
||||||
|
return await _interfaceRepository.GetSystemInterfacePaginatedListAsync(input);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -14,7 +14,9 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\InterfaceForward.Api.Contract\InterfaceForward.Api.Contract.csproj" />
|
||||||
<ProjectReference Include="..\InterfaceForward.Domain\InterfaceForward.Domain.csproj" />
|
<ProjectReference Include="..\InterfaceForward.Domain\InterfaceForward.Domain.csproj" />
|
||||||
|
<ProjectReference Include="..\InterfaceForward.Infrastructure\InterfaceForward.Infrastructure.csproj" />
|
||||||
<ProjectReference Include="..\InterfaceForward.ServiceDefaults\InterfaceForward.ServiceDefaults.csproj" />
|
<ProjectReference Include="..\InterfaceForward.ServiceDefaults\InterfaceForward.ServiceDefaults.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,13 @@
|
|||||||
using Fake.AspNetCore;
|
using Fake.AspNetCore;
|
||||||
using Fake.Modularity;
|
using Fake.Modularity;
|
||||||
|
using InterfaceForward.Api.Contract;
|
||||||
|
using InterfaceForward.Domain;
|
||||||
|
|
||||||
namespace InterfaceForward.Api;
|
namespace InterfaceForward.Api;
|
||||||
|
|
||||||
[DependsOn(typeof(FakeAspNetCoreModule))]
|
[DependsOn(typeof(FakeAspNetCoreModule))]
|
||||||
|
[DependsOn(typeof(InterfaceForwardDomainModule))]
|
||||||
|
[DependsOn(typeof(InterfaceForwardApiContractModule))]
|
||||||
public class InterfaceForwardApiModule : FakeModule
|
public class InterfaceForwardApiModule : FakeModule
|
||||||
{
|
{
|
||||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using Fake.DomainDrivenDesign.Entities.Auditing;
|
using Fake.DomainDrivenDesign.Entities.Auditing;
|
||||||
|
|
||||||
namespace InterfaceForward.Domain.DictionaryAggregate;
|
namespace InterfaceForward.Domain.Aggregates.DictionaryAggregate;
|
||||||
|
|
||||||
public class DictionaryEntity:FullAuditedAggregate<Guid>
|
public class DictionaryEntity:FullAuditedAggregate<Guid>
|
||||||
{
|
{
|
||||||
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using Fake.DomainDrivenDesign.Entities.Auditing;
|
using Fake.DomainDrivenDesign.Entities.Auditing;
|
||||||
|
|
||||||
namespace InterfaceForward.Domain.DictionaryAggregate;
|
namespace InterfaceForward.Domain.Aggregates.DictionaryAggregate;
|
||||||
|
|
||||||
public class DictionaryItemEntity : FullAuditedEntity<Guid>
|
public class DictionaryItemEntity : FullAuditedEntity<Guid>
|
||||||
{
|
{
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
namespace InterfaceForward.Domain.Aggregates.InterfaceAggregate;
|
||||||
|
|
||||||
|
public interface IInterfaceRepository
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@ -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<Guid>
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 入参根节点类型
|
||||||
|
/// </summary>
|
||||||
|
public ParameterType InParamRootType { get; private set; } = inParamRootType;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 出参根节点类型
|
||||||
|
/// </summary>
|
||||||
|
public ParameterType OutParamRootType { get; private set; } = outParamRootType;
|
||||||
|
|
||||||
|
private readonly List<InterfaceParamEntity> _params = [];
|
||||||
|
public IReadOnlyCollection<InterfaceParamEntity> InParams => _params.Where(x => x.IsInParam).ToImmutableList();
|
||||||
|
public IReadOnlyCollection<InterfaceParamEntity> OutParams => _params.Where(x => !x.IsInParam).ToImmutableList();
|
||||||
|
|
||||||
|
public void AddInParams(IEnumerable<InterfaceParamEntity> inParams)
|
||||||
|
{
|
||||||
|
_params.AddRange(inParams);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,8 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using Fake.DomainDrivenDesign.Entities.Auditing;
|
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<Guid>
|
public class InterfaceParamEntity : FullAuditedEntity<Guid>
|
||||||
{
|
{
|
||||||
@ -1,9 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using Fake.DomainDrivenDesign.Entities.Auditing;
|
using Fake.DomainDrivenDesign.Entities.Auditing;
|
||||||
|
using InterfaceForward.Domain.Enums;
|
||||||
using InterfaceForward.Domain.InterfaceAggregate;
|
using InterfaceForward.Domain.InterfaceAggregate;
|
||||||
using InterfaceForward.Domain.UpStreamInterfaceAggregate;
|
|
||||||
|
|
||||||
namespace InterfaceForward.Domain.ServiceProviderAggregate;
|
namespace InterfaceForward.Domain.Aggregates.InterfaceAggregate;
|
||||||
|
|
||||||
public class ServiceProviderInterfaceEntity(
|
public class ServiceProviderInterfaceEntity(
|
||||||
int serviceProviderId,
|
int serviceProviderId,
|
||||||
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using Fake.DomainDrivenDesign.Entities.Auditing;
|
using Fake.DomainDrivenDesign.Entities.Auditing;
|
||||||
|
|
||||||
namespace InterfaceForward.Domain.InterfaceMapAggregate;
|
namespace InterfaceForward.Domain.Aggregates.InterfaceMapAggregate;
|
||||||
|
|
||||||
public class InterfaceMapDetailsEntity : FullAuditedEntity<Guid>
|
public class InterfaceMapDetailsEntity : FullAuditedEntity<Guid>
|
||||||
{
|
{
|
||||||
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||||||
using Fake.DomainDrivenDesign.Entities;
|
using Fake.DomainDrivenDesign.Entities;
|
||||||
using Fake.DomainDrivenDesign.Entities.Auditing;
|
using Fake.DomainDrivenDesign.Entities.Auditing;
|
||||||
|
|
||||||
namespace InterfaceForward.Domain.InterfaceMapAggregate;
|
namespace InterfaceForward.Domain.Aggregates.InterfaceMapAggregate;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 上游接口映射服务商接口(1:1:N)
|
/// 上游接口映射服务商接口(1:1:N)
|
||||||
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using Fake.DomainDrivenDesign.Entities.Auditing;
|
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)
|
public class ServiceProviderEntity(string name, string code, string description, string? flowCode = null)
|
||||||
: FullAuditedAggregate<Guid>
|
: FullAuditedAggregate<Guid>
|
||||||
12
src/InterfaceForward.Domain/DTOs/Common/PagedResultDto.cs
Normal file
12
src/InterfaceForward.Domain/DTOs/Common/PagedResultDto.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace InterfaceForward.Domain.DTOs.Common;
|
||||||
|
|
||||||
|
public class PagedResultDto<T>(List<T> items, int pageIndex, int pageSize, int total)
|
||||||
|
{
|
||||||
|
public int PageIndex { get; } = pageIndex;
|
||||||
|
public int PageSize { get; } = pageSize;
|
||||||
|
public int Total { get; } = total;
|
||||||
|
|
||||||
|
public List<T> Items { get; } = items;
|
||||||
|
}
|
||||||
12
src/InterfaceForward.Domain/DTOs/Common/UnifiedResult.cs
Normal file
12
src/InterfaceForward.Domain/DTOs/Common/UnifiedResult.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace InterfaceForward.Domain.DTOs.Common;
|
||||||
|
|
||||||
|
public class UnifiedResult<T>(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;
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
namespace InterfaceForward.Domain.DTOs.Interfaces;
|
||||||
|
|
||||||
|
public class InterfaceSummary
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
7
src/InterfaceForward.Domain/Enums/InterfaceType.cs
Normal file
7
src/InterfaceForward.Domain/Enums/InterfaceType.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace InterfaceForward.Domain.Enums;
|
||||||
|
|
||||||
|
public enum InterfaceType
|
||||||
|
{
|
||||||
|
ServiceProvider = 1,
|
||||||
|
Platform = 2
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
namespace InterfaceForward.Domain.UpStreamInterfaceAggregate;
|
namespace InterfaceForward.Domain.Enums;
|
||||||
|
|
||||||
public enum ParameterType
|
public enum ParameterType
|
||||||
{
|
{
|
||||||
@ -1,78 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Fake.DomainDrivenDesign.Entities.Auditing;
|
|
||||||
using InterfaceForward.Domain.UpStreamInterfaceAggregate;
|
|
||||||
|
|
||||||
namespace InterfaceForward.Domain.InterfaceAggregate;
|
|
||||||
|
|
||||||
public class InterfaceEntity : FullAuditedAggregate<Guid>
|
|
||||||
{
|
|
||||||
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; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 接口单次请求数量上限
|
|
||||||
/// </summary>
|
|
||||||
public int? Limit { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 接口qps限制
|
|
||||||
/// </summary>
|
|
||||||
public int? Qps { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 入参根节点类型
|
|
||||||
/// </summary>
|
|
||||||
public ParameterType InParamRootType { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 出参根节点类型
|
|
||||||
/// </summary>
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -10,4 +10,8 @@
|
|||||||
<PackageReference Include="Fake.DomainDrivenDesign" Version="8.0.0-preview.2"/>
|
<PackageReference Include="Fake.DomainDrivenDesign" Version="8.0.0-preview.2"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Aggregates\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -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<InterfaceEntity>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<InterfaceEntity> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
using InterfaceForward.Domain.InterfaceMapAggregate;
|
using InterfaceForward.Domain.Aggregates.InterfaceMapAggregate;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using InterfaceForward.Domain.InterfaceMapAggregate;
|
using InterfaceForward.Domain.Aggregates.InterfaceMapAggregate;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
|
|
||||||
|
|||||||
@ -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<InterfaceParamEntity>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<InterfaceParamEntity> builder)
|
||||||
|
{
|
||||||
|
builder.ToTable("t_interface_params", InterfaceForwardContext.DefaultSchema);
|
||||||
|
|
||||||
|
builder.HasKey(x => x.Id);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
using Fake.EntityFrameworkCore;
|
using Fake.EntityFrameworkCore;
|
||||||
|
using InterfaceForward.Domain.Aggregates.InterfaceAggregate;
|
||||||
|
using InterfaceForward.Domain.Aggregates.ServiceProviderAggregate;
|
||||||
using InterfaceForward.Domain.InterfaceAggregate;
|
using InterfaceForward.Domain.InterfaceAggregate;
|
||||||
using InterfaceForward.Domain.ServiceProviderAggregate;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace InterfaceForward.Infrastructure;
|
namespace InterfaceForward.Infrastructure;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user