diff --git a/Yi.Framework.Net6/src/framework/Yi.Framework.AspNetCore/Microsoft/Extensions/DependencyInjection/CurrentUserAddExtensions.cs b/Yi.Framework.Net6/src/framework/Yi.Framework.AspNetCore/Microsoft/Extensions/DependencyInjection/CurrentUserAddExtensions.cs index 130d6090..e6874c1a 100644 --- a/Yi.Framework.Net6/src/framework/Yi.Framework.AspNetCore/Microsoft/Extensions/DependencyInjection/CurrentUserAddExtensions.cs +++ b/Yi.Framework.Net6/src/framework/Yi.Framework.AspNetCore/Microsoft/Extensions/DependencyInjection/CurrentUserAddExtensions.cs @@ -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; diff --git a/Yi.Framework.Net6/src/framework/Yi.Framework.AspNetCore/YiFrameworkAspNetCoreModule.cs b/Yi.Framework.Net6/src/framework/Yi.Framework.AspNetCore/YiFrameworkAspNetCoreModule.cs index 08043a7f..85f7cba7 100644 --- a/Yi.Framework.Net6/src/framework/Yi.Framework.AspNetCore/YiFrameworkAspNetCoreModule.cs +++ b/Yi.Framework.Net6/src/framework/Yi.Framework.AspNetCore/YiFrameworkAspNetCoreModule.cs @@ -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; diff --git a/Yi.Framework.Net6/src/framework/Yi.Framework.Core.Sqlsugar/Repositories/SqlsugarRepository.cs b/Yi.Framework.Net6/src/framework/Yi.Framework.Core.Sqlsugar/Repositories/SqlsugarRepository.cs index d6043e94..ad59e324 100644 --- a/Yi.Framework.Net6/src/framework/Yi.Framework.Core.Sqlsugar/Repositories/SqlsugarRepository.cs +++ b/Yi.Framework.Net6/src/framework/Yi.Framework.Core.Sqlsugar/Repositories/SqlsugarRepository.cs @@ -45,6 +45,29 @@ namespace Yi.Framework.Core.Sqlsugar.Repositories } + + + public async Task> GetPageListAsync(Expression> whereExpression, int pageNum,int pageSize) + { + return await base.GetPageListAsync(whereExpression, new PageModel { PageIndex = pageNum, PageSize = pageSize }); + } + + public async Task> GetPageListAsync(Expression> whereExpression, int pageNum, int pageSize, Expression>? orderByExpression = null, OrderByEnum orderByType = OrderByEnum.Asc) + { + return await base.GetPageListAsync(whereExpression, new PageModel { PageIndex = pageNum, PageSize = pageSize }, orderByExpression, orderByType.EnumToEnum()); + } + + public async Task> GetPageListAsync(Expression> 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 UpdateIgnoreNullAsync(T updateObj) { return await _Db.Updateable(updateObj).IgnoreColumns(true).ExecuteCommandAsync() > 0; diff --git a/Yi.Framework.Net6/src/framework/Yi.Framework.Core/Module/ModuleAssembly.cs b/Yi.Framework.Net6/src/framework/Yi.Framework.Core/Module/ModuleAssembly.cs new file mode 100644 index 00000000..080564d2 --- /dev/null +++ b/Yi.Framework.Net6/src/framework/Yi.Framework.Core/Module/ModuleAssembly.cs @@ -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 assemblies=new HashSet(); + public static Assembly[] Assemblies { get=> assemblies.ToArray();} + + public static void Add(Assembly assembly) + { + assemblies.Add(assembly); + } + } +} diff --git a/Yi.Framework.Net6/src/framework/Yi.Framework.Core/Module/ModuleManager.cs b/Yi.Framework.Net6/src/framework/Yi.Framework.Core/Module/ModuleManager.cs index 7886a9b4..4d24a4c6 100644 --- a/Yi.Framework.Net6/src/framework/Yi.Framework.Core/Module/ModuleManager.cs +++ b/Yi.Framework.Net6/src/framework/Yi.Framework.Core/Module/ModuleManager.cs @@ -25,7 +25,8 @@ namespace Yi.Framework.Core.Module foreach (var r in result) { - + //添加全局模块程序集 + ModuleAssembly.Add(r.Assembly); Console.WriteLine($"意框架正在加载模块:{r.Name}"); } return result; diff --git a/Yi.Framework.Net6/src/framework/Yi.Framework.Ddd/Repositories/IRepository.cs b/Yi.Framework.Net6/src/framework/Yi.Framework.Ddd/Repositories/IRepository.cs index 2a999aa7..b15dea78 100644 --- a/Yi.Framework.Net6/src/framework/Yi.Framework.Ddd/Repositories/IRepository.cs +++ b/Yi.Framework.Net6/src/framework/Yi.Framework.Ddd/Repositories/IRepository.cs @@ -29,6 +29,9 @@ namespace Yi.Framework.Ddd.Repositories Task> GetListAsync(Expression> whereExpression); //分页查 + Task> GetPageListAsync(Expression> whereExpression, int pageNum, int pageSize); + Task> GetPageListAsync(Expression> whereExpression, int pageNum, int pageSize, Expression>? orderByExpression = null, OrderByEnum orderByType = OrderByEnum.Asc); + Task> GetPageListAsync(Expression> whereExpression, int pageNum, int pageSize, string? orderBy, OrderByEnum orderByType = OrderByEnum.Asc); Task> GetPageListAsync(Expression> whereExpression, IPagedAndSortedResultRequestDto page); Task> GetPageListAsync(Expression> whereExpression, IPagedAndSortedResultRequestDto page, Expression>? orderByExpression = null, OrderByEnum orderByType = OrderByEnum.Asc); Task> GetPageListAsync(Expression> whereExpression, IPagedAndSortedResultRequestDto page, string? orderBy, OrderByEnum orderByType = OrderByEnum.Asc); @@ -55,5 +58,6 @@ namespace Yi.Framework.Ddd.Repositories Task DeleteAsync(Expression> whereExpression); Task DeleteByIdAsync(dynamic id); Task DeleteByIdsAsync(dynamic[] ids); + } } diff --git a/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/Program.cs b/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/Program.cs index 5d0af2e6..93593807 100644 --- a/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/Program.cs +++ b/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/Program.cs @@ -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)); +//autofacģ,Ҫģ builder.Host.ConfigureAutoFacContainer(container => { - container.RegisterYiModule(AutoFacModuleEnum.PropertiesAutowiredModule, - typeof(YiBBSApplicationModule).Assembly, - typeof(YiRBACApplicationModule).Assembly); + container.RegisterYiModule(AutoFacModuleEnum.PropertiesAutowiredModule, ModuleAssembly.Assemblies); }); var app = builder.Build(); diff --git a/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/YiBBSWebModule.cs b/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/YiBBSWebModule.cs index 93d27737..a62ec31a 100644 --- a/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/YiBBSWebModule.cs +++ b/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/YiBBSWebModule.cs @@ -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 diff --git a/Yi.Framework.Net6/src/project/Template/Yi.Template.Web/Program.cs b/Yi.Framework.Net6/src/project/Template/Yi.Template.Web/Program.cs index be0db32c..d0d546a1 100644 --- a/Yi.Framework.Net6/src/project/Template/Yi.Template.Web/Program.cs +++ b/Yi.Framework.Net6/src/project/Template/Yi.Template.Web/Program.cs @@ -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(); diff --git a/Yi.Framework.Net6/src/project/Template/Yi.Template.Web/YiTemplateWebModule.cs b/Yi.Framework.Net6/src/project/Template/Yi.Template.Web/YiTemplateWebModule.cs index 1fce11c9..194428a6 100644 --- a/Yi.Framework.Net6/src/project/Template/Yi.Template.Web/YiTemplateWebModule.cs +++ b/Yi.Framework.Net6/src/project/Template/Yi.Template.Web/YiTemplateWebModule.cs @@ -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 diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/Program.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/Program.cs index 5d0af2e6..93593807 100644 --- a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/Program.cs +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/Program.cs @@ -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)); +//autofacģ,Ҫģ builder.Host.ConfigureAutoFacContainer(container => { - container.RegisterYiModule(AutoFacModuleEnum.PropertiesAutowiredModule, - typeof(YiBBSApplicationModule).Assembly, - typeof(YiRBACApplicationModule).Assembly); + container.RegisterYiModule(AutoFacModuleEnum.PropertiesAutowiredModule, ModuleAssembly.Assemblies); }); var app = builder.Build(); diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/YiBBSWebModule.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/YiBBSWebModule.cs index 93d27737..a62ec31a 100644 --- a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/YiBBSWebModule.cs +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/YiBBSWebModule.cs @@ -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 diff --git a/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Web/Program.cs b/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Web/Program.cs index 8fc3d552..f7ca1426 100644 --- a/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Web/Program.cs +++ b/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Web/Program.cs @@ -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(); diff --git a/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Web/YiRBACWebModule.cs b/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Web/YiRBACWebModule.cs index 6db43adc..91f968be 100644 --- a/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Web/YiRBACWebModule.cs +++ b/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Web/YiRBACWebModule.cs @@ -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); }); diff --git a/Yi.Framework.Net6/src/project/template/Yi.Template.Web/Program.cs b/Yi.Framework.Net6/src/project/template/Yi.Template.Web/Program.cs index be0db32c..d0d546a1 100644 --- a/Yi.Framework.Net6/src/project/template/Yi.Template.Web/Program.cs +++ b/Yi.Framework.Net6/src/project/template/Yi.Template.Web/Program.cs @@ -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(); diff --git a/Yi.Framework.Net6/src/project/template/Yi.Template.Web/YiTemplateWebModule.cs b/Yi.Framework.Net6/src/project/template/Yi.Template.Web/YiTemplateWebModule.cs index 1fce11c9..194428a6 100644 --- a/Yi.Framework.Net6/src/project/template/Yi.Template.Web/YiTemplateWebModule.cs +++ b/Yi.Framework.Net6/src/project/template/Yi.Template.Web/YiTemplateWebModule.cs @@ -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