This commit is contained in:
xiaolipro 2025-07-17 11:07:39 +08:00
parent a8b2c38b3b
commit cac23b6569
8 changed files with 25 additions and 22 deletions

View File

@ -10,7 +10,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\InterfaceForward.Application\InterfaceForward.Application.csproj" /> <ProjectReference Include="..\InterfaceForward.Application\InterfaceForward.Application.csproj" />
<ProjectReference Include="..\InterfaceForward.ServiceDefaults\InterfaceForward.ServiceDefaults.csproj"/> <ProjectReference Include="..\InterfaceForward.ServiceDefaults\InterfaceForward.ServiceDefaults.csproj"/>
<PackageReference Include="Fake.Autofac" Version="8.0.0-preview.5" /> <PackageReference Include="Fake.Autofac" Version="8.0.0-preview.9" />
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" /> <PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="10.0.0" /> <PackageReference Include="Serilog.Sinks.Elasticsearch" Version="10.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" /> <PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />

View File

@ -17,9 +17,9 @@
<PackageReference Include="DiffPlex" Version="1.7.2" /> <PackageReference Include="DiffPlex" Version="1.7.2" />
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.14.1" /> <PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.14.1" />
<PackageReference Include="DotNetCore.Natasha.CSharp" Version="5.2.2.1"/> <PackageReference Include="DotNetCore.Natasha.CSharp" Version="5.2.2.1"/>
<PackageReference Include="Fake.AspNetCore" Version="8.0.0-preview.5" /> <PackageReference Include="Fake.AspNetCore" Version="8.0.0-preview.9" />
<PackageReference Include="Fake.EventBus.RabbitMQ" Version="8.0.0-preview.6" /> <PackageReference Include="Fake.EventBus.RabbitMQ" Version="8.0.0-preview.9" />
<PackageReference Include="Fake.ObjectMapping.AutoMapper" Version="8.0.0-preview.5" /> <PackageReference Include="Fake.ObjectMapping.AutoMapper" Version="8.0.0-preview.9" />
<PackageReference Include="FreeRedis" Version="1.3.6" /> <PackageReference Include="FreeRedis" Version="1.3.6" />
</ItemGroup> </ItemGroup>

View File

@ -33,7 +33,7 @@ public class ServiceProviderInterfaceService : ApplicationService
private IBasicRepository<InterfaceMapEntity> InterfaceMapRepository => private IBasicRepository<InterfaceMapEntity> InterfaceMapRepository =>
LazyServiceProvider.GetRequiredService<IBasicRepository<InterfaceMapEntity>>(); LazyServiceProvider.GetRequiredService<IBasicRepository<InterfaceMapEntity>>();
private InterfaceCategoryService InterfaceCategoryService => private InterfaceCategoryService InterfaceCategoryService =>
LazyServiceProvider.GetRequiredService<InterfaceCategoryService>(); LazyServiceProvider.GetRequiredService<InterfaceCategoryService>();
@ -48,12 +48,12 @@ public class ServiceProviderInterfaceService : ApplicationService
GetServiceProviderInterfaceTreeListAsync(ServiceProviderInterfaceTreeListInputObjectValue input) GetServiceProviderInterfaceTreeListAsync(ServiceProviderInterfaceTreeListInputObjectValue input)
{ {
var res = await InterfaceRepository.GetServiceProviderInterfaceListAsync(input); var res = await InterfaceRepository.GetServiceProviderInterfaceListAsync(input);
var tree = await InterfaceCategoryService.GetCategoryTree(false, res); var tree = await InterfaceCategoryService.GetCategoryTree(false, res);
return tree; return tree;
} }
/// <summary> /// <summary>
/// 服务商接口分页列表 /// 服务商接口分页列表
/// </summary> /// </summary>
@ -128,13 +128,12 @@ public class ServiceProviderInterfaceService : ApplicationService
/// <returns></returns> /// <returns></returns>
/// <exception cref="BusinessException"></exception> /// <exception cref="BusinessException"></exception>
[HttpPost("Interface/SaveServiceProviderInterface")] [HttpPost("Interface/SaveServiceProviderInterface")]
public async Task SaveServiceProviderInterfaceAsync(ServiceProviderInterfaceInput input) public async Task<int> SaveServiceProviderInterfaceAsync(ServiceProviderInterfaceInput input)
{ {
switch (input.OptionType) switch (input.OptionType)
{ {
case OptionType.: case OptionType.:
await CreateServiceProviderInterfaceAsync(input); return await CreateServiceProviderInterfaceAsync(input);
break;
case OptionType.: case OptionType.:
await UpdateServiceProviderInterfaceAsync(input); await UpdateServiceProviderInterfaceAsync(input);
break; break;
@ -146,6 +145,8 @@ public class ServiceProviderInterfaceService : ApplicationService
default: default:
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
} }
return input.Id ?? 0;
} }
@ -173,7 +174,7 @@ public class ServiceProviderInterfaceService : ApplicationService
return true; return true;
} }
internal async Task CreateServiceProviderInterfaceAsync(ServiceProviderInterfaceInput input) internal async Task<int> CreateServiceProviderInterfaceAsync(ServiceProviderInterfaceInput input)
{ {
// 校验参数合法性 // 校验参数合法性
ParameterService.ValidateParameter( ParameterService.ValidateParameter(
@ -232,6 +233,8 @@ public class ServiceProviderInterfaceService : ApplicationService
// 提交事务 // 提交事务
ts.Complete(); ts.Complete();
return interfaceId;
} }
private async Task<string> GenerateServiceProviderInterfaceCode(int serviceProviderId) private async Task<string> GenerateServiceProviderInterfaceCode(int serviceProviderId)

View File

@ -23,7 +23,7 @@ public class InterfaceMapPublishService(
IInterfaceMapPublishRepository interfaceMapPublishRepository, IInterfaceMapPublishRepository interfaceMapPublishRepository,
InterfaceForwardQuery interfaceForwardQuery, InterfaceForwardQuery interfaceForwardQuery,
IInterfaceMapRepository interfaceMapRepository) IInterfaceMapRepository interfaceMapRepository)
: Fake.Application.ApplicationService : ApplicationService
{ {
private static readonly JsonSerializerSettings Settings = new() private static readonly JsonSerializerSettings Settings = new()
{ {
@ -79,7 +79,7 @@ public class InterfaceMapPublishService(
string redisContent = JsonConvert.SerializeObject(cache, Settings); string redisContent = JsonConvert.SerializeObject(cache, Settings);
var differenceContent = CompareTexts(redisContent, dbContent); var differenceContent = CompareTexts(redisContent, dbContent?? String.Empty);
return new InterfaceMapPublishedDifferenceVO return new InterfaceMapPublishedDifferenceVO
{ {

View File

@ -11,6 +11,6 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Fake.DomainDrivenDesign" Version="8.0.0-preview.5" /> <PackageReference Include="Fake.DomainDrivenDesign" Version="8.0.0-preview.9" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -10,19 +10,19 @@ namespace InterfaceForward.Repositories;
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
public class BasicRepository<T> : SqlSugarRepository<InterfaceForwardDbContext, T>, IBasicRepository<T>where T : class, IAggregateRoot, new() public class BasicRepository<T> : SqlSugarRepository<InterfaceForwardDbContext, T>, IBasicRepository<T>where T : class, IAggregateRoot, new()
{ {
protected ISqlSugarClient Context => GetDbContextAsync().Result.SqlSugarClient; protected ISqlSugarClient Context => GetDbContextAsync().Result;
public ISugarQueryable<T> AsQueryable() public ISugarQueryable<T> AsQueryable()
{ {
return Context.Queryable<T>(); return Context.Queryable<T>();
} }
public async Task<T> GetFirstAsync(Expression<Func<T, bool>> whereExpression) public async Task<T?> GetFirstAsync(Expression<Func<T, bool>> whereExpression)
{ {
return await AsQueryable().FirstAsync(whereExpression); return await AsQueryable().FirstAsync(whereExpression);
} }
public async Task<TResult> GetFirstAsync<TResult>(Expression<Func<T, bool>> whereExpression, public async Task<TResult?> GetFirstAsync<TResult>(Expression<Func<T, bool>> whereExpression,
Expression<Func<T, TResult>> resultExpression) Expression<Func<T, TResult>> resultExpression)
{ {
return await Context.Queryable<T>().Where(whereExpression).Select(resultExpression).FirstAsync(); return await Context.Queryable<T>().Where(whereExpression).Select(resultExpression).FirstAsync();
@ -37,7 +37,7 @@ public class BasicRepository<T> : SqlSugarRepository<InterfaceForwardDbContext,
Expression<Func<T, TResult>> resultExpression) Expression<Func<T, TResult>> resultExpression)
{ {
var ctx = await GetDbContextAsync(); var ctx = await GetDbContextAsync();
return await ctx.SqlSugarClient.Queryable<T>().Where(whereExpression).Select(resultExpression).ToListAsync(); return await ctx.Queryable<T>().Where(whereExpression).Select(resultExpression).ToListAsync();
} }
public async Task<int> CountAsync(Expression<Func<T, bool>> exp) public async Task<int> CountAsync(Expression<Func<T, bool>> exp)

View File

@ -13,9 +13,9 @@ public interface IBasicRepository<T>: ISqlSugarRepository<InterfaceForwardDbCont
/// </summary> /// </summary>
/// <param name="whereExpression"></param> /// <param name="whereExpression"></param>
/// <returns></returns> /// <returns></returns>
Task<T> GetFirstAsync(Expression<Func<T, bool>> whereExpression); Task<T?> GetFirstAsync(Expression<Func<T, bool>> whereExpression);
Task<TResult> GetFirstAsync<TResult>(Expression<Func<T, bool>> whereExpression,Expression<Func<T, TResult>> resultExpression); Task<TResult?> GetFirstAsync<TResult>(Expression<Func<T, bool>> whereExpression,Expression<Func<T, TResult>> resultExpression);
/// <summary> /// <summary>
/// get list /// get list

View File

@ -7,7 +7,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Fake.SqlSugarCore" Version="8.0.0-preview.5" /> <PackageReference Include="Fake.SqlSugarCore" Version="8.0.0-preview.9" />
<PackageReference Include="NEST" Version="7.17.5" /> <PackageReference Include="NEST" Version="7.17.5" />
</ItemGroup> </ItemGroup>