升级框架

This commit is contained in:
xiaolipro 2026-06-12 14:15:54 +08:00
parent c637a7b9c8
commit 6ba2ca367e
51 changed files with 172 additions and 246 deletions

View File

@ -1,6 +1,6 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<!-- All Fake packages --> <!-- All Fake packages -->
<FakePackageVersion>8.0.5.6</FakePackageVersion> <FakePackageVersion>8.0.5.13</FakePackageVersion>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@ -9,9 +9,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\InterfaceForward.Application\InterfaceForward.Application.csproj" /> <ProjectReference Include="..\InterfaceForward.Application\InterfaceForward.Application.csproj" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.18" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" /> <PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageReference Include="Fake.Consul" Version="$(FakePackageVersion)" /> <PackageReference Include="Fake.Consul" Version="$(FakePackageVersion)" />
<PackageReference Include="Fake.Autofac" Version="$(FakePackageVersion)" /> <PackageReference Include="Fake.Autofac" Version="$(FakePackageVersion)" />
</ItemGroup> </ItemGroup>

View File

@ -1,17 +1,18 @@
using Fake.AspNetCore; using Fake.AspNetCore;
using Fake.AspNetCore.Auditing; using Fake.AspNetCore.Auditing;
using Fake.AspNetCore.Mvc; using Fake.AspNetCore.Authentication;
using Fake.AspNetCore.ExceptionHandling;
using Fake.AspNetCore.Newtonsoft;
using Fake.AspNetCore.Swagger;
using Fake.Authorization; using Fake.Authorization;
using Fake.Autofac; using Fake.Autofac;
using Fake.FeiShu; using Fake.FeiShu;
using Fake.Modularity; using Fake.Modularity;
using Fake.Security.Claims; using Fake.Security.Claims;
using Fake.Serilog.Sink.FeiShu; using Fake.Serilog;
using InterfaceForward.Application; using InterfaceForward.Application;
using InterfaceForward.Domain.Shared;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Authorization; using Microsoft.AspNetCore.Mvc.Authorization;
namespace InterfaceForward.Api; namespace InterfaceForward.Api;
@ -19,7 +20,7 @@ namespace InterfaceForward.Api;
[DependsOn(typeof(FakeAuthorizationModule))] [DependsOn(typeof(FakeAuthorizationModule))]
[DependsOn(typeof(FakeAutofacModule))] [DependsOn(typeof(FakeAutofacModule))]
[DependsOn(typeof(InterfaceForwardApplicationModule))] [DependsOn(typeof(InterfaceForwardApplicationModule))]
[DependsOn(typeof(FakeSerilogSinkFeiShuModule))] [DependsOn(typeof(FakeSerilogModule))]
public class InterfaceForwardApiModule : FakeModule public class InterfaceForwardApiModule : FakeModule
{ {
private const string DefaultCorsPolicyName = "default"; private const string DefaultCorsPolicyName = "default";
@ -34,9 +35,6 @@ public class InterfaceForwardApiModule : FakeModule
var services = context.Services; var services = context.Services;
var configuration = context.Services.GetConfiguration(); var configuration = context.Services.GetConfiguration();
// Add services to the container.
services.AddProblemDetails();
services.Configure<FakeAspNetCoreMvcOptions>(options => services.Configure<FakeAspNetCoreMvcOptions>(options =>
{ {
options.ApplicationServices2Controller<InterfaceForwardApplicationModule>(); options.ApplicationServices2Controller<InterfaceForwardApplicationModule>();
@ -49,20 +47,12 @@ public class InterfaceForwardApiModule : FakeModule
.RequireAuthenticatedUser() .RequireAuthenticatedUser()
.Build(); .Build();
options.Filters.Add(new AuthorizeFilter(policy)); options.Filters.Add(new AuthorizeFilter(policy));
}).AddNewtonsoftJson();
//Json格式化全局处理
context.Services.Configure<MvcNewtonsoftJsonOptions>(options =>
{
options.SerializerSettings.ContractResolver =
new Newtonsoft.Json.Serialization.
CamelCasePropertyNamesContractResolver(); // 首字母小写(驼峰样式)
options.SerializerSettings.Converters.Add(new DateTimeJsonConverter("yyyy-MM-dd HH:mm:ss"));
options.SerializerSettings.Converters.Add(new LongJsonConverter());
}); });
services.AddFakeSwaggerGen(addSecurity: true) services.AddFakeSwaggerGen(addSecurity: true)
.AddFakeAspNetCoreAuditing(); .AddFakeAspNetCoreAuditing()
.AddFakeNewtonsoft()
.AddFeiShuNotification();
services.AddCors(options => services.AddCors(options =>
{ {

View File

@ -1,7 +1,6 @@
using AutoMapper; using AutoMapper;
using InterfaceForward.Application.Contracts.Dtos.Interface; using InterfaceForward.Application.Contracts.Dtos.Interface;
using InterfaceForward.Application.Contracts.Dtos.ServiceProvider; using InterfaceForward.Application.Contracts.Dtos.ServiceProvider;
using InterfaceForward.Domain.Shared.Dtos;
using InterfaceForward.Repositories.Interface.Entitys; using InterfaceForward.Repositories.Interface.Entitys;
using InterfaceForward.Repositories.Interface.ValueObjects; using InterfaceForward.Repositories.Interface.ValueObjects;
using InterfaceForward.Repositories.Parameter.Entities; using InterfaceForward.Repositories.Parameter.Entities;

View File

@ -1,7 +1,6 @@
using AutoMapper; using AutoMapper;
using InterfaceForward.Application.Contracts.Dtos.Interface; using InterfaceForward.Application.Contracts.Dtos.Interface;
using InterfaceForward.Application.Contracts.Dtos.ServiceProvider; using InterfaceForward.Application.Contracts.Dtos.ServiceProvider;
using InterfaceForward.Domain.Shared.Dtos;
using InterfaceForward.Repositories.Interface.Entitys; using InterfaceForward.Repositories.Interface.Entitys;
using InterfaceForward.Repositories.Interface.ValueObjects; using InterfaceForward.Repositories.Interface.ValueObjects;
using InterfaceForward.Repositories.Parameter.Entities; using InterfaceForward.Repositories.Parameter.Entities;

View File

@ -45,22 +45,22 @@ public class ForwardAuthorizeFilter(
string? appKey = headers["appKey"], appSecret = headers["appSecret"]; string? appKey = headers["appKey"], appSecret = headers["appSecret"];
if (appKey.IsNullOrWhiteSpace() || appSecret.IsNullOrWhiteSpace()) if (appKey.IsNullOrWhiteSpace() || appSecret.IsNullOrWhiteSpace())
{ {
throw new BusinessException(message: "应用授权失败AppKey和AppSecret是必填的"); throw new BusinessException("应用授权失败AppKey和AppSecret是必填的");
} }
var app = await interfaceForwardQuery.FindAppAsync(appKey!, appSecret!); var app = await interfaceForwardQuery.FindAppAsync(appKey!, appSecret!);
if (app == null) if (app == null)
throw new BusinessException(message: "应用授权失败请检查AppKey或AppSecret是否正确"); throw new BusinessException("应用授权失败请检查AppKey或AppSecret是否正确");
log.Name = app.Name; log.Name = app.Name;
if (!app.IsOnline) if (!app.IsOnline)
throw new BusinessException(message: "应用已被禁用,请检查应用状态"); throw new BusinessException("应用已被禁用,请检查应用状态");
logRepository.AppId = app.Id; logRepository.AppId = app.Id;
var upStreamCode = httpContext.Request.Query["standardCode"].ToString(); var upStreamCode = httpContext.Request.Query["standardCode"].ToString();
var systemInterface = await interfaceRepository.GetFirstAsync(x => x.Code == upStreamCode, var systemInterface = await interfaceRepository.GetFirstAsync(x => x.Code == upStreamCode,
x => new { x.Code, x.Name }); x => new { x.Code, x.Name });
if (systemInterface == null) throw new BusinessException(message: "系统接口不存在"); if (systemInterface == null) throw new BusinessException("系统接口不存在");
logRepository.AppRequestLog.InterfaceCode = systemInterface.Code; logRepository.AppRequestLog.InterfaceCode = systemInterface.Code;
logRepository.AppRequestLog.InterfaceName = systemInterface.Name; logRepository.AppRequestLog.InterfaceName = systemInterface.Name;

View File

@ -239,7 +239,7 @@ public class DefaultForwardFlow : IForwardFlow, ITransientDependency
context.ServiceProviderRequestLog.Address = context.TargetInterface.RequestAddress; context.ServiceProviderRequestLog.Address = context.TargetInterface.RequestAddress;
context.ServiceProviderRequestLog.IsSuccess = false; context.ServiceProviderRequestLog.IsSuccess = false;
throw new BusinessException(message: msg); throw new BusinessException(msg);
} }
/// <summary> /// <summary>
@ -440,7 +440,7 @@ public class DefaultForwardFlow : IForwardFlow, ITransientDependency
break; break;
case ContentType.FormData: case ContentType.FormData:
default: default:
throw new BusinessException(message: "暂时不支持该ContentType"); throw new BusinessException("暂时不支持该ContentType");
} }
msg.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType); msg.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType);
@ -474,7 +474,7 @@ public class DefaultForwardFlow : IForwardFlow, ITransientDependency
break; break;
case ContentType.FormData: case ContentType.FormData:
default: default:
throw new BusinessException(message: "暂时不支持该ContentType"); throw new BusinessException("暂时不支持该ContentType");
} }
return data; return data;
@ -498,7 +498,7 @@ public class DefaultForwardFlow : IForwardFlow, ITransientDependency
{ {
case GlobalConst.FromBody: case GlobalConst.FromBody:
var val = context.OriginalInterfaceMappedInput.SelectToken(fieldName); var val = context.OriginalInterfaceMappedInput.SelectToken(fieldName);
if (val == null) throw new BusinessException(message: $"映射后的body中找不到该路径{fieldName}"); if (val == null) throw new BusinessException($"映射后的body中找不到该路径{fieldName}");
item.FieldValue = val.ToString(); item.FieldValue = val.ToString();
break; break;
case GlobalConst.TimeStamp: case GlobalConst.TimeStamp:

View File

@ -3,4 +3,5 @@
global using Fake; global using Fake;
global using Fake.Application; global using Fake.Application;
global using Fake.Application.Dtos; global using Fake.Application.Dtos;
global using InterfaceForward.Domain.Shared.Dtos;
global using InterfaceForward.Domain.Shared.Helpers; global using InterfaceForward.Domain.Shared.Helpers;

View File

@ -4,7 +4,6 @@ using Fake.UnitOfWork;
using InterfaceForward.Application.Contracts.Dtos.App; using InterfaceForward.Application.Contracts.Dtos.App;
using InterfaceForward.Application.Helpers; using InterfaceForward.Application.Helpers;
using InterfaceForward.Application.OSS; using InterfaceForward.Application.OSS;
using InterfaceForward.Domain.Shared.Dtos;
using InterfaceForward.Repositories; using InterfaceForward.Repositories;
using InterfaceForward.Repositories.App.Entitys; using InterfaceForward.Repositories.App.Entitys;
using InterfaceForward.Repositories.App.Services; using InterfaceForward.Repositories.App.Services;
@ -134,7 +133,7 @@ public class AppsService : ApplicationService
var res = await _appRepository.AsQueryable() var res = await _appRepository.AsQueryable()
.Select(x => new AppOutput { Id = x.Id.SelectAll() }) .Select(x => new AppOutput { Id = x.Id.SelectAll() })
.SingleAsync(x => x.Id == id); .SingleAsync(x => x.Id == id);
_ = res ?? throw new BusinessException(message: "在指定的编号下找不到数据"); _ = res ?? throw new BusinessException("在指定的编号下找不到数据");
// if (res.LogoKey != null) res.LogoUrl = OSSHelper.GetUrlByKey(res.LogoKey); // if (res.LogoKey != null) res.LogoUrl = OSSHelper.GetUrlByKey(res.LogoKey);
res.AppScope = await _appScopeRepository.AsQueryable() res.AppScope = await _appScopeRepository.AsQueryable()
@ -158,12 +157,12 @@ public class AppsService : ApplicationService
public async Task Create(CreateAppInput input) public async Task Create(CreateAppInput input)
{ {
if (await _appRepository.IsAnyAsync(x => x.Name == input.Name)) if (await _appRepository.IsAnyAsync(x => x.Name == input.Name))
throw new BusinessException(message: "应用名称已存在"); throw new BusinessException("应用名称已存在");
if (await _appRepository.IsAnyAsync(x => x.AppKey == input.AppKey)) if (await _appRepository.IsAnyAsync(x => x.AppKey == input.AppKey))
throw new BusinessException(message: "appkey已存在"); throw new BusinessException("appkey已存在");
input.LogoKey = String.Empty; input.LogoKey = String.Empty;
if (await _appRepository.IsAnyAsync(x => x.AppSecret == input.AppSecret)) if (await _appRepository.IsAnyAsync(x => x.AppSecret == input.AppSecret))
throw new BusinessException(message: "appsecret已存在"); throw new BusinessException("appsecret已存在");
var entity = ObjectMapper.Map<CreateAppInput, AppEntity>(input); var entity = ObjectMapper.Map<CreateAppInput, AppEntity>(input);
var appScopeEntitys = ObjectMapper.Map<List<CreateAppScopeInput>, List<AppScopeEntity>>(input.AppScopeList); var appScopeEntitys = ObjectMapper.Map<List<CreateAppScopeInput>, List<AppScopeEntity>>(input.AppScopeList);
@ -174,7 +173,7 @@ public class AppsService : ApplicationService
if (interfaceDic.Count != interfaceIds.Count) if (interfaceDic.Count != interfaceIds.Count)
{ {
throw new BusinessException(message: "有接口不存在,请检查"); throw new BusinessException("有接口不存在,请检查");
} }
using (var ts = TransacationHelper.GetReadCommitted()) using (var ts = TransacationHelper.GetReadCommitted())
@ -202,11 +201,11 @@ public class AppsService : ApplicationService
public async Task<bool> Update(UpdateAppInput input) public async Task<bool> Update(UpdateAppInput input)
{ {
if (await _appRepository.IsAnyAsync(x => x.Name == input.Name && x.Id != input.Id)) if (await _appRepository.IsAnyAsync(x => x.Name == input.Name && x.Id != input.Id))
throw new BusinessException(message: "应用名称已存在"); throw new BusinessException("应用名称已存在");
if (await _appRepository.IsAnyAsync(x => x.AppKey == input.AppKey && x.Id != input.Id)) if (await _appRepository.IsAnyAsync(x => x.AppKey == input.AppKey && x.Id != input.Id))
throw new BusinessException(message: "appkey已存在"); throw new BusinessException("appkey已存在");
if (await _appRepository.IsAnyAsync(x => x.AppSecret == input.AppSecret && x.Id != input.Id)) if (await _appRepository.IsAnyAsync(x => x.AppSecret == input.AppSecret && x.Id != input.Id))
throw new BusinessException(message: "appsecret已存在"); throw new BusinessException("appsecret已存在");
var entity = ObjectMapper.Map<UpdateAppInput, AppEntity>(input); var entity = ObjectMapper.Map<UpdateAppInput, AppEntity>(input);
var appScopeEntitys = ObjectMapper.Map<List<CreateAppScopeInput>, List<AppScopeEntity>>(input.AppScopeList); var appScopeEntitys = ObjectMapper.Map<List<CreateAppScopeInput>, List<AppScopeEntity>>(input.AppScopeList);
@ -283,11 +282,11 @@ public class AppsService : ApplicationService
var appEntity = await _appRepository.GetFirstAsync(x => var appEntity = await _appRepository.GetFirstAsync(x =>
x.AppKey == input.AppKey && x.AppSecret == input.AppSecret && x.IsOnline == true); x.AppKey == input.AppKey && x.AppSecret == input.AppSecret && x.IsOnline == true);
if (appEntity is null) if (appEntity is null)
throw new BusinessException(message: "在指定的编号下找不到数据"); throw new BusinessException("在指定的编号下找不到数据");
var appScopeEntity = await _appScopeRepository.GetAppScopeAsync(appEntity.Id, input.InterfaceCode); var appScopeEntity = await _appScopeRepository.GetAppScopeAsync(appEntity.Id, input.InterfaceCode);
if (appScopeEntity is null) if (appScopeEntity is null)
throw new BusinessException(message: "应用不可访问该接口"); throw new BusinessException("应用不可访问该接口");
string redisKey = input.AppKey + input.InterfaceCode; string redisKey = input.AppKey + input.InterfaceCode;
@ -297,7 +296,7 @@ public class AppsService : ApplicationService
if (num < appScopeEntity.QPS) if (num < appScopeEntity.QPS)
await RedisHelper.Client.IncrByAsync(redisKey, 1); await RedisHelper.Client.IncrByAsync(redisKey, 1);
else else
throw new BusinessException(message: "超过流量限制"); throw new BusinessException("超过流量限制");
} }
else else
await RedisHelper.Client.SetAsync(redisKey, 1, 1); await RedisHelper.Client.SetAsync(redisKey, 1, 1);

View File

@ -44,25 +44,25 @@ public class ShopeeForwardAuthorizeFilter(
// string? appKey = headers["appKey"], appSecret = headers["appSecret"]; // string? appKey = headers["appKey"], appSecret = headers["appSecret"];
// if (appKey.IsNullOrWhiteSpace() || appSecret.IsNullOrWhiteSpace()) // if (appKey.IsNullOrWhiteSpace() || appSecret.IsNullOrWhiteSpace())
// { // {
// throw new BusinessException(message: "应用授权失败AppKey和AppSecret是必填的"); // throw new BusinessException("应用授权失败AppKey和AppSecret是必填的");
// } // }
// //
// var app = await interfaceForwardQuery.FindAppAsync(appKey!, appSecret!); // var app = await interfaceForwardQuery.FindAppAsync(appKey!, appSecret!);
// if (app == null) // if (app == null)
// throw new BusinessException(message: "应用授权失败请检查AppKey或AppSecret是否正确"); // throw new BusinessException("应用授权失败请检查AppKey或AppSecret是否正确");
// 先写死的 // 先写死的
var app = await interfaceForwardQuery.FindAppAsync("W2507080", "G1rA80mAfGovH7j53t5bIH425M4vKreT"); var app = await interfaceForwardQuery.FindAppAsync("W2507080", "G1rA80mAfGovH7j53t5bIH425M4vKreT");
log.Name = app.Name; log.Name = app.Name;
if (!app.IsOnline) if (!app.IsOnline)
throw new BusinessException(message: "应用已被禁用,请检查应用状态"); throw new BusinessException("应用已被禁用,请检查应用状态");
logRepository.AppId = app.Id; logRepository.AppId = app.Id;
var upStreamCode = httpContext.Request.Path.ToUriComponent().Split('/')[1]; var upStreamCode = httpContext.Request.Path.ToUriComponent().Split('/')[1];
var systemInterface = await interfaceRepository.GetFirstAsync(x => x.Code == upStreamCode, var systemInterface = await interfaceRepository.GetFirstAsync(x => x.Code == upStreamCode,
x => new { x.Code, x.Name }); x => new { x.Code, x.Name });
if (systemInterface == null) throw new BusinessException(message: "系统接口不存在"); if (systemInterface == null) throw new BusinessException("系统接口不存在");
logRepository.AppRequestLog.InterfaceCode = systemInterface.Code; logRepository.AppRequestLog.InterfaceCode = systemInterface.Code;
logRepository.AppRequestLog.InterfaceName = systemInterface.Name; logRepository.AppRequestLog.InterfaceName = systemInterface.Name;

View File

@ -50,7 +50,7 @@ public class InterfaceReturnConfigService : ApplicationService
{ {
if (!await _interfaceRepository.IsAnyAsync(x => x.Id == input.InterfaceId)) if (!await _interfaceRepository.IsAnyAsync(x => x.Id == input.InterfaceId))
{ {
throw new BusinessException(message: "接口不存在"); throw new BusinessException("接口不存在");
} }
// 开启事务 // 开启事务

View File

@ -101,7 +101,7 @@ public class InterfaceService : ApplicationService
var interfaceEntity = await InterfaceRepository.GetFirstAsync(x => x.Id == id); var interfaceEntity = await InterfaceRepository.GetFirstAsync(x => x.Id == id);
if (interfaceEntity == null) if (interfaceEntity == null)
{ {
throw new BusinessException(message: "接口不存在"); throw new BusinessException("接口不存在");
} }
var res = ObjectMapper.Map<InterfaceEntity, InterfaceOutput>(interfaceEntity); var res = ObjectMapper.Map<InterfaceEntity, InterfaceOutput>(interfaceEntity);
@ -237,7 +237,7 @@ public class InterfaceService : ApplicationService
x.IsUpStream == input.IsUpStream && (x.Name.Equals(input.Name) || x.Code.Equals(input.Code)) && x.IsUpStream == input.IsUpStream && (x.Name.Equals(input.Name) || x.Code.Equals(input.Code)) &&
x.ServiceProviderId == input.ServiceProviderId)) x.ServiceProviderId == input.ServiceProviderId))
{ {
throw new BusinessException(message: $"接口名或code:{input.Name} 已存在"); throw new BusinessException($"接口名或code:{input.Name} 已存在");
} }
#endregion #endregion
@ -260,7 +260,7 @@ public class InterfaceService : ApplicationService
// 接口代码生成时并发兜底方案 // 接口代码生成时并发兜底方案
if (await InterfaceRepository.CountAsync(x => x.Code.Equals(interfaceEntity.Code)) > 1) if (await InterfaceRepository.CountAsync(x => x.Code.Equals(interfaceEntity.Code)) > 1)
{ {
throw new BusinessException(message: "接口代码生成异常,请稍后重试"); throw new BusinessException("接口代码生成异常,请稍后重试");
} }
// 提交事务 // 提交事务
@ -274,7 +274,7 @@ public class InterfaceService : ApplicationService
// 系统生成,由服务商代码+3位数字组成0-999按顺序生成 // 系统生成,由服务商代码+3位数字组成0-999按顺序生成
// tips唯一性 // tips唯一性
var entity = await ServiceProviderRepository.GetFirstAsync(x => x.Id == serviceProviderId); var entity = await ServiceProviderRepository.GetFirstAsync(x => x.Id == serviceProviderId);
if (entity == null) throw new BusinessException(message: "服务商不存在系统接口自己定义code谢谢配合"); if (entity == null) throw new BusinessException("服务商不存在系统接口自己定义code谢谢配合");
string res = entity.Code; string res = entity.Code;
@ -293,14 +293,14 @@ public class InterfaceService : ApplicationService
if (!await InterfaceRepository.IsAnyAsync(x => x.Id == input.Id)) if (!await InterfaceRepository.IsAnyAsync(x => x.Id == input.Id))
{ {
throw new BusinessException(message: "接口不存在"); throw new BusinessException("接口不存在");
} }
if (await InterfaceRepository.IsAnyAsync(x => if (await InterfaceRepository.IsAnyAsync(x =>
x.Name.Equals(input.Name) && x.Id != input.Id && x.IsUpStream == input.IsUpStream && x.Name.Equals(input.Name) && x.Id != input.Id && x.IsUpStream == input.IsUpStream &&
x.ServiceProviderId == input.ServiceProviderId)) x.ServiceProviderId == input.ServiceProviderId))
{ {
throw new BusinessException(message: $"接口名:{input.Name} 已存在"); throw new BusinessException($"接口名:{input.Name} 已存在");
} }
#endregion #endregion
@ -360,7 +360,7 @@ public class InterfaceService : ApplicationService
if (input.IsUpStream) if (input.IsUpStream)
{ {
if (input.RequestBodyParameterList.Count > 0 || input.MappingBodyParameterList.Count > 0 || input.BodyFormParameterList.Count > 0) if (input.RequestBodyParameterList.Count > 0 || input.MappingBodyParameterList.Count > 0 || input.BodyFormParameterList.Count > 0)
throw new BusinessException(message: "上游接口只能维护 inParameterList"); throw new BusinessException("上游接口只能维护 inParameterList");
return; return;
} }
@ -368,19 +368,19 @@ public class InterfaceService : ApplicationService
{ {
case ContentType.None: case ContentType.None:
if (input.InParameterList.Count > 0 || input.RequestBodyParameterList.Count > 0 || input.BodyFormParameterList.Count > 0) if (input.InParameterList.Count > 0 || input.RequestBodyParameterList.Count > 0 || input.BodyFormParameterList.Count > 0)
throw new BusinessException(message: "None 下游接口只能维护 Query/Header/MappingBody/Response"); throw new BusinessException("None 下游接口只能维护 Query/Header/MappingBody/Response");
break; break;
case ContentType.Json: case ContentType.Json:
case ContentType.Xml: case ContentType.Xml:
if (input.InParameterList.Count > 0 || input.MappingBodyParameterList.Count > 0 || input.BodyFormParameterList.Count > 0) if (input.InParameterList.Count > 0 || input.MappingBodyParameterList.Count > 0 || input.BodyFormParameterList.Count > 0)
throw new BusinessException(message: "Json/Xml 下游接口只能维护 requestBodyParameterList"); throw new BusinessException("Json/Xml 下游接口只能维护 requestBodyParameterList");
break; break;
case ContentType.FormUrlEncoded: case ContentType.FormUrlEncoded:
if (input.InParameterList.Count > 0 || input.RequestBodyParameterList.Count > 0) if (input.InParameterList.Count > 0 || input.RequestBodyParameterList.Count > 0)
throw new BusinessException(message: "FormUrlEncoded 下游接口只能维护 bodyFormParameterList 和 mappingBodyParameterList"); throw new BusinessException("FormUrlEncoded 下游接口只能维护 bodyFormParameterList 和 mappingBodyParameterList");
break; break;
case ContentType.FormData: case ContentType.FormData:
throw new BusinessException(message: "暂时不支持该ContentType"); throw new BusinessException("暂时不支持该ContentType");
default: default:
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
} }

View File

@ -8,7 +8,6 @@ using InterfaceForward.Application.Contracts.ForwardCore;
using InterfaceForward.Application.ForwardCore; using InterfaceForward.Application.ForwardCore;
using InterfaceForward.Application.Helpers; using InterfaceForward.Application.Helpers;
using InterfaceForward.Domain.Shared; using InterfaceForward.Domain.Shared;
using InterfaceForward.Domain.Shared.Dtos;
using InterfaceForward.Domain.Shared.Enum; using InterfaceForward.Domain.Shared.Enum;
using InterfaceForward.Repositories; using InterfaceForward.Repositories;
using InterfaceForward.Repositories.Log.Services; using InterfaceForward.Repositories.Log.Services;
@ -46,13 +45,13 @@ public class InterfaceForwardCommon(
if (cacheContext == null) if (cacheContext == null)
{ {
var systemInterface = await interfaceForwardQuery.GetInterfaceByCodeAsync(upStreamCode); var systemInterface = await interfaceForwardQuery.GetInterfaceByCodeAsync(upStreamCode);
if (systemInterface == null) throw new BusinessException(message: "系统接口不存在"); if (systemInterface == null) throw new BusinessException("系统接口不存在");
logRepository.AppRequestLog.InterfaceCode = systemInterface.Code; logRepository.AppRequestLog.InterfaceCode = systemInterface.Code;
logRepository.AppRequestLog.InterfaceName = systemInterface.Name; logRepository.AppRequestLog.InterfaceName = systemInterface.Name;
var serviceProviderDto = await interfaceForwardQuery.GetServiceProviderByCodeAsync(serviceProviderCode); var serviceProviderDto = await interfaceForwardQuery.GetServiceProviderByCodeAsync(serviceProviderCode);
if (serviceProviderDto == null) throw new BusinessException(message: "服务商不存在"); if (serviceProviderDto == null) throw new BusinessException("服务商不存在");
cacheContext = await interfaceForwardQuery.BuildForwardCoreContext(systemInterface, serviceProviderDto); cacheContext = await interfaceForwardQuery.BuildForwardCoreContext(systemInterface, serviceProviderDto);
await RedisHelper.Client.SetAsync(contextCacheKey, cacheContext.ToJson(), DefaultCacheTtl); await RedisHelper.Client.SetAsync(contextCacheKey, cacheContext.ToJson(), DefaultCacheTtl);
} }
@ -72,7 +71,7 @@ public class InterfaceForwardCommon(
// 服务商授权 // 服务商授权
if (!serviceProviderDto.IsDisableAuth && accountId == default) if (!serviceProviderDto.IsDisableAuth && accountId == default)
{ {
throw new BusinessException(message: $"服务商:{serviceProviderDto.Name} 下不存在此账户,请联系管理员或前往接口通创建"); throw new BusinessException($"服务商:{serviceProviderDto.Name} 下不存在此账户,请联系管理员或前往接口通创建");
} }
accountFieldCache = await interfaceForwardQuery.GetAccountFieldListAsync(accountId); accountFieldCache = await interfaceForwardQuery.GetAccountFieldListAsync(accountId);
@ -145,7 +144,7 @@ public class InterfaceForwardCommon(
var flow = serviceProvider.GetServices<IForwardFlow>() var flow = serviceProvider.GetServices<IForwardFlow>()
.FirstOrDefault(x => x.GetType().Name == flowCode); .FirstOrDefault(x => x.GetType().Name == flowCode);
if (flow == null) if (flow == null)
throw new BusinessException(message: "找不到接口转发流程" + flowCode); throw new BusinessException("找不到接口转发流程" + flowCode);
return flow; return flow;
} }
@ -399,7 +398,7 @@ public class InterfaceForwardCommon(
{ {
if (JToken.FromObject(data) is not JArray jarray) if (JToken.FromObject(data) is not JArray jarray)
{ {
throw new BusinessException(message: "非法结构,请传对象数组"); throw new BusinessException("非法结构,请传对象数组");
} }
var objectArray = new List<JObject>(jarray.Count); var objectArray = new List<JObject>(jarray.Count);
@ -407,7 +406,7 @@ public class InterfaceForwardCommon(
{ {
if (item is not JObject jobect) if (item is not JObject jobect)
{ {
throw new BusinessException(message: "批量处理必须传递对象数组"); throw new BusinessException("批量处理必须传递对象数组");
} }
objectArray.Add(jobect); objectArray.Add(jobect);
@ -415,7 +414,7 @@ public class InterfaceForwardCommon(
if (objectArray.Count < 1) if (objectArray.Count < 1)
{ {
throw new BusinessException(message: "请勿传递空数组"); throw new BusinessException("请勿传递空数组");
} }
return objectArray; return objectArray;

View File

@ -121,7 +121,7 @@ public class InterfaceForwardService : ApplicationService
{ {
if (JToken.FromObject(data) is not JObject jobject) if (JToken.FromObject(data) is not JObject jobject)
{ {
throw new BusinessException(message: "非法结构,请传对象"); throw new BusinessException("非法结构,请传对象");
} }
var contextList = await _forwardCommon.VerifyBusinessAndBuildForwardContexts(standardCode, supplierCode); var contextList = await _forwardCommon.VerifyBusinessAndBuildForwardContexts(standardCode, supplierCode);
@ -159,7 +159,7 @@ public class InterfaceForwardService : ApplicationService
var logs = await _logRepository.GetRequestLogsAsync(requestId); var logs = await _logRepository.GetRequestLogsAsync(requestId);
var failedLog = logs.FirstOrDefault(x => !x.IsSuccess); var failedLog = logs.FirstOrDefault(x => !x.IsSuccess);
if (failedLog == default) throw new BusinessException(message: "找不到失败日志,无法重试"); if (failedLog == default) throw new BusinessException("找不到失败日志,无法重试");
var contextList = await _forwardCommon.VerifyBusinessAndBuildForwardContexts(standardCode, supplierCode); var contextList = await _forwardCommon.VerifyBusinessAndBuildForwardContexts(standardCode, supplierCode);

View File

@ -1,5 +1,4 @@
using System.Reflection; using System.Reflection;
using InterfaceForward.Domain.Shared.Dtos;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;

View File

@ -4,7 +4,6 @@ using DiffPlex.DiffBuilder;
using DiffPlex.DiffBuilder.Model; using DiffPlex.DiffBuilder.Model;
using InterfaceForward.Application.Contracts.Dtos.Interface; using InterfaceForward.Application.Contracts.Dtos.Interface;
using InterfaceForward.Application.Helpers; using InterfaceForward.Application.Helpers;
using InterfaceForward.Domain.Shared.Dtos;
using InterfaceForward.Repositories; using InterfaceForward.Repositories;
using InterfaceForward.Repositories.Interface.Entitys; using InterfaceForward.Repositories.Interface.Entitys;
using InterfaceForward.Repositories.Interface.Services; using InterfaceForward.Repositories.Interface.Services;
@ -60,10 +59,10 @@ public class InterfaceMapPublishService(
[Required] int serviceProviderId, string? version) [Required] int serviceProviderId, string? version)
{ {
var systemInterface = await interfaceForwardQuery.GetInterfaceByCodeAsync(interfaceCode); var systemInterface = await interfaceForwardQuery.GetInterfaceByCodeAsync(interfaceCode);
if (systemInterface == null) throw new BusinessException(message: "系统接口不存在"); if (systemInterface == null) throw new BusinessException("系统接口不存在");
var serviceProvider = await interfaceForwardQuery.GetServiceProviderByIdAsync(serviceProviderId); var serviceProvider = await interfaceForwardQuery.GetServiceProviderByIdAsync(serviceProviderId);
if (serviceProvider == null) throw new BusinessException(message: "服务商不存在"); if (serviceProvider == null) throw new BusinessException("服务商不存在");
// 没有指定比对的版本,就是比对数据库最新数据 // 没有指定比对的版本,就是比对数据库最新数据
var dbContent = version.IsNullOrWhiteSpace() var dbContent = version.IsNullOrWhiteSpace()
@ -99,10 +98,10 @@ public class InterfaceMapPublishService(
public async Task<bool> PublishAsync(InterfaceMapPublishInput input) public async Task<bool> PublishAsync(InterfaceMapPublishInput input)
{ {
var systemInterface = await interfaceForwardQuery.GetInterfaceByCodeAsync(input.InterfaceCode); var systemInterface = await interfaceForwardQuery.GetInterfaceByCodeAsync(input.InterfaceCode);
if (systemInterface == null) throw new BusinessException(message: "系统接口不存在"); if (systemInterface == null) throw new BusinessException("系统接口不存在");
var serviceProvider = await interfaceForwardQuery.GetServiceProviderByIdAsync(input.ServiceProviderId); var serviceProvider = await interfaceForwardQuery.GetServiceProviderByIdAsync(input.ServiceProviderId);
if (serviceProvider == null) throw new BusinessException(message: "服务商不存在"); if (serviceProvider == null) throw new BusinessException("服务商不存在");
// 确认比对期间数据是否被篡改 // 确认比对期间数据是否被篡改
var differ = new Differ(); var differ = new Differ();
@ -110,7 +109,7 @@ public class InterfaceMapPublishService(
var context = await interfaceForwardQuery.BuildForwardCoreContext(systemInterface, serviceProvider); var context = await interfaceForwardQuery.BuildForwardCoreContext(systemInterface, serviceProvider);
var content = JsonConvert.SerializeObject(context, Settings); var content = JsonConvert.SerializeObject(context, Settings);
var diffResult = inlineBuilder.BuildDiffModel(content, input.DBContent); var diffResult = inlineBuilder.BuildDiffModel(content, input.DBContent);
if (diffResult.HasDifferences) throw new BusinessException(message: "数据库已经发生变更,请重新获取最新数据进行比对"); if (diffResult.HasDifferences) throw new BusinessException("数据库已经发生变更,请重新获取最新数据进行比对");
var mapsEntities = await interfaceMapRepository.GetListAsync(x => var mapsEntities = await interfaceMapRepository.GetListAsync(x =>
x.UpStreamId == systemInterface.Id && x.ServiceProviderId == serviceProvider.Id); x.UpStreamId == systemInterface.Id && x.ServiceProviderId == serviceProvider.Id);
@ -152,22 +151,22 @@ public class InterfaceMapPublishService(
public async Task<bool> PublishRollbackAsync(InterfaceMapRollbackInput input) public async Task<bool> PublishRollbackAsync(InterfaceMapRollbackInput input)
{ {
var systemInterface = await interfaceForwardQuery.GetInterfaceByCodeAsync(input.InterfaceCode); var systemInterface = await interfaceForwardQuery.GetInterfaceByCodeAsync(input.InterfaceCode);
if (systemInterface == null) throw new BusinessException(message: "系统接口不存在"); if (systemInterface == null) throw new BusinessException("系统接口不存在");
var serviceProvider = await interfaceForwardQuery.GetServiceProviderByIdAsync(input.ServiceProviderId); var serviceProvider = await interfaceForwardQuery.GetServiceProviderByIdAsync(input.ServiceProviderId);
if (serviceProvider == null) throw new BusinessException(message: "服务商不存在"); if (serviceProvider == null) throw new BusinessException("服务商不存在");
var mapsEntities = await interfaceMapRepository.GetListAsync(x => var mapsEntities = await interfaceMapRepository.GetListAsync(x =>
x.UpStreamId == systemInterface.Id && x.ServiceProviderId == input.ServiceProviderId); x.UpStreamId == systemInterface.Id && x.ServiceProviderId == input.ServiceProviderId);
if (mapsEntities == null || mapsEntities.Count == 0) if (mapsEntities == null || mapsEntities.Count == 0)
{ {
throw new BusinessException(message: "映射不存在"); throw new BusinessException("映射不存在");
} }
var targetVersionContent = await interfaceMapPublishRepository.GetFirstAsync(a => var targetVersionContent = await interfaceMapPublishRepository.GetFirstAsync(a =>
a.InterfaceId == systemInterface.Id && a.ServiceProviderId == input.ServiceProviderId && a.InterfaceId == systemInterface.Id && a.ServiceProviderId == input.ServiceProviderId &&
a.PublishedVersion == input.Version, a => a.PublishedContent); a.PublishedVersion == input.Version, a => a.PublishedContent);
// tips空是合法的虽然在业务上不存在 // tips空是合法的虽然在业务上不存在
if (targetVersionContent == null) throw new BusinessException(message: "要回滚的版本不存在"); if (targetVersionContent == null) throw new BusinessException("要回滚的版本不存在");
// tips回滚是缓存覆盖行为不考虑脏数据问题 // tips回滚是缓存覆盖行为不考虑脏数据问题
var redisKey = InterfaceForwardCommon.GetContextCacheKey(input.InterfaceCode, serviceProvider.Code); var redisKey = InterfaceForwardCommon.GetContextCacheKey(input.InterfaceCode, serviceProvider.Code);

View File

@ -26,7 +26,7 @@ public partial class InterfaceMapService
x => new { x.Id, x.DownStreamId, x.PrefixScript, x.PostfixScript, x.FreeMap }); x => new { x.Id, x.DownStreamId, x.PrefixScript, x.PostfixScript, x.FreeMap });
if (maps == null || maps.Count == 0) if (maps == null || maps.Count == 0)
{ {
throw new BusinessException(message: "映射不存在"); throw new BusinessException("映射不存在");
} }
var serviceProviderInterfaceIds = maps.Select(x => x.DownStreamId).ToList(); var serviceProviderInterfaceIds = maps.Select(x => x.DownStreamId).ToList();
@ -75,7 +75,7 @@ public partial class InterfaceMapService
x => x.DownStreamId); x => x.DownStreamId);
if (serviceProviderInterfaceIds == null || serviceProviderInterfaceIds.Count == 0) if (serviceProviderInterfaceIds == null || serviceProviderInterfaceIds.Count == 0)
{ {
throw new BusinessException(message: "映射不存在"); throw new BusinessException("映射不存在");
} }
var interfaceIds = new List<int>(serviceProviderInterfaceIds) { interfaceId }; var interfaceIds = new List<int>(serviceProviderInterfaceIds) { interfaceId };
@ -88,7 +88,7 @@ public partial class InterfaceMapService
}); });
if (interfaces == null || interfaces.Count != interfaceIds.Count) if (interfaces == null || interfaces.Count != interfaceIds.Count)
{ {
throw new BusinessException(message: "映射接口已丢失,请联系管理员"); throw new BusinessException("映射接口已丢失,请联系管理员");
} }
var res = new List<MapParameterCascadedOutput>(); var res = new List<MapParameterCascadedOutput>();
@ -141,7 +141,7 @@ public partial class InterfaceMapService
var mapIds = input.InParaMapList.Select(x => x.InterfaceMapId).ToList(); var mapIds = input.InParaMapList.Select(x => x.InterfaceMapId).ToList();
if (mapIds.Count == 0 || mapIds.Count != await _interfaceMapRepository.CountAsync(x => mapIds.Contains(x.Id))) if (mapIds.Count == 0 || mapIds.Count != await _interfaceMapRepository.CountAsync(x => mapIds.Contains(x.Id)))
{ {
throw new BusinessException(message: "非法保存"); throw new BusinessException("非法保存");
} }
var entitiesForUpdate = new List<InterfaceMapDetailEntity>(); var entitiesForUpdate = new List<InterfaceMapDetailEntity>();
@ -206,7 +206,7 @@ public partial class InterfaceMapService
if (x.IsRequired) if (x.IsRequired)
{ {
if (x.MappedParaId == null && x.FixedValue.IsNullOrEmpty()) if (x.MappedParaId == null && x.FixedValue.IsNullOrEmpty())
throw new BusinessException(message: $"{x.Alias}必填不能空"); throw new BusinessException($"{x.Alias}必填不能空");
} }
if (x.InterfaceMapDetailId == null) if (x.InterfaceMapDetailId == null)

View File

@ -52,7 +52,7 @@ public partial class InterfaceMapService : Fake.Application.ApplicationService
var systemInterfaceCode = await _interfaceRepository.GetFirstAsync(x => x.Id == input.UpStreamId, x => x.Code); var systemInterfaceCode = await _interfaceRepository.GetFirstAsync(x => x.Id == input.UpStreamId, x => x.Code);
if (systemInterfaceCode.IsNullOrEmpty()) if (systemInterfaceCode.IsNullOrEmpty())
{ {
throw new BusinessException(message: "系统接口不存在"); throw new BusinessException("系统接口不存在");
} }
var serviceProviderInterfaces = var serviceProviderInterfaces =
@ -62,7 +62,7 @@ public partial class InterfaceMapService : Fake.Application.ApplicationService
|| serviceProviderInterfaces.Count != input.DownStreamIds.Length || serviceProviderInterfaces.Count != input.DownStreamIds.Length
|| serviceProviderInterfaces.DistinctBy(x => x.ServiceProviderId).Count() != 1) || serviceProviderInterfaces.DistinctBy(x => x.ServiceProviderId).Count() != 1)
{ {
throw new BusinessException(message: "请传入合法服务商接口(同一服务商下的一个或多个接口)"); throw new BusinessException("请传入合法服务商接口(同一服务商下的一个或多个接口)");
} }
Debug.Assert(serviceProviderInterfaces.Count > 0, "interfaces.Count > 0"); Debug.Assert(serviceProviderInterfaces.Count > 0, "interfaces.Count > 0");
@ -70,7 +70,7 @@ public partial class InterfaceMapService : Fake.Application.ApplicationService
x.UpStreamId == input.UpStreamId && x.UpStreamId == input.UpStreamId &&
x.ServiceProviderId == serviceProviderInterfaces.First().ServiceProviderId)) x.ServiceProviderId == serviceProviderInterfaces.First().ServiceProviderId))
{ {
throw new BusinessException(message: "映射已存在"); throw new BusinessException("映射已存在");
} }
var maps = serviceProviderInterfaces.Select(serviceProviderInterface => new InterfaceMapEntity var maps = serviceProviderInterfaces.Select(serviceProviderInterface => new InterfaceMapEntity
@ -114,19 +114,19 @@ public partial class InterfaceMapService : Fake.Application.ApplicationService
var systemInterfaceCode = await _interfaceRepository.GetFirstAsync(x => x.Id == interfaceId, x => x.Code); var systemInterfaceCode = await _interfaceRepository.GetFirstAsync(x => x.Id == interfaceId, x => x.Code);
if (systemInterfaceCode.IsNullOrEmpty()) if (systemInterfaceCode.IsNullOrEmpty())
{ {
throw new BusinessException(message: "系统接口不存在"); throw new BusinessException("系统接口不存在");
} }
var serviceProviderCode = var serviceProviderCode =
await _serviceProviderQueries.GetFirstAsync(x => x.Id == serviceProviderId, x => x.Code); await _serviceProviderQueries.GetFirstAsync(x => x.Id == serviceProviderId, x => x.Code);
if (serviceProviderCode.IsNullOrEmpty()) if (serviceProviderCode.IsNullOrEmpty())
{ {
throw new BusinessException(message: "服务商不存在!"); throw new BusinessException("服务商不存在!");
} }
var mapIds = await _interfaceMapRepository.GetListAsync(x => var mapIds = await _interfaceMapRepository.GetListAsync(x =>
x.UpStreamId == interfaceId && x.ServiceProviderId == serviceProviderId, x => x.Id); x.UpStreamId == interfaceId && x.ServiceProviderId == serviceProviderId, x => x.Id);
if (mapIds == null || mapIds.Count == 0) throw new BusinessException(message: "映射不存在"); if (mapIds == null || mapIds.Count == 0) throw new BusinessException("映射不存在");
using var ts = TransacationHelper.GetReadCommitted(); using var ts = TransacationHelper.GetReadCommitted();
foreach (var mapId in mapIds) foreach (var mapId in mapIds)

View File

@ -71,7 +71,7 @@ public class FixedParameterService : ApplicationService, IAuditingEnabled
// 校验服务商是否存在 // 校验服务商是否存在
if (!await _serviceProviderRepository.IsAnyAsync(x => x.Id == input.ServiceProviderId)) if (!await _serviceProviderRepository.IsAnyAsync(x => x.Id == input.ServiceProviderId))
{ {
throw new BusinessException(message: "服务商不存在"); throw new BusinessException("服务商不存在");
} }
// 校验账户字段是否合法 // 校验账户字段是否合法
@ -107,7 +107,7 @@ public class FixedParameterService : ApplicationService, IAuditingEnabled
input.InterfaceId == x.InterfaceId && input.InterfaceId == x.InterfaceId &&
x.FieldName == item.FieldName && x.Id != item.Id)) x.FieldName == item.FieldName && x.Id != item.Id))
{ {
throw new BusinessException(message: $"参数{item.FieldName}已存在"); throw new BusinessException($"参数{item.FieldName}已存在");
} }
} }
else else
@ -116,7 +116,7 @@ public class FixedParameterService : ApplicationService, IAuditingEnabled
input.ServiceProviderId == x.ServiceProviderId && input.ServiceProviderId == x.ServiceProviderId &&
x.FieldName == item.FieldName && x.Id != item.Id)) x.FieldName == item.FieldName && x.Id != item.Id))
{ {
throw new BusinessException(message: $"参数{item.FieldName}已存在"); throw new BusinessException($"参数{item.FieldName}已存在");
} }
} }
@ -148,7 +148,7 @@ public class FixedParameterService : ApplicationService, IAuditingEnabled
input.ServiceProviderId == x.ServiceProviderId && x.FieldName == item.FieldName)) input.ServiceProviderId == x.ServiceProviderId && x.FieldName == item.FieldName))
) )
{ {
throw new BusinessException(message: $"参数{item.FieldName}已存在"); throw new BusinessException($"参数{item.FieldName}已存在");
} }
var entity = ObjectMapper.Map<FixedParameterItem, FixedParameterEntity>(item); var entity = ObjectMapper.Map<FixedParameterItem, FixedParameterEntity>(item);
@ -190,7 +190,7 @@ public class FixedParameterService : ApplicationService, IAuditingEnabled
if (accountFields.All(x => x.Value != fieldName)) if (accountFields.All(x => x.Value != fieldName))
{ {
throw new BusinessException(message: $"账户中不存在字段:{fieldName}"); throw new BusinessException($"账户中不存在字段:{fieldName}");
} }
} }
} }

View File

@ -1,6 +1,5 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using InterfaceForward.Application.Helpers; using InterfaceForward.Application.Helpers;
using InterfaceForward.Domain.Shared.Dtos;
using InterfaceForward.Domain.Shared.Enum; using InterfaceForward.Domain.Shared.Enum;
using InterfaceForward.Repositories; using InterfaceForward.Repositories;
using InterfaceForward.Repositories.Parameter.Entities; using InterfaceForward.Repositories.Parameter.Entities;

View File

@ -64,7 +64,7 @@ public class ParameterService : ApplicationService
{ {
if (!await _interfaceRepository.IsAnyAsync(x => x.Id == input.InterfaceId)) if (!await _interfaceRepository.IsAnyAsync(x => x.Id == input.InterfaceId))
{ {
throw new BusinessException(message: "接口不存在"); throw new BusinessException("接口不存在");
} }
return await MaintainParametersAsync(input.ParameterList, input.InterfaceId, input.IsInPara); return await MaintainParametersAsync(input.ParameterList, input.InterfaceId, input.IsInPara);
@ -81,7 +81,7 @@ public class ParameterService : ApplicationService
{ {
if (!await _interfaceRepository.IsAnyAsync(x => x.Id == input.InterfaceId)) if (!await _interfaceRepository.IsAnyAsync(x => x.Id == input.InterfaceId))
{ {
throw new BusinessException(message: "接口不存在"); throw new BusinessException("接口不存在");
} }
var entities = input.ParameterSortList.Select(x => var entities = input.ParameterSortList.Select(x =>
@ -131,7 +131,7 @@ public class ParameterService : ApplicationService
case ParameterParseTypeEnum.Xml: case ParameterParseTypeEnum.Xml:
return ParseXml(input.ParameterContent); return ParseXml(input.ParameterContent);
default: default:
throw new BusinessException(message: "暂不支持该格式解析"); throw new BusinessException("暂不支持该格式解析");
} }
} }
@ -153,7 +153,7 @@ public class ParameterService : ApplicationService
} }
catch (Exception) catch (Exception)
{ {
throw new BusinessException(message: "无法正常解析请传入合法xml"); throw new BusinessException("无法正常解析请传入合法xml");
} }
return ParseJson(json); return ParseJson(json);
@ -181,7 +181,7 @@ public class ParameterService : ApplicationService
} }
catch (Exception) catch (Exception)
{ {
throw new BusinessException(message: "无法正常解析请传入合法json"); throw new BusinessException("无法正常解析请传入合法json");
} }
Debug.Assert(jtoken != null, nameof(jtoken) + " != null"); Debug.Assert(jtoken != null, nameof(jtoken) + " != null");
@ -563,22 +563,22 @@ public class ParameterService : ApplicationService
// 校验唯一性 // 校验唯一性
if (!set.Add(cur.Alias)) if (!set.Add(cur.Alias))
throw new BusinessException(message: $"不能存在相同路径的参数({cur.Name}"); throw new BusinessException($"不能存在相同路径的参数({cur.Name}");
if (cur.Type == ParameterType.Object) if (cur.Type == ParameterType.Object)
{ {
if (list.All(x => x.PId != cur.Id)) if (list.All(x => x.PId != cur.Id))
throw new BusinessException(message: $"非法结构,空对象({cur.Name}"); throw new BusinessException($"非法结构,空对象({cur.Name}");
} }
else if (cur.Type == ParameterType.Array) else if (cur.Type == ParameterType.Array)
{ {
if (list.Count(x => x.PId == cur.Id) != 1) if (list.Count(x => x.PId == cur.Id) != 1)
throw new BusinessException(message: $"非法结构,数组元素(数组的子级)只能是一个对象或基本类型({cur.Name}"); throw new BusinessException($"非法结构,数组元素(数组的子级)只能是一个对象或基本类型({cur.Name}");
} }
else else
{ {
if (list.Any(x => x.PId == cur.Id)) if (list.Any(x => x.PId == cur.Id))
throw new BusinessException(message: $"非法结构,基本类型不能拥有下级({cur.Name}"); throw new BusinessException($"非法结构,基本类型不能拥有下级({cur.Name}");
continue; continue;
} }

View File

@ -4,7 +4,6 @@ using System.Text.RegularExpressions;
using InterfaceForward.Application.Contracts.Dtos.ScriptAssistant; using InterfaceForward.Application.Contracts.Dtos.ScriptAssistant;
using InterfaceForward.Application.Contracts.ForwardCore; using InterfaceForward.Application.Contracts.ForwardCore;
using InterfaceForward.Application.ForwardCore; using InterfaceForward.Application.ForwardCore;
using InterfaceForward.Domain.Shared.Dtos;
using InterfaceForward.Domain.Shared.Enum; using InterfaceForward.Domain.Shared.Enum;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
@ -27,7 +26,7 @@ public class ScriptAssistantService : ApplicationService
var requirement = input.Requirement.Trim(); var requirement = input.Requirement.Trim();
if (requirement.IsNullOrWhiteSpace()) if (requirement.IsNullOrWhiteSpace())
{ {
throw new BusinessException(message: "请输入脚本需求"); throw new BusinessException("请输入脚本需求");
} }
var script = GenerateTemplateScript(input); var script = GenerateTemplateScript(input);

View File

@ -46,7 +46,7 @@ public class ServiceProviderAccountService : ApplicationService
{ {
var accountInfo = await _serviceProviderAccountRepository.GetSingleAccountAsync(accountId); var accountInfo = await _serviceProviderAccountRepository.GetSingleAccountAsync(accountId);
if (accountInfo == null) throw new BusinessException(message: "账户不存在!"); if (accountInfo == null) throw new BusinessException("账户不存在!");
var res = new SaveServiceProviderAccountOutput(); var res = new SaveServiceProviderAccountOutput();
res.ServiceProviderId = accountInfo.ServiceProviderId; res.ServiceProviderId = accountInfo.ServiceProviderId;
res.MainBodyId = accountInfo.MainBodyId; res.MainBodyId = accountInfo.MainBodyId;
@ -91,14 +91,14 @@ public class ServiceProviderAccountService : ApplicationService
var serviceProvider = await _serviceProviderRepository.GetFirstAsync(x => x.Id == input.ServiceProviderId); var serviceProvider = await _serviceProviderRepository.GetFirstAsync(x => x.Id == input.ServiceProviderId);
if (serviceProvider == null) if (serviceProvider == null)
{ {
throw new BusinessException(message: "服务商不存在!"); throw new BusinessException("服务商不存在!");
} }
if (await _serviceProviderAccountRepository.IsAnyAsync(x => if (await _serviceProviderAccountRepository.IsAnyAsync(x =>
x.ServiceProviderId == input.ServiceProviderId && x.AppId == input.AppId && x.ServiceProviderId == input.ServiceProviderId && x.AppId == input.AppId &&
(input.OptionType == OptionType. || x.Id != input.AccountId))) (input.OptionType == OptionType. || x.Id != input.AccountId)))
{ {
throw new BusinessException(message: $"服务商:{serviceProvider.Name} 下已存在此应用的账户!"); throw new BusinessException($"服务商:{serviceProvider.Name} 下已存在此应用的账户!");
} }
#endregion #endregion
@ -191,7 +191,7 @@ public class ServiceProviderAccountService : ApplicationService
/// <param name="pageSize">页大小</param> /// <param name="pageSize">页大小</param>
/// <returns></returns> /// <returns></returns>
[HttpGet("ServiceProviderAccount/GetAccountPageList")] [HttpGet("ServiceProviderAccount/GetAccountPageList")]
public async Task<PagedResult<Dictionary<string, object?>>> GetAccountPageListAsync( public async Task<PagedResult<Dictionary<string, object>>> GetAccountPageListAsync(
[Required] int serviceProviderId [Required] int serviceProviderId
, int pageIndex = 1 , int pageIndex = 1
, int pageSize = 50) , int pageSize = 50)
@ -274,7 +274,7 @@ public class ServiceProviderAccountService : ApplicationService
var serviceProvider = await _serviceProviderRepository.GetFirstAsync(x => x.Id == serviceProviderId); var serviceProvider = await _serviceProviderRepository.GetFirstAsync(x => x.Id == serviceProviderId);
if (serviceProvider == null) if (serviceProvider == null)
{ {
throw new BusinessException(message: "服务商不存在!"); throw new BusinessException("服务商不存在!");
} }
#endregion #endregion

View File

@ -46,7 +46,7 @@ public class ServiceProviderAuthService : ApplicationService
x.Id == input.ServiceProviderId); x.Id == input.ServiceProviderId);
if (serviceProvider == null) if (serviceProvider == null)
{ {
throw new BusinessException(message: "服务商不存在"); throw new BusinessException("服务商不存在");
} }
serviceProvider.AuthInterfaceCode = input.InterfaceCode; serviceProvider.AuthInterfaceCode = input.InterfaceCode;
@ -125,7 +125,7 @@ public class ServiceProviderAuthService : ApplicationService
x.Id == input.ServiceProviderId); x.Id == input.ServiceProviderId);
if (serviceProvider == null) if (serviceProvider == null)
{ {
throw new BusinessException(message: "服务商不存在"); throw new BusinessException("服务商不存在");
} }
var authConfigsEntities = BuildServiceProviderAuthConfigEntities(input); var authConfigsEntities = BuildServiceProviderAuthConfigEntities(input);

View File

@ -85,7 +85,7 @@ public class ServiceProviderImportExportService : ApplicationService
var context = (await _sqlSugarClientProvider.GetDbContextAsync(default)).SqlSugarClient; var context = (await _sqlSugarClientProvider.GetDbContextAsync(default)).SqlSugarClient;
if (await context.Queryable<ServiceProviderEntity>() if (await context.Queryable<ServiceProviderEntity>()
.AnyAsync(x => x.Name == input.Name && x.Code == input.Code)) .AnyAsync(x => x.Name == input.Name && x.Code == input.Code))
throw new BusinessException(message: "服务商Name或Code已经存在"); throw new BusinessException("服务商Name或Code已经存在");
var data = await GetServiceProviderExportModel(input.Id ?? 0); var data = await GetServiceProviderExportModel(input.Id ?? 0);
data.ServiceProviderEntity.Name = input.Name; data.ServiceProviderEntity.Name = input.Name;
@ -121,7 +121,7 @@ public class ServiceProviderImportExportService : ApplicationService
var context = (await _sqlSugarClientProvider.GetDbContextAsync(default)).SqlSugarClient; var context = (await _sqlSugarClientProvider.GetDbContextAsync(default)).SqlSugarClient;
if (!await context.Queryable<ServiceProviderEntity>().AnyAsync(x => x.Id == serviceProviderId)) if (!await context.Queryable<ServiceProviderEntity>().AnyAsync(x => x.Id == serviceProviderId))
throw new BusinessException(message: "服务商不存在"); throw new BusinessException("服务商不存在");
var data = new ImportExportModel(); var data = new ImportExportModel();
// 服务商 // 服务商

View File

@ -84,7 +84,7 @@ public class ServiceProviderService : ApplicationService
if (entity == null) if (entity == null)
{ {
throw new BusinessException(message: "服务商不存在"); throw new BusinessException("服务商不存在");
} }
if (entity.FlowCode.IsNullOrWhiteSpace()) entity.FlowCode = nameof(DefaultForwardFlow); if (entity.FlowCode.IsNullOrWhiteSpace()) entity.FlowCode = nameof(DefaultForwardFlow);
@ -102,9 +102,9 @@ public class ServiceProviderService : ApplicationService
public async Task AddAsync(ServiceProviderInput input) public async Task AddAsync(ServiceProviderInput input)
{ {
if (await _serviceProviderRepository.IsAnyAsync(x => x.Name == input.Name)) if (await _serviceProviderRepository.IsAnyAsync(x => x.Name == input.Name))
throw new BusinessException(message: $"服务商名称:{input.Name} 已存在"); throw new BusinessException($"服务商名称:{input.Name} 已存在");
if (await _serviceProviderRepository.IsAnyAsync(x => x.Code == input.Code)) if (await _serviceProviderRepository.IsAnyAsync(x => x.Code == input.Code))
throw new BusinessException(message: $"服务商代码:{input.Code} 已存在"); throw new BusinessException($"服务商代码:{input.Code} 已存在");
var entity = ObjectMapper.Map<ServiceProviderInput, ServiceProviderEntity>(input); var entity = ObjectMapper.Map<ServiceProviderInput, ServiceProviderEntity>(input);
@ -120,9 +120,9 @@ public class ServiceProviderService : ApplicationService
public async Task<bool> UpdateAsync(ServiceProviderInput input) public async Task<bool> UpdateAsync(ServiceProviderInput input)
{ {
if (await _serviceProviderRepository.IsAnyAsync(x => x.Name == input.Name && x.Id != input.Id)) if (await _serviceProviderRepository.IsAnyAsync(x => x.Name == input.Name && x.Id != input.Id))
throw new BusinessException(message: $"服务商名称:{input.Name} 已存在"); throw new BusinessException($"服务商名称:{input.Name} 已存在");
if (await _serviceProviderRepository.IsAnyAsync(x => x.Code == input.Code && x.Id != input.Id)) if (await _serviceProviderRepository.IsAnyAsync(x => x.Code == input.Code && x.Id != input.Id))
throw new BusinessException(message: $"服务商代码:{input.Code} 已存在"); throw new BusinessException($"服务商代码:{input.Code} 已存在");
var entity = ObjectMapper.Map<ServiceProviderInput, ServiceProviderEntity>(input); var entity = ObjectMapper.Map<ServiceProviderInput, ServiceProviderEntity>(input);
return await _serviceProviderRepository.UpdateColumnAsync(entity, x => new return await _serviceProviderRepository.UpdateColumnAsync(entity, x => new
@ -145,7 +145,7 @@ public class ServiceProviderService : ApplicationService
{ {
if (await _interfaceRepository.IsAnyAsync(x => ids.Contains(x.ServiceProviderId))) if (await _interfaceRepository.IsAnyAsync(x => ids.Contains(x.ServiceProviderId)))
{ {
throw new BusinessException(message: "请勿删除存在接口的服务商"); throw new BusinessException("请勿删除存在接口的服务商");
} }
await _serviceProviderRepository.SoftDeleteAsync(x => ids.Contains(x.Id)); await _serviceProviderRepository.SoftDeleteAsync(x => ids.Contains(x.Id));

View File

@ -0,0 +1,11 @@
using Newtonsoft.Json.Converters;
namespace InterfaceForward.Domain.Shared;
public class CustomDateTimeConverter: IsoDateTimeConverter
{
public CustomDateTimeConverter(string dateTimeFormat = "yyyy-MM-dd HH:mm:ss")
{
DateTimeFormat = dateTimeFormat;
}
}

View File

@ -1,32 +0,0 @@
using Newtonsoft.Json;
namespace InterfaceForward.Domain.Shared;
public class DateTimeJsonConverter: JsonConverter
{
private readonly string _format;
public DateTimeJsonConverter(string format = "yyyy-MM-dd HH:mm:ss") => this._format = format;
public override bool CanConvert(Type objectType)
{
return objectType == typeof (DateTime) || objectType == typeof (DateTime?);
}
public override object? ReadJson(
JsonReader reader,
Type objectType,
object? existingValue,
JsonSerializer serializer)
{
if (reader.Value == null || string.IsNullOrEmpty(reader.Value.ToString()))
return (object) null;
DateTime result;
return DateTime.TryParse(reader.Value.ToString(), out result) ? (object) result : (object) new DateTime();
}
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
{
writer.WriteValue(((DateTime) value).ToString(this._format));
}
}

View File

@ -0,0 +1,28 @@
namespace InterfaceForward.Domain.Shared.Dtos;
public class PagedResult<T>(long totalCount, List<T> items) : ListResponse<T>(items)
{
/*
* total count是longint
* in fakelong类型自增idguid作为主键int id
*/
/// <summary>
/// 总条数
/// </summary>
public long TotalCount { get; set; } = totalCount;
public PagedResult() : this(0, [])
{
}
}
/// <summary>
/// 列表响应结果模版
/// </summary>
/// <param name="items"></param>
/// <typeparam name="T"></typeparam>
public class ListResponse<T>(List<T> items)
{
public List<T> Items { get; set; } = items;
}

View File

@ -1,7 +1,6 @@
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Fake; using Fake.Domain.Exceptions;
using Fake.Application;
using InterfaceForward.Domain.Shared.Dtos; using InterfaceForward.Domain.Shared.Dtos;
using InterfaceForward.Domain.Shared.Enum; using InterfaceForward.Domain.Shared.Enum;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
@ -291,7 +290,7 @@ public static class JsonHelper
if (item.Type == ParameterType.Array) continue; if (item.Type == ParameterType.Array) continue;
var len = GetLength(jobject, item, idxList); var len = GetLength(jobject, item, idxList);
if (len == 0) continue; if (len == 0) continue;
if (res != 0 && res != len) throw new BusinessException(message: $"组成元素数量不对等,请检查{node.Alias}的组成"); if (res != 0 && res != len) throw new DomainException($"组成元素数量不对等,请检查{node.Alias}的组成");
res = Math.Max(len, res); res = Math.Max(len, res);
} }
@ -322,13 +321,13 @@ public static class JsonHelper
if (string.IsNullOrEmpty(item.MapAlias)) if (string.IsNullOrEmpty(item.MapAlias))
{ {
if (item.IsRequired) if (item.IsRequired)
throw new BusinessException(message: $"必填参数{item.Name}{item.Alias})必须建立映射或传入固定值"); throw new DomainException($"必填参数{item.Name}{item.Alias})必须建立映射或传入固定值");
return JValue.CreateNull(); return JValue.CreateNull();
} }
if (item.Alias.Split("[*]").Length != item.MapAlias.Split("[*]").Length) if (item.Alias.Split("[*]").Length != item.MapAlias.Split("[*]").Length)
{ {
throw new BusinessException(message: $"{item.Alias}<-{item.MapAlias}是不对等映射"); throw new DomainException($"{item.Alias}<-{item.MapAlias}是不对等映射");
} }
string path = BuildPath(item.MapAlias, idxList); string path = BuildPath(item.MapAlias, idxList);
@ -526,13 +525,13 @@ public static class JsonHelper
if (string.IsNullOrEmpty(item.MapAlias)) if (string.IsNullOrEmpty(item.MapAlias))
{ {
if (item.IsRequired) if (item.IsRequired)
throw new BusinessException(message: $"必填参数{item.Name}{item.Alias})必须建立映射或传入固定值"); throw new DomainException($"必填参数{item.Name}{item.Alias})必须建立映射或传入固定值");
return JValue.CreateNull(); return JValue.CreateNull();
} }
if (item.Alias.Split("[*]").Length != item.MapAlias.Split("[*]").Length) if (item.Alias.Split("[*]").Length != item.MapAlias.Split("[*]").Length)
{ {
throw new BusinessException(message: $"{item.Alias}<-{item.MapAlias}是不对等映射"); throw new DomainException($"{item.Alias}<-{item.MapAlias}是不对等映射");
} }
string path = BuildPathV2(item.MapAlias, arrIndex,parentArrItemPath); string path = BuildPathV2(item.MapAlias, arrIndex,parentArrItemPath);
@ -544,7 +543,7 @@ public static class JsonHelper
private static JToken ValidateValue(ParameterNode node, JToken val) private static JToken ValidateValue(ParameterNode node, JToken val)
{ {
if (node.IsRequired && val.Type is JTokenType.Null) if (node.IsRequired && val.Type is JTokenType.Null)
throw new BusinessException(message: $"服务商参数{node.Name}是必填的(系统{node.MapAlias}->服务商{node.Alias}"); throw new DomainException($"服务商参数{node.Name}是必填的(系统{node.MapAlias}->服务商{node.Alias}");
if (val.Type is JTokenType.Null) return val; if (val.Type is JTokenType.Null) return val;
@ -585,8 +584,7 @@ public static class JsonHelper
} }
if (!equal) if (!equal)
throw new BusinessException(message: throw new DomainException($"服务商参数{node.Name}{node.Alias})期望的类型是{node.Type},但实际分配的是{val.Type}类型的{val}{val.Path}");
$"服务商参数{node.Name}{node.Alias})期望的类型是{node.Type},但实际分配的是{val.Type}类型的{val}{val.Path}");
return val; return val;
} }

View File

@ -11,6 +11,6 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Fake.Serilog" Version="$(FakePackageVersion)" /> <PackageReference Include="Fake.Serilog" Version="$(FakePackageVersion)" />
<PackageReference Include="Fake.DomainDrivenDesign" Version="$(FakePackageVersion)" /> <PackageReference Include="Fake.Ddd.Domain" Version="$(FakePackageVersion)" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -3,7 +3,7 @@ using Fake.Modularity;
namespace InterfaceForward.Domain.Shared namespace InterfaceForward.Domain.Shared
{ {
[DependsOn(typeof(FakeDomainDrivenDesignModule))] [DependsOn(typeof(FakeDddDomainModule))]
public class InterfaceForwardDomainSharedModule : FakeModule public class InterfaceForwardDomainSharedModule : FakeModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)

View File

@ -1,26 +0,0 @@
using Newtonsoft.Json;
namespace InterfaceForward.Domain.Shared;
public class LongJsonConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return objectType == typeof (long) || objectType == typeof (long?);
}
public override object? ReadJson(
JsonReader reader,
Type objectType,
object? existingValue,
JsonSerializer serializer)
{
long result;
return reader.Value == null || string.IsNullOrEmpty(reader.Value.ToString()) ? (object) null : (long.TryParse(reader.Value.ToString(), out result) ? (object) result : (object) new DateTime());
}
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
{
writer.WriteValue(((long) value).ToString());
}
}

View File

@ -1,19 +0,0 @@
namespace InterfaceForward.Domain.Shared.Options;
public class FeiShuNoticeOptions
{
/// <summary>
/// 飞书通知webhook
/// </summary>
public string Webhook { get; set; }
/// <summary>
/// 消息标题前缀
/// </summary>
public string TitlePrefix { get; set; }
/// <summary>
/// 超时时间 秒
/// </summary>
public int Timeout { get; set; } = 20;
}

View File

@ -1,4 +1,5 @@
using System.Linq.Expressions; using System.Linq.Expressions;
using Fake;
using Fake.Domain.Entities; using Fake.Domain.Entities;
using Fake.DomainDrivenDesign.Repositories.SqlSugarCore; using Fake.DomainDrivenDesign.Repositories.SqlSugarCore;
@ -81,8 +82,7 @@ public class BasicRepository<T> : SqlSugarRepository<InterfaceForwardDbContext,
public async Task<bool> SoftDeleteAsync(Expression<Func<T, bool>>? where) public async Task<bool> SoftDeleteAsync(Expression<Func<T, bool>>? where)
{ {
if (!typeof(T).IsAssignableTo<ISoftDelete>()) if (!typeof(T).IsAssignableTo<ISoftDelete>())
throw new BusinessException( throw new FakeException($"实体没有实现{nameof(ISoftDelete)}不能调用{nameof(SoftDeleteAsync)}");
message: $"实体没有实现{nameof(ISoftDelete)}不能调用{nameof(SoftDeleteAsync)}");
// tips: required where // tips: required where
if (where == default) return false; if (where == default) return false;

View File

@ -1,8 +1,7 @@
// Global using directives // Global using directives
global using Fake.Application;
global using Fake.Application.Dtos;
global using Fake.DependencyInjection; global using Fake.DependencyInjection;
global using Fake.Domain.Entities.Auditing; global using Fake.Domain.Entities.Auditing;
global using Fake.DomainDrivenDesign; global using Fake.DomainDrivenDesign;
global using InterfaceForward.Domain.Shared.Dtos;
global using SqlSugar; global using SqlSugar;

View File

@ -1,5 +1,4 @@
using InterfaceForward.Application.Contracts.Dtos.Interface; using InterfaceForward.Application.Contracts.Dtos.Interface;
using InterfaceForward.Domain.Shared.Dtos;
using InterfaceForward.Repositories.Interface.Entitys; using InterfaceForward.Repositories.Interface.Entitys;
using InterfaceForward.Repositories.Interface.ValueObjects; using InterfaceForward.Repositories.Interface.ValueObjects;
using InterfaceForward.Repositories.Parameter.VO; using InterfaceForward.Repositories.Parameter.VO;

View File

@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using InterfaceForward.Domain.Shared.Dtos;
namespace InterfaceForward.Repositories.Interface.ValueObjects; namespace InterfaceForward.Repositories.Interface.ValueObjects;

View File

@ -1,5 +1,4 @@
using InterfaceForward.Domain.Shared.Dtos; using InterfaceForward.Domain.Shared.Enum;
using InterfaceForward.Domain.Shared.Enum;
using InterfaceForward.Repositories.Parameter.VO; using InterfaceForward.Repositories.Parameter.VO;
namespace InterfaceForward.Repositories.Interface.ValueObjects; namespace InterfaceForward.Repositories.Interface.ValueObjects;

View File

@ -1,6 +1,4 @@
using InterfaceForward.Domain.Shared.Dtos; namespace InterfaceForward.Repositories.Interface.ValueObjects;
namespace InterfaceForward.Repositories.Interface.ValueObjects;
/// <summary> /// <summary>
/// 接口分页 /// 接口分页

View File

@ -1,6 +1,4 @@
using InterfaceForward.Domain.Shared.Dtos; namespace InterfaceForward.Repositories.Interface.ValueObjects;
namespace InterfaceForward.Repositories.Interface.ValueObjects;
/// <summary> /// <summary>
/// 服务商接口分页 /// 服务商接口分页

View File

@ -1,4 +1,4 @@
using InterfaceForward.Domain.Shared.Dtos; using Fake.Domain.Exceptions;
using InterfaceForward.Domain.Shared.Enum; using InterfaceForward.Domain.Shared.Enum;
using InterfaceForward.Domain.Shared.Helpers; using InterfaceForward.Domain.Shared.Helpers;
using InterfaceForward.Repositories.App.Entitys; using InterfaceForward.Repositories.App.Entitys;
@ -163,12 +163,12 @@ ORDER BY `b`.`Sort` ASC").ToListAsync();
.Where(x => x.UpStreamCode == systemInterface.Code && x.ServiceProviderId == serviceProvider.Id) .Where(x => x.UpStreamCode == systemInterface.Code && x.ServiceProviderId == serviceProvider.Id)
.Select(x => new { x.Id, x.DownStreamCode, x.PrefixScript, x.PostfixScript }) .Select(x => new { x.Id, x.DownStreamCode, x.PrefixScript, x.PostfixScript })
.ToArrayAsync(); .ToArrayAsync();
if (maps == null || maps.Length == 0) throw new BusinessException(message: "映射不存在"); if (maps == null || maps.Length == 0) throw new EntityNotFoundException("映射不存在");
var downStreamIds = maps.Select(x => x.DownStreamCode).ToArray(); var downStreamIds = maps.Select(x => x.DownStreamCode).ToArray();
var targetInterfaceList = await GetInterfaceByCodesAsync(downStreamIds); var targetInterfaceList = await GetInterfaceByCodesAsync(downStreamIds);
if (targetInterfaceList == null || targetInterfaceList.Count != downStreamIds.Length) if (targetInterfaceList == null || targetInterfaceList.Count != downStreamIds.Length)
throw new BusinessException(message: "服务商一个或多个接口不存在"); throw new EntityNotFoundException("服务商一个或多个接口不存在");
var mapIds = maps.Select(x => x.Id).ToList(); var mapIds = maps.Select(x => x.Id).ToList();
var context = new ForwardCoreContextCache var context = new ForwardCoreContextCache

View File

@ -2,6 +2,7 @@
using InterfaceForward.Repositories.Log.ES; using InterfaceForward.Repositories.Log.ES;
using Nest; using Nest;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace InterfaceForward.Repositories.Log.Entitys; namespace InterfaceForward.Repositories.Log.Entitys;
@ -16,7 +17,7 @@ public class LogIndex : IdBaseIndex
///<summary> ///<summary>
/// 请求时间 /// 请求时间
///</summary> ///</summary>
[JsonConverter(typeof(DateTimeJsonConverter), "yyyy-MM-dd HH:mm:ss fff")] [JsonConverter(typeof(CustomDateTimeConverter), "yyyy-MM-dd HH:mm:ss fff")]
public DateTime RequestTime { get; set; } public DateTime RequestTime { get; set; }
///<summary> ///<summary>

View File

@ -1,5 +1,4 @@
using InterfaceForward.Domain.Shared.Dtos; using InterfaceForward.Repositories.Log.Entitys;
using InterfaceForward.Repositories.Log.Entitys;
using InterfaceForward.Repositories.Log.ES; using InterfaceForward.Repositories.Log.ES;
using InterfaceForward.Repositories.Log.ValueObjects; using InterfaceForward.Repositories.Log.ValueObjects;
using Nest; using Nest;

View File

@ -1,5 +1,4 @@
using InterfaceForward.Domain.Shared.Dtos; using InterfaceForward.Domain.Shared.Enum;
using InterfaceForward.Domain.Shared.Enum;
using InterfaceForward.Domain.Shared.Helpers; using InterfaceForward.Domain.Shared.Helpers;
using InterfaceForward.Repositories.Log.Entitys; using InterfaceForward.Repositories.Log.Entitys;
using InterfaceForward.Repositories.Log.ES; using InterfaceForward.Repositories.Log.ES;

View File

@ -1,5 +1,4 @@
using InterfaceForward.Domain.Shared.Dtos; using InterfaceForward.Domain.Shared.Enum;
using InterfaceForward.Domain.Shared.Enum;
namespace InterfaceForward.Repositories.Log.ValueObjects; namespace InterfaceForward.Repositories.Log.ValueObjects;

View File

@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using InterfaceForward.Domain.Shared.Dtos;
using InterfaceForward.Domain.Shared.Enum; using InterfaceForward.Domain.Shared.Enum;
namespace InterfaceForward.Repositories.Log.ValueObjects; namespace InterfaceForward.Repositories.Log.ValueObjects;

View File

@ -1,5 +1,4 @@
using InterfaceForward.Domain.Shared.Dtos; using InterfaceForward.Repositories.ServiceProvider.Entitys;
using InterfaceForward.Repositories.ServiceProvider.Entitys;
using InterfaceForward.Repositories.ServiceProvider.ValueObjects; using InterfaceForward.Repositories.ServiceProvider.ValueObjects;
namespace InterfaceForward.Repositories.ServiceProvider.Services namespace InterfaceForward.Repositories.ServiceProvider.Services

View File

@ -1,5 +1,4 @@
using InterfaceForward.Domain.Shared.Dtos; using InterfaceForward.Repositories.App.Entitys;
using InterfaceForward.Repositories.App.Entitys;
using InterfaceForward.Repositories.ServiceProvider.Entitys; using InterfaceForward.Repositories.ServiceProvider.Entitys;
using InterfaceForward.Repositories.ServiceProvider.ValueObjects; using InterfaceForward.Repositories.ServiceProvider.ValueObjects;

View File

@ -1,5 +1,4 @@
using InterfaceForward.Domain.Shared.Dtos; using InterfaceForward.Domain.Shared.Enum;
using InterfaceForward.Domain.Shared.Enum;
using InterfaceForward.Repositories.Interface.Entitys; using InterfaceForward.Repositories.Interface.Entitys;
using InterfaceForward.Repositories.ServiceProvider.Entitys; using InterfaceForward.Repositories.ServiceProvider.Entitys;
using InterfaceForward.Repositories.ServiceProvider.ValueObjects; using InterfaceForward.Repositories.ServiceProvider.ValueObjects;

View File

@ -1,5 +1,4 @@
using InterfaceForward.Domain.Shared.Dtos; using InterfaceForward.Domain.Shared.Enum;
using InterfaceForward.Domain.Shared.Enum;
namespace InterfaceForward.Repositories.ServiceProvider.ValueObjects; namespace InterfaceForward.Repositories.ServiceProvider.ValueObjects;