Pārlūkot izejas kodu

优化——升级Furion最新特性

zuohuaijun 3 gadi atpakaļ
vecāks
revīzija
4d63736648

+ 4 - 4
Admin.NET/Admin.NET.Core/Admin.NET.Core.csproj

@@ -20,10 +20,10 @@
 
   <ItemGroup>
     <PackageReference Include="Caching.CSRedis" Version="3.8.2" />
-    <PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="3.6.4" />
-    <PackageReference Include="Furion.Extras.Logging.Serilog" Version="3.6.4" />
-    <PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="3.6.4" />
-    <PackageReference Include="Furion.Pure" Version="3.6.4" />
+    <PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="3.6.5" />
+    <PackageReference Include="Furion.Extras.Logging.Serilog" Version="3.6.5" />
+    <PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="3.6.5" />
+    <PackageReference Include="Furion.Pure" Version="3.6.5" />
     <PackageReference Include="Magicodes.IE.Excel" Version="2.6.4" />
     <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.6" />
     <PackageReference Include="MySql.Data" Version="8.0.29" />

+ 7 - 2
Admin.NET/Admin.NET.Core/Admin.NET.Core.xml

@@ -103,6 +103,11 @@
             常量下拉框
             </summary>
         </member>
+        <member name="F:Admin.NET.Core.CacheConst.SwaggerLogin">
+            <summary>
+            swagger登录缓存
+            </summary>
+        </member>
         <member name="T:Admin.NET.Core.ClaimConst">
             <summary>
             Claim相关常量
@@ -4357,9 +4362,9 @@
              <example>Magic.Application</example>
         </member>
         <member name="P:Admin.NET.Core.Service.CreateEntityInput.ConfigId">
-            <summary>
+             <summary>
             
-            </summary>
+             </summary>
         </member>
         <member name="P:Admin.NET.Core.Service.DataResourceInput.Pid">
             <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Service/DataBase/Dto/CreateEntityInput.cs

@@ -27,7 +27,7 @@ public class CreateEntityInput
     public string Position { get; set; }
 
     /// <summary>
-    /// 
+    ///
     /// </summary>
     public string ConfigId { get; set; }
 }

+ 1 - 1
Admin.NET/Admin.NET.Core/Service/Menu/SysMenuService.cs

@@ -86,7 +86,7 @@ public class SysMenuService : IDynamicApiController, ITransient
         var isExist = input.Type != 3
             ? await _sysMenuRep.IsAnyAsync(u => u.Name == input.Name)
             : await _sysMenuRep.IsAnyAsync(u => u.Permission == input.Permission);
-            
+
         if (isExist)
             throw Oops.Oh(ErrorCodeEnum.D4000);
 

+ 1 - 1
Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarRepository.cs

@@ -10,7 +10,7 @@ public class SqlSugarRepository<T> : SimpleClient<T> where T : class, new()
 
     public SqlSugarRepository(ISqlSugarClient context = null) : base(context) // 默认值等于null不能少
     {
-        iTenant = App.GetService<ISqlSugarClient>().AsTenant();        
+        iTenant = App.GetService<ISqlSugarClient>().AsTenant();
         base.Context = iTenant.GetConnectionWithAttr<T>();
     }
 }

+ 7 - 0
Admin.NET/Admin.NET.Web.Core/Admin.NET.Web.Core.xml

@@ -18,5 +18,12 @@
             <param name="httpContext"></param>
             <returns></returns>
         </member>
+        <member name="M:Admin.NET.Web.Core.ProjectOptions.AddProjectOptions(Microsoft.Extensions.DependencyInjection.IServiceCollection)">
+            <summary>
+            注册项目配置选项
+            </summary>
+            <param name="services"></param>
+            <returns></returns>
+        </member>
     </members>
 </doc>

+ 28 - 0
Admin.NET/Admin.NET.Web.Core/ProjectOptions.cs

@@ -0,0 +1,28 @@
+using Admin.NET.Core;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace Admin.NET.Web.Core;
+
+public static class ProjectOptions
+{
+    /// <summary>
+    /// 注册项目配置选项
+    /// </summary>
+    /// <param name="services"></param>
+    /// <returns></returns>
+    public static IServiceCollection AddProjectOptions(this IServiceCollection services)
+    {
+        services.AddConfigurableOptions<ConnectionStringsOptions>();
+        services.AddConfigurableOptions<RefreshTokenOptions>();
+        services.AddConfigurableOptions<SnowIdOptions>();
+        services.AddConfigurableOptions<CacheOptions>();
+        services.AddConfigurableOptions<OSSProviderOptions>();
+        services.AddConfigurableOptions<UploadOptions>();
+        services.AddConfigurableOptions<WechatOptions>();
+        services.AddConfigurableOptions<WechatPayOptions>();
+        services.AddConfigurableOptions<PayCallBackOptions>();
+        services.AddConfigurableOptions<CodeGenOptions>();
+
+        return services;
+    }
+}

+ 90 - 99
Admin.NET/Admin.NET.Web.Core/Startup.cs

@@ -10,120 +10,111 @@ using OnceMi.AspNetCore.OSS;
 using Serilog;
 using Yitter.IdGenerator;
 
-namespace Admin.NET.Web.Core
+namespace Admin.NET.Web.Core;
+
+public class Startup : AppStartup
 {
-    public class Startup : AppStartup
+    public void ConfigureServices(IServiceCollection services)
     {
-        public void ConfigureServices(IServiceCollection services)
-        {
-            services.AddConfigurableOptions<ConnectionStringsOptions>();
-            services.AddConfigurableOptions<RefreshTokenOptions>();
-            services.AddConfigurableOptions<SnowIdOptions>();
-            services.AddConfigurableOptions<CacheOptions>();
-            services.AddConfigurableOptions<OSSProviderOptions>();
-            services.AddConfigurableOptions<UploadOptions>();
-            services.AddConfigurableOptions<WechatOptions>();
-            services.AddConfigurableOptions<WechatPayOptions>();
-            services.AddConfigurableOptions<PayCallBackOptions>();
-            services.AddConfigurableOptions<CodeGenOptions>();
-
-            services.AddSqlSugarSetup(App.Configuration);
-
-            services.AddJwt<JwtHandler>(enableGlobalAuthorize: true);
-
-            services.AddCorsAccessor();
-            services.AddRemoteRequest();
-
-            services.AddTaskScheduler();
-
-            services.AddControllersWithViews()
-                .AddMvcFilter<RequestActionFilter>()
-                .AddNewtonsoftJson(options =>
-                {
-                    options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); // 响应驼峰命名
-                    options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss"; // 时间格式化
-                    options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; // 忽略循环引用
-                    // options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; // 忽略空值
-                })
-                .AddInjectWithUnifyResult<AdminResultProvider>();
-
-            // 注册日志事件订阅者(支持自定义消息队列组件)
-            services.AddEventBus(builder =>
-            {
-                builder.AddSubscriber<LogEventSubscriber>();
-            });
+        // 统一配置项目选项注册
+        services.AddProjectOptions();
+
+        services.AddSqlSugarSetup(App.Configuration);
+
+        services.AddJwt<JwtHandler>(enableGlobalAuthorize: true);
+
+        services.AddCorsAccessor();
+        services.AddRemoteRequest();
 
-            // 注册OSS对象存储
-            services.AddOSSService(option =>
+        services.AddTaskScheduler();
+
+        services.AddControllersWithViews()
+            .AddMvcFilter<RequestActionFilter>()
+            .AddNewtonsoftJson(options =>
             {
-                var ossOptions = App.GetOptions<OSSProviderOptions>();
-                option.Provider = (OSSProvider)ossOptions.Provider;
-                option.Endpoint = ossOptions.Endpoint;
-                option.AccessKey = ossOptions.AccessKey;
-                option.SecretKey = ossOptions.SecretKey;
-                option.Region = ossOptions.Region;
-                option.IsEnableCache = ossOptions.IsEnableCache;
-                option.IsEnableHttps = ossOptions.IsEnableHttps;
-            });
-
-            // 注册CSRedis缓存
-            services.AddCSRedisSetup();
-
-            // 注册模板引擎
-            services.AddViewEngine();
-
-            // 注册即时通讯
-            services.AddSignalR();
-
-            // 增加Logo输出显示
-            services.AddLogoDisplay();
-        }
+                options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); // 响应驼峰命名
+                options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss"; // 时间格式化
+                options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; // 忽略循环引用
+                // options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; // 忽略空值
+            })
+            .AddInjectWithUnifyResult<AdminResultProvider>();
+
+        // 注册日志事件订阅者(支持自定义消息队列组件)
+        services.AddEventBus(builder =>
+        {
+            builder.AddSubscriber<LogEventSubscriber>();
+        });
 
-        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
+        // 注册OSS对象存储
+        services.AddOSSService(option =>
         {
-            if (env.IsDevelopment())
-            {
-                app.UseDeveloperExceptionPage();
-            }
-            else
-            {
-                app.UseExceptionHandler("/Home/Error");
-                app.UseHsts();
-            }
+            var ossOptions = App.GetOptions<OSSProviderOptions>();
+            option.Provider = (OSSProvider)ossOptions.Provider;
+            option.Endpoint = ossOptions.Endpoint;
+            option.AccessKey = ossOptions.AccessKey;
+            option.SecretKey = ossOptions.SecretKey;
+            option.Region = ossOptions.Region;
+            option.IsEnableCache = ossOptions.IsEnableCache;
+            option.IsEnableHttps = ossOptions.IsEnableHttps;
+        });
+
+        // 注册CSRedis缓存
+        services.AddCSRedisSetup();
+
+        // 注册模板引擎
+        services.AddViewEngine();
+
+        // 注册即时通讯
+        services.AddSignalR();
+
+        // 增加Logo输出显示
+        services.AddLogoDisplay();
+    }
 
-            // 添加状态码拦截中间件
-            app.UseUnifyResultStatusCodes();
+    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
+    {
+        if (env.IsDevelopment())
+        {
+            app.UseDeveloperExceptionPage();
+        }
+        else
+        {
+            app.UseExceptionHandler("/Home/Error");
+            app.UseHsts();
+        }
 
-            app.UseHttpsRedirection();
-            app.UseStaticFiles();
+        // 添加状态码拦截中间件
+        app.UseUnifyResultStatusCodes();
 
-            // Serilog请求日志中间件---必须在 UseStaticFiles 和 UseRouting 之间
-            app.UseSerilogRequestLogging();
+        app.UseHttpsRedirection();
+        app.UseStaticFiles();
 
-            app.UseRouting();
+        // Serilog请求日志中间件---必须在 UseStaticFiles 和 UseRouting 之间
+        app.UseSerilogRequestLogging();
 
-            app.UseCorsAccessor();
+        app.UseRouting();
 
-            app.UseAuthentication();
-            app.UseAuthorization();
+        app.UseCorsAccessor();
 
-            app.UseInject();
+        app.UseAuthentication();
+        app.UseAuthorization();
 
-            app.UseEndpoints(endpoints =>
-            {
-                // 注册集线器
-                endpoints.MapHubs();
+        app.UseInject();
 
-                endpoints.MapControllerRoute(
-                    name: "default",
-                    pattern: "{controller=Home}/{action=Index}/{id?}");
-            });
+        app.UseEndpoints(endpoints =>
+        {
+            // 注册集线器
+            endpoints.MapHubs();
 
-            // 设置雪花Id算法机器码
-            YitIdHelper.SetIdGenerator(new IdGeneratorOptions
-            {
-                WorkerId = App.GetOptions<SnowIdOptions>().WorkerId
-            });
-        }
+            endpoints.MapControllerRoute(
+                name: "default",
+                pattern: "{controller=Home}/{action=Index}/{id?}");
+        });
+
+        // 设置雪花Id算法机器码
+        YitIdHelper.SetIdGenerator(new IdGeneratorOptions
+        {
+            WorkerId = App.GetOptions<SnowIdOptions>().WorkerId
+        });
     }
 }

+ 38 - 37
Admin.NET/Admin.NET.Web.Entry/Admin.NET.Web.Entry.csproj

@@ -4,22 +4,23 @@
 		<TargetFramework>net6.0</TargetFramework>
 		<ImplicitUsings>enable</ImplicitUsings>
 		<SatelliteResourceLanguages>en-US</SatelliteResourceLanguages>
+		<PublishReadyToRunComposite>true</PublishReadyToRunComposite>
 	</PropertyGroup>
 
 	<ItemGroup>
-	  <Compile Remove="logs\**" />
-	  <Compile Remove="publish\**" />
-	  <Content Remove="logs\**" />
-	  <Content Remove="publish\**" />
-	  <EmbeddedResource Remove="logs\**" />
-	  <EmbeddedResource Remove="publish\**" />
-	  <None Remove="logs\**" />
-	  <None Remove="publish\**" />
+		<Compile Remove="logs\**" />
+		<Compile Remove="publish\**" />
+		<Content Remove="logs\**" />
+		<Content Remove="publish\**" />
+		<EmbeddedResource Remove="logs\**" />
+		<EmbeddedResource Remove="publish\**" />
+		<None Remove="logs\**" />
+		<None Remove="publish\**" />
 	</ItemGroup>
 
 	<ItemGroup>
-	  <None Remove="Admin.NET.db" />
-	  <None Remove="Test.db" />
+		<None Remove="Admin.NET.db" />
+		<None Remove="Test.db" />
 	</ItemGroup>
 
 	<ItemGroup>
@@ -27,33 +28,33 @@
 	</ItemGroup>
 
 	<ItemGroup>
-	  <Content Update="wwwroot\Template\data.data.ts.vm">
-	    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-	  </Content>
-	  <Content Update="wwwroot\Template\dataModal.vue.vm">
-	    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-	  </Content>
-	  <Content Update="wwwroot\Template\Dto.cs.vm">
-	    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-	  </Content>
-	  <Content Update="wwwroot\Template\Entity.cs.vm">
-	    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-	  </Content>
-	  <Content Update="wwwroot\Template\index.vue.vm">
-	    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-	  </Content>
-	  <Content Update="wwwroot\Template\Input.cs.vm">
-	    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-	  </Content>
-	  <Content Update="wwwroot\Template\Manage.js.vm">
-	    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-	  </Content>
-	  <Content Update="wwwroot\Template\Output.cs.vm">
-	    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-	  </Content>
-	  <Content Update="wwwroot\Template\Service.cs.vm">
-	    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-	  </Content>
+		<Content Update="wwwroot\Template\data.data.ts.vm">
+			<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+		</Content>
+		<Content Update="wwwroot\Template\dataModal.vue.vm">
+			<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+		</Content>
+		<Content Update="wwwroot\Template\Dto.cs.vm">
+			<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+		</Content>
+		<Content Update="wwwroot\Template\Entity.cs.vm">
+			<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+		</Content>
+		<Content Update="wwwroot\Template\index.vue.vm">
+			<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+		</Content>
+		<Content Update="wwwroot\Template\Input.cs.vm">
+			<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+		</Content>
+		<Content Update="wwwroot\Template\Manage.js.vm">
+			<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+		</Content>
+		<Content Update="wwwroot\Template\Output.cs.vm">
+			<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+		</Content>
+		<Content Update="wwwroot\Template\Service.cs.vm">
+			<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+		</Content>
 	</ItemGroup>
 
 </Project>

+ 2 - 4
Admin.NET/Admin.NET.Web.Entry/Program.cs

@@ -1,4 +1,2 @@
-var builder = WebApplication.CreateBuilder(args).Inject();
-builder.Host.UseSerilogDefault();
-var app = builder.Build();
-app.Run();
+Serve.Run(RunOptions.Default
+    .ConfigureBuilder(builder => builder.Host.UseSerilogDefault()));

+ 0 - 1
Admin.NET/Admin.NET.Web.Entry/SingleFilePublish.cs

@@ -32,7 +32,6 @@ public class SingleFilePublish : ISingleFilePublish
             "Admin.NET.Application",
             "Admin.NET.Core",
             "Admin.NET.Web.Core",
-            "Furion.Extras.ObjectMapper.Mapster"    // 修复单文件 Mapster 不能映射问题
         };
     }
 }