ok
This commit is contained in:
parent
87a2eec61b
commit
8f418b4fd7
@ -1,7 +1,7 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<!-- <Nullable>enable</Nullable>-->
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<!-- <WarningsAsErrors>Nullable</WarningsAsErrors>-->
|
||||
</PropertyGroup>
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\InterfaceForward.Application\InterfaceForward.Application.csproj" />
|
||||
<ProjectReference Include="..\InterfaceForward.ServiceDefaults\InterfaceForward.ServiceDefaults.csproj"/>
|
||||
<PackageReference Include="Fake.Autofac" Version="8.0.0-preview8.4" />
|
||||
<PackageReference Include="Fake.Autofac" Version="8.0.0-preview8.5" />
|
||||
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
|
||||
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="10.0.0" />
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using Fake.AspNetCore;
|
||||
using Fake.AspNetCore.Auditing;
|
||||
using Fake.AspNetCore.Mvc.Conventions;
|
||||
using Fake.AspNetCore.Mvc.Filters;
|
||||
using Fake.Autofac;
|
||||
using Fake.Modularity;
|
||||
using InterfaceForward.Application;
|
||||
@ -28,6 +29,7 @@ public class InterfaceForwardApiModule : FakeModule
|
||||
services.AddFakeSwaggerGen()
|
||||
.AddFakeExceptionFilter()
|
||||
.AddFakeValidationActionFilter()
|
||||
.AddFakeUnitOfWorkActionFilter()
|
||||
.AddFakeAspNetCoreAuditing();
|
||||
|
||||
services.AddCors(options =>
|
||||
|
||||
@ -27,6 +27,9 @@
|
||||
"http://localhost:8888"
|
||||
]
|
||||
},
|
||||
"ConnectionStrings":{
|
||||
"Default": "server=baget.xiaolipro.cn;database=interface_forward;uid=dev;pwd=itd!@#123;charset=utf8mb4;"
|
||||
},
|
||||
"FeiShuNotice": {
|
||||
"Title": "InterfaceForward-Dev",
|
||||
"Webhook": "https://open.feishu.cn/open-apis/bot/v2/hook/255c44ff-5891-4902-9b6a-6d0250e745f7"
|
||||
|
||||
@ -17,8 +17,8 @@
|
||||
<PackageReference Include="DiffPlex" Version="1.7.2" />
|
||||
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.13.0" />
|
||||
<PackageReference Include="DotNetCore.Natasha.CSharp" Version="5.2.2.1"/>
|
||||
<PackageReference Include="Fake.AspNetCore" Version="8.0.0-preview8.4" />
|
||||
<PackageReference Include="Fake.ObjectMapping.AutoMapper" Version="8.0.0-preview8.4" />
|
||||
<PackageReference Include="Fake.AspNetCore" Version="8.0.0-preview8.5" />
|
||||
<PackageReference Include="Fake.ObjectMapping.AutoMapper" Version="8.0.0-preview8.5" />
|
||||
<PackageReference Include="FreeRedis" Version="1.2.15" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text;
|
||||
using Fake.UnitOfWork;
|
||||
using InterfaceForward.Application.Contracts.Dtos.App;
|
||||
using InterfaceForward.Application.Helpers;
|
||||
using InterfaceForward.Application.OSS;
|
||||
|
||||
@ -11,6 +11,6 @@
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Fake.DomainDrivenDesign" Version="8.0.0-preview8.4" />
|
||||
<PackageReference Include="Fake.DomainDrivenDesign" Version="8.0.0-preview8.5" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@ -7,6 +7,14 @@ namespace InterfaceForward.Repositories.App.Services
|
||||
/// </summary>
|
||||
public class AppRepository : BasicRepository<AppEntity>, IAppRepository, IScopedDependency
|
||||
{
|
||||
public IUpdateable<AppEntity> AsUpdateable()
|
||||
{
|
||||
return Context.Updateable<AppEntity>();
|
||||
}
|
||||
|
||||
public IUpdateable<AppEntity> AsUpdateable(AppEntity updateObj)
|
||||
{
|
||||
return Context.Updateable(updateObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using InterfaceForward.Repositories.App.Entitys;
|
||||
using System.Linq.Expressions;
|
||||
using InterfaceForward.Repositories.App.Entitys;
|
||||
using InterfaceForward.Repositories.Interface.Entitys;
|
||||
|
||||
namespace InterfaceForward.Repositories.App.Services
|
||||
@ -8,6 +9,16 @@ namespace InterfaceForward.Repositories.App.Services
|
||||
/// </summary>
|
||||
public class AppScopeRepository : BasicRepository<AppScopeEntity>, IAppScopeRepository, IScopedDependency
|
||||
{
|
||||
public Task<bool> UpdateAsync(Expression<Func<AppScopeEntity, object>> columns, Expression<Func<AppScopeEntity, bool>> whereExpression)
|
||||
{
|
||||
return Context.Updateable<AppScopeEntity>().Where(whereExpression).UpdateColumns(columns).ExecuteCommandHasChangeAsync();
|
||||
}
|
||||
|
||||
public IUpdateable<AppScopeEntity> AsUpdateable()
|
||||
{
|
||||
return Context.Updateable<AppScopeEntity>();
|
||||
}
|
||||
|
||||
public async Task<AppScopeEntity> GetAppScopeAsync(int appId, string interfaceCode)
|
||||
{
|
||||
return await AsQueryable()
|
||||
|
||||
@ -7,8 +7,6 @@ namespace InterfaceForward.Repositories.App.Services;
|
||||
/// </summary>
|
||||
public interface IAppRepository:IBasicRepository<AppEntity>
|
||||
{
|
||||
ISugarQueryable<AppEntity> AsQueryable();
|
||||
|
||||
IUpdateable<AppEntity> AsUpdateable();
|
||||
|
||||
IUpdateable<AppEntity> AsUpdateable(AppEntity updateObj);
|
||||
|
||||
@ -8,7 +8,7 @@ namespace InterfaceForward.Repositories.App.Services
|
||||
/// </summary>
|
||||
public interface IAppScopeRepository
|
||||
{
|
||||
Task<bool> UpdateAsync(Expression<Func<AppScopeEntity, AppScopeEntity>> columns, Expression<Func<AppScopeEntity, bool>> whereExpression);
|
||||
Task<bool> UpdateAsync(Expression<Func<AppScopeEntity, object>> columns, Expression<Func<AppScopeEntity, bool>> whereExpression);
|
||||
|
||||
ISugarQueryable<AppScopeEntity> AsQueryable();
|
||||
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
using System.Linq.Expressions;
|
||||
using Fake;
|
||||
using Fake.SqlSugarCore;
|
||||
using Fake.DomainDrivenDesign.Entities;
|
||||
using Fake.DomainDrivenDesign.Repositories.SqlSugarCore;
|
||||
using Fake.UnitOfWork;
|
||||
|
||||
namespace InterfaceForward.Repositories;
|
||||
|
||||
@ -8,12 +10,18 @@ namespace InterfaceForward.Repositories;
|
||||
/// 仓储基类实现
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class BasicRepository<T> : SimpleClient<T>, IBasicRepository<T> where T : class, new()
|
||||
public class BasicRepository<T> : SqlSugarRepository<InterfaceForwardDbContext, T>, IBasicRepository<T> where T : class, IAggregateRoot, new()
|
||||
{
|
||||
public ISugarDbContextProvider<InterfaceForwardDbContext> DbContextProvider { get; set; } = null!;
|
||||
public BasicRepository()
|
||||
protected ISqlSugarClient Context => GetDbContextAsync().Result.SqlSugarClient;
|
||||
|
||||
public ISugarQueryable<T> AsQueryable()
|
||||
{
|
||||
Context = DbContextProvider.GetDbContextAsync(default).Result.SqlSugarClient;
|
||||
return Context.Queryable<T>();
|
||||
}
|
||||
|
||||
public async Task<T> GetFirstAsync(Expression<Func<T, bool>> whereExpression)
|
||||
{
|
||||
return await AsQueryable().FirstAsync(whereExpression);
|
||||
}
|
||||
|
||||
public async Task<TResult> GetFirstAsync<TResult>(Expression<Func<T, bool>> whereExpression,
|
||||
@ -22,10 +30,26 @@ public class BasicRepository<T> : SimpleClient<T>, IBasicRepository<T> where T :
|
||||
return await Context.Queryable<T>().Where(whereExpression).Select(resultExpression).FirstAsync();
|
||||
}
|
||||
|
||||
public async Task<List<T>> GetListAsync(Expression<Func<T, bool>> whereExpression)
|
||||
{
|
||||
return await AsQueryable().Where(whereExpression).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<List<TResult>> GetListAsync<TResult>(Expression<Func<T, bool>> whereExpression,
|
||||
Expression<Func<T, TResult>> resultExpression)
|
||||
{
|
||||
return await Context.Queryable<T>().Where(whereExpression).Select(resultExpression).ToListAsync();
|
||||
var ctx = await GetDbContextAsync();
|
||||
return await ctx.SqlSugarClient.Queryable<T>().Where(whereExpression).Select(resultExpression).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<int> CountAsync(Expression<Func<T, bool>> exp)
|
||||
{
|
||||
return await AsQueryable().Where(exp).CountAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> IsAnyAsync(Expression<Func<T, bool>> exp)
|
||||
{
|
||||
return await AsQueryable().Where(exp).AnyAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateAsync(T entity, Expression<Func<T, object>>? ignoreColumns)
|
||||
@ -70,4 +94,19 @@ public class BasicRepository<T> : SimpleClient<T>, IBasicRepository<T> where T :
|
||||
.SetColumns(nameof(ISoftDelete.IsDeleted), 1)
|
||||
.ExecuteCommandHasChangeAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> InsertAsync(T insertObj)
|
||||
{
|
||||
return await Context.Insertable(insertObj).ExecuteCommandAsync() > 0;
|
||||
}
|
||||
|
||||
public async Task<int> InsertReturnIdentityAsync(T insertObj)
|
||||
{
|
||||
return await Context.Insertable(insertObj).ExecuteReturnIdentityAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> InsertRangeAsync(List<T> entities)
|
||||
{
|
||||
return await Context.Insertable(entities).ExecuteCommandAsync() > 0;
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,4 @@
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace InterfaceForward.Repositories;
|
||||
|
||||
public interface IBasicRepository<T>
|
||||
@ -11,7 +10,7 @@ public interface IBasicRepository<T>
|
||||
/// </summary>
|
||||
/// <param name="whereExpression"></param>
|
||||
/// <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);
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ namespace InterfaceForward.Repositories.Interface.Entitys;
|
||||
/// 接口映射明细表
|
||||
///</summary>
|
||||
[SugarTable("t_interface_map_published")]
|
||||
public class InterfaceMapPublishedEntity: CreateAuditedEntity<int>
|
||||
public class InterfaceMapPublishedEntity: CreateAuditedEntity<int>,IAggregateRoot
|
||||
{
|
||||
///<summary>
|
||||
/// id
|
||||
|
||||
@ -16,9 +16,15 @@ namespace InterfaceForward.Repositories.Interface.Services
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> InsertOrUpdateAsync(InterfaceReturnConfigEntity data, CancellationToken cancellationToken)
|
||||
{
|
||||
Context.Ado.CancellationToken = cancellationToken;
|
||||
return await Context.Storageable(data).ExecuteCommandAsync(cancellationToken) > 0;
|
||||
}
|
||||
|
||||
public async Task DeleteConfigByIdAsync(int id)
|
||||
{
|
||||
await AsUpdateable().SetColumns(x => x.IsDeleted == true)
|
||||
await Context.Updateable<InterfaceReturnConfigEntity>().SetColumns(x => x.IsDeleted == true)
|
||||
.Where(x => x.Id == id).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Fake.SqlSugarCore" Version="8.0.0-preview8.4" />
|
||||
<PackageReference Include="Fake.SqlSugarCore" Version="8.0.0-preview8.5" />
|
||||
<PackageReference Include="NEST" Version="7.17.5" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@ -1,7 +1,24 @@
|
||||
using Fake.Modularity;
|
||||
using Fake.SqlSugarCore;
|
||||
using Fake.UnitOfWork;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace InterfaceForward.Repositories;
|
||||
|
||||
[DependsOn(typeof(FakeUnitOfWorkModule))]
|
||||
[DependsOn(typeof(FakeSqlSugarCoreModule))]
|
||||
public class InterfaceForwardRepositoriesModule : FakeModule
|
||||
{
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
var configuration = context.Services.GetConfiguration();
|
||||
context.Services.AddSugarDbContext<InterfaceForwardDbContext>(options =>
|
||||
{
|
||||
options.ConnectionString = configuration.GetConnectionString("Default")!;
|
||||
options.DbType = DbType.MySql;
|
||||
});
|
||||
|
||||
context.Services.AddScoped(typeof(IBasicRepository<>), typeof(BasicRepository<>));
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,13 @@
|
||||
namespace InterfaceForward.Repositories.ServiceProvider.Entitys;
|
||||
using Fake.DomainDrivenDesign.Entities;
|
||||
|
||||
namespace InterfaceForward.Repositories.ServiceProvider.Entitys;
|
||||
|
||||
|
||||
///<summary>
|
||||
/// 服务商账户授权表
|
||||
///</summary>
|
||||
[SugarTable("t_service_provider_account_field_value")]
|
||||
public class ServiceProviderAccountFieldValueEntity
|
||||
public class ServiceProviderAccountFieldValueEntity: Entity<int>, IAggregateRoot
|
||||
{
|
||||
///<summary>
|
||||
/// 自增主键
|
||||
|
||||
@ -7,7 +7,7 @@ public class FixedParameterRepository : BasicRepository<FixedParameterEntity>,
|
||||
{
|
||||
public async Task UpdateFieldAsync(FixedParameterEntity entity)
|
||||
{
|
||||
await AsUpdateable(entity)
|
||||
await Context.Updateable(entity)
|
||||
.IgnoreColumns(x => new {x.ServiceProviderId, x.InterfaceId})
|
||||
.IgnoreColumns(ignoreAllNullColumns:true, ignoreAllDefaultValue:true)
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
@ -30,13 +30,13 @@ public class ServiceProviderAccountFieldValueRepository : BasicRepository<Servic
|
||||
/// <inheritdoc />
|
||||
public async Task AddFieldValueRangeAsync(List<ServiceProviderAccountFieldValueEntity> entities)
|
||||
{
|
||||
await AsInsertable(entities).ExecuteCommandAsync();
|
||||
await Context.Insertable(entities).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task BatchDeleteByAccountIdAsync(int accountId)
|
||||
{
|
||||
await AsDeleteable()
|
||||
await Context.Deleteable<ServiceProviderAccountFieldValueEntity>()
|
||||
.Where(x => x.AccountId == accountId)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
@ -8,12 +8,12 @@ public class ServiceProviderAccountFieldRepository : BasicRepository<ServiceProv
|
||||
{
|
||||
public async Task AddAccountFieldRangeAsync(List<ServiceProviderAccountFieldEntity> entities)
|
||||
{
|
||||
await AsInsertable(entities).ExecuteCommandAsync();
|
||||
await Context.Insertable(entities).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
public async Task UpdateAccountFieldRangeAsync(List<ServiceProviderAccountFieldEntity> entities)
|
||||
{
|
||||
await AsUpdateable(entities)
|
||||
await Context.Updateable(entities)
|
||||
.UpdateColumns(x => new
|
||||
{
|
||||
x.FieldName,
|
||||
@ -65,7 +65,7 @@ where a.Id = @accountId and a.IsDeleted = 0 and b.IsDeleted = 0",
|
||||
|
||||
public async Task BatchDeleteAccountFieldAsync(params int[] ids)
|
||||
{
|
||||
await AsUpdateable()
|
||||
await Context.Updateable<ServiceProviderAccountFieldEntity>()
|
||||
.Where(x => ids.Contains(x.Id))
|
||||
.SetColumns(x => x.IsDeleted == true)
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
@ -10,12 +10,12 @@ public class ServiceProviderAccountRepository : BasicRepository<ServiceProviderA
|
||||
{
|
||||
public async Task<int> AddAccountAsync(ServiceProviderAccountEntity entity)
|
||||
{
|
||||
return await AsInsertable(entity).ExecuteReturnIdentityAsync();
|
||||
return await Context.Insertable(entity).ExecuteReturnIdentityAsync();
|
||||
}
|
||||
|
||||
public async Task UpdateAccountAsync(ServiceProviderAccountEntity entity)
|
||||
{
|
||||
await AsUpdateable(entity)
|
||||
await Context.Updateable(entity)
|
||||
.UpdateColumns(x => new { x.MainBodyId, x.AppId, x.UpdateTime, x.UpdateUserId })
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ public class ServiceProviderRepository : BasicRepository<ServiceProviderEntity>,
|
||||
|
||||
public async Task UpdateServiceProviderAsync(ServiceProviderEntity entity)
|
||||
{
|
||||
var update = AsUpdateable(entity);
|
||||
var update = Context.Updateable(entity);
|
||||
await update.ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user