perf: 优化全部模块程序集
This commit is contained in:
@@ -9,7 +9,6 @@ using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.AspNetCore.CurrentUser;
|
||||
using Yi.Framework.Core.Const;
|
||||
using Yi.Framework.Core.CurrentUsers;
|
||||
using Yi.Framework.Core.CurrentUsers.Accessor;
|
||||
|
||||
@@ -7,7 +7,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.AspNetCore.CurrentUser;
|
||||
using Yi.Framework.Core.CurrentUsers.Accessor;
|
||||
using Yi.Framework.Core.CurrentUsers;
|
||||
|
||||
|
||||
@@ -45,6 +45,29 @@ namespace Yi.Framework.Core.Sqlsugar.Repositories
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task<List<T>> GetPageListAsync(Expression<Func<T, bool>> whereExpression, int pageNum,int pageSize)
|
||||
{
|
||||
return await base.GetPageListAsync(whereExpression, new PageModel { PageIndex = pageNum, PageSize = pageSize });
|
||||
}
|
||||
|
||||
public async Task<List<T>> GetPageListAsync(Expression<Func<T, bool>> whereExpression, int pageNum, int pageSize, Expression<Func<T, object>>? orderByExpression = null, OrderByEnum orderByType = OrderByEnum.Asc)
|
||||
{
|
||||
return await base.GetPageListAsync(whereExpression, new PageModel { PageIndex = pageNum, PageSize = pageSize }, orderByExpression, orderByType.EnumToEnum<OrderByType>());
|
||||
}
|
||||
|
||||
public async Task<List<T>> GetPageListAsync(Expression<Func<T, bool>> whereExpression, int pageNum, int pageSize, string? orderBy, OrderByEnum orderByType = OrderByEnum.Asc)
|
||||
{
|
||||
return await _DbQueryable.Where(whereExpression).OrderByIF(orderBy is not null, orderBy + " " + orderByType.ToString().ToLower()).ToPageListAsync(pageNum, pageSize);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task<bool> UpdateIgnoreNullAsync(T updateObj)
|
||||
{
|
||||
return await _Db.Updateable(updateObj).IgnoreColumns(true).ExecuteCommandAsync() > 0;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Core.Module
|
||||
{
|
||||
public class ModuleAssembly
|
||||
{
|
||||
private static HashSet<Assembly> assemblies=new HashSet<Assembly>();
|
||||
public static Assembly[] Assemblies { get=> assemblies.ToArray();}
|
||||
|
||||
public static void Add(Assembly assembly)
|
||||
{
|
||||
assemblies.Add(assembly);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,8 @@ namespace Yi.Framework.Core.Module
|
||||
|
||||
foreach (var r in result)
|
||||
{
|
||||
|
||||
//添加全局模块程序集
|
||||
ModuleAssembly.Add(r.Assembly);
|
||||
Console.WriteLine($"意框架正在加载模块:{r.Name}");
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -29,6 +29,9 @@ namespace Yi.Framework.Ddd.Repositories
|
||||
Task<List<T>> GetListAsync(Expression<Func<T, bool>> whereExpression);
|
||||
|
||||
//分页查
|
||||
Task<List<T>> GetPageListAsync(Expression<Func<T, bool>> whereExpression, int pageNum, int pageSize);
|
||||
Task<List<T>> GetPageListAsync(Expression<Func<T, bool>> whereExpression, int pageNum, int pageSize, Expression<Func<T, object>>? orderByExpression = null, OrderByEnum orderByType = OrderByEnum.Asc);
|
||||
Task<List<T>> GetPageListAsync(Expression<Func<T, bool>> whereExpression, int pageNum, int pageSize, string? orderBy, OrderByEnum orderByType = OrderByEnum.Asc);
|
||||
Task<List<T>> GetPageListAsync(Expression<Func<T, bool>> whereExpression, IPagedAndSortedResultRequestDto page);
|
||||
Task<List<T>> GetPageListAsync(Expression<Func<T, bool>> whereExpression, IPagedAndSortedResultRequestDto page, Expression<Func<T, object>>? orderByExpression = null, OrderByEnum orderByType = OrderByEnum.Asc);
|
||||
Task<List<T>> GetPageListAsync(Expression<Func<T, bool>> whereExpression, IPagedAndSortedResultRequestDto page, string? orderBy, OrderByEnum orderByType = OrderByEnum.Asc);
|
||||
@@ -55,5 +58,6 @@ namespace Yi.Framework.Ddd.Repositories
|
||||
Task<bool> DeleteAsync(Expression<Func<T, bool>> whereExpression);
|
||||
Task<bool> DeleteByIdAsync(dynamic id);
|
||||
Task<bool> DeleteByIdsAsync(dynamic[] ids);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,19 +3,17 @@ using Yi.Framework.Core.Autofac.Extensions;
|
||||
using Yi.Framework.Core.Autofac.Modules;
|
||||
using Yi.Framework.Core.Extensions;
|
||||
using Yi.BBS.Web;
|
||||
using Yi.BBS.Application;
|
||||
using Yi.RBAC.Application;
|
||||
using Yi.Framework.Core.Module;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.WebHost.UseStartUrlsServer(builder.Configuration);
|
||||
|
||||
builder.UseYiModules(typeof(YiBBSWebModule));
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>autofacģ<63><C4A3>,<2C><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
|
||||
builder.Host.ConfigureAutoFacContainer(container =>
|
||||
{
|
||||
container.RegisterYiModule(AutoFacModuleEnum.PropertiesAutowiredModule,
|
||||
typeof(YiBBSApplicationModule).Assembly,
|
||||
typeof(YiRBACApplicationModule).Assembly);
|
||||
container.RegisterYiModule(AutoFacModuleEnum.PropertiesAutowiredModule, ModuleAssembly.Assemblies);
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
@@ -11,6 +11,7 @@ using Yi.RBAC.Application;
|
||||
using Yi.Framework.AspNetCore;
|
||||
using Yi.Framework.Data.Json;
|
||||
using Yi.Framework.OperLogManager;
|
||||
using Yi.Framework.Core.Module;
|
||||
|
||||
namespace Yi.BBS.Web
|
||||
{
|
||||
@@ -28,10 +29,11 @@ namespace Yi.BBS.Web
|
||||
services.AddControllers().AddJsonOptions(opt => {
|
||||
opt.JsonSerializerOptions.Converters.Add(new DateTimeJsonConverter("yyyy-MM-dd HH:mm:ss"));
|
||||
});
|
||||
|
||||
services.AddAutoApiService(opt =>
|
||||
{
|
||||
//NETServiceTest所在程序集添加进动态api配置
|
||||
opt.CreateConventional(typeof(YiBBSApplicationModule).Assembly, option => option.RootPath = string.Empty);
|
||||
opt.CreateConventional(ModuleAssembly.Assemblies, option => option.RootPath = string.Empty);
|
||||
});
|
||||
|
||||
//添加swagger
|
||||
|
||||
@@ -2,6 +2,7 @@ using AspNetCore.Microsoft.AspNetCore.Hosting;
|
||||
using Yi.Framework.Core.Autofac.Extensions;
|
||||
using Yi.Framework.Core.Autofac.Modules;
|
||||
using Yi.Framework.Core.Extensions;
|
||||
using Yi.Framework.Core.Module;
|
||||
using Yi.Template.Application;
|
||||
using Yi.Template.Web;
|
||||
|
||||
@@ -15,7 +16,7 @@ builder.UseYiModules(typeof(YiTemplateWebModule));
|
||||
//添加autofac模块,需要添加模块
|
||||
builder.Host.ConfigureAutoFacContainer(container =>
|
||||
{
|
||||
container.RegisterYiModule(AutoFacModuleEnum.PropertiesAutowiredModule, typeof(YiTemplateApplicationModule).Assembly);
|
||||
container.RegisterYiModule(AutoFacModuleEnum.PropertiesAutowiredModule, ModuleAssembly.Assemblies);
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
@@ -5,6 +5,7 @@ using Yi.Framework.Auth.JwtBearer;
|
||||
using Yi.Framework.Core;
|
||||
using Yi.Framework.Core.Attributes;
|
||||
using Yi.Framework.Core.Autofac;
|
||||
using Yi.Framework.Core.Module;
|
||||
using Yi.Framework.Data.Json;
|
||||
using Yi.Template.Application;
|
||||
using Yi.Template.Sqlsugar;
|
||||
@@ -28,7 +29,7 @@ namespace Yi.Template.Web
|
||||
services.AddAutoApiService(opt =>
|
||||
{
|
||||
//NETServiceTest所在程序集添加进动态api配置
|
||||
opt.CreateConventional(typeof(YiTemplateApplicationModule).Assembly, option => option.RootPath = string.Empty);
|
||||
opt.CreateConventional(ModuleAssembly.Assemblies, option => option.RootPath = string.Empty);
|
||||
});
|
||||
|
||||
//添加swagger
|
||||
|
||||
@@ -3,19 +3,17 @@ using Yi.Framework.Core.Autofac.Extensions;
|
||||
using Yi.Framework.Core.Autofac.Modules;
|
||||
using Yi.Framework.Core.Extensions;
|
||||
using Yi.BBS.Web;
|
||||
using Yi.BBS.Application;
|
||||
using Yi.RBAC.Application;
|
||||
using Yi.Framework.Core.Module;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.WebHost.UseStartUrlsServer(builder.Configuration);
|
||||
|
||||
builder.UseYiModules(typeof(YiBBSWebModule));
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>autofacģ<63><C4A3>,<2C><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
|
||||
builder.Host.ConfigureAutoFacContainer(container =>
|
||||
{
|
||||
container.RegisterYiModule(AutoFacModuleEnum.PropertiesAutowiredModule,
|
||||
typeof(YiBBSApplicationModule).Assembly,
|
||||
typeof(YiRBACApplicationModule).Assembly);
|
||||
container.RegisterYiModule(AutoFacModuleEnum.PropertiesAutowiredModule, ModuleAssembly.Assemblies);
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
@@ -11,6 +11,7 @@ using Yi.RBAC.Application;
|
||||
using Yi.Framework.AspNetCore;
|
||||
using Yi.Framework.Data.Json;
|
||||
using Yi.Framework.OperLogManager;
|
||||
using Yi.Framework.Core.Module;
|
||||
|
||||
namespace Yi.BBS.Web
|
||||
{
|
||||
@@ -28,10 +29,11 @@ namespace Yi.BBS.Web
|
||||
services.AddControllers().AddJsonOptions(opt => {
|
||||
opt.JsonSerializerOptions.Converters.Add(new DateTimeJsonConverter("yyyy-MM-dd HH:mm:ss"));
|
||||
});
|
||||
|
||||
services.AddAutoApiService(opt =>
|
||||
{
|
||||
//NETServiceTest所在程序集添加进动态api配置
|
||||
opt.CreateConventional(typeof(YiBBSApplicationModule).Assembly, option => option.RootPath = string.Empty);
|
||||
opt.CreateConventional(ModuleAssembly.Assemblies, option => option.RootPath = string.Empty);
|
||||
});
|
||||
|
||||
//添加swagger
|
||||
|
||||
@@ -2,6 +2,7 @@ using AspNetCore.Microsoft.AspNetCore.Hosting;
|
||||
using Yi.Framework.Core.Autofac.Extensions;
|
||||
using Yi.Framework.Core.Autofac.Modules;
|
||||
using Yi.Framework.Core.Extensions;
|
||||
using Yi.Framework.Core.Module;
|
||||
using Yi.RBAC.Application;
|
||||
using Yi.RBAC.Web;
|
||||
|
||||
@@ -15,7 +16,7 @@ builder.UseYiModules(typeof(YiRBACWebModule));
|
||||
//添加autofac模块,需要添加模块
|
||||
builder.Host.ConfigureAutoFacContainer(container =>
|
||||
{
|
||||
container.RegisterYiModule(AutoFacModuleEnum.PropertiesAutowiredModule, typeof(YiRBACApplicationModule).Assembly);
|
||||
container.RegisterYiModule(AutoFacModuleEnum.PropertiesAutowiredModule, ModuleAssembly.Assemblies);
|
||||
});
|
||||
var app = builder.Build();
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ using Yi.Framework.Auth.JwtBearer;
|
||||
using Yi.Framework.Core;
|
||||
using Yi.Framework.Core.Attributes;
|
||||
using Yi.Framework.Core.Autofac;
|
||||
using Yi.Framework.Core.Module;
|
||||
using Yi.Framework.Data.Json;
|
||||
using Yi.Framework.OperLogManager;
|
||||
using Yi.RBAC.Application;
|
||||
@@ -31,11 +32,10 @@ namespace Yi.RBAC.Web
|
||||
});
|
||||
|
||||
|
||||
|
||||
services.AddAutoApiService(opt =>
|
||||
{
|
||||
opt.CreateConventional(AssemblyHelper.GetAllLoadAssembly(), option => option.RootPath = string.Empty);
|
||||
|
||||
//NETServiceTest所在程序集添加进动态api配置
|
||||
opt.CreateConventional(ModuleAssembly.Assemblies, option => option.RootPath = string.Empty);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ using AspNetCore.Microsoft.AspNetCore.Hosting;
|
||||
using Yi.Framework.Core.Autofac.Extensions;
|
||||
using Yi.Framework.Core.Autofac.Modules;
|
||||
using Yi.Framework.Core.Extensions;
|
||||
using Yi.Framework.Core.Module;
|
||||
using Yi.Template.Application;
|
||||
using Yi.Template.Web;
|
||||
|
||||
@@ -15,7 +16,7 @@ builder.UseYiModules(typeof(YiTemplateWebModule));
|
||||
//添加autofac模块,需要添加模块
|
||||
builder.Host.ConfigureAutoFacContainer(container =>
|
||||
{
|
||||
container.RegisterYiModule(AutoFacModuleEnum.PropertiesAutowiredModule, typeof(YiTemplateApplicationModule).Assembly);
|
||||
container.RegisterYiModule(AutoFacModuleEnum.PropertiesAutowiredModule, ModuleAssembly.Assemblies);
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
@@ -5,6 +5,7 @@ using Yi.Framework.Auth.JwtBearer;
|
||||
using Yi.Framework.Core;
|
||||
using Yi.Framework.Core.Attributes;
|
||||
using Yi.Framework.Core.Autofac;
|
||||
using Yi.Framework.Core.Module;
|
||||
using Yi.Framework.Data.Json;
|
||||
using Yi.Template.Application;
|
||||
using Yi.Template.Sqlsugar;
|
||||
@@ -28,7 +29,7 @@ namespace Yi.Template.Web
|
||||
services.AddAutoApiService(opt =>
|
||||
{
|
||||
//NETServiceTest所在程序集添加进动态api配置
|
||||
opt.CreateConventional(typeof(YiTemplateApplicationModule).Assembly, option => option.RootPath = string.Empty);
|
||||
opt.CreateConventional(ModuleAssembly.Assemblies, option => option.RootPath = string.Empty);
|
||||
});
|
||||
|
||||
//添加swagger
|
||||
|
||||
Reference in New Issue
Block a user