Procházet zdrojové kódy

1、调整数据库选项配置 2、升级nuget包及其他优化

zuohuaijun před 3 roky
rodič
revize
e2f18ce1c8

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

@@ -17,9 +17,9 @@
     <PackageReference Include="AngleSharp" Version="0.17.1" />
     <PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" />
     <PackageReference Include="DotNetCore.Natasha.CSharp" Version="5.0.2" />
-    <PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.8.3.5" />
-    <PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.8.3.5" />
-    <PackageReference Include="Furion.Pure" Version="4.8.3.5" />
+    <PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.8.3.6" />
+    <PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.8.3.6" />
+    <PackageReference Include="Furion.Pure" Version="4.8.3.6" />
     <PackageReference Include="Lazy.Captcha.Core" Version="1.1.6" />
     <PackageReference Include="Magicodes.IE.Excel" Version="2.7.2" />
     <PackageReference Include="Magicodes.IE.Pdf" Version="2.7.2" />
@@ -30,7 +30,7 @@
     <PackageReference Include="OnceMi.AspNetCore.OSS" Version="1.1.9" />
     <PackageReference Include="SKIT.FlurlHttpClient.Wechat.Api" Version="2.21.1" />
     <PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="2.15.0" />
-    <PackageReference Include="SqlSugarCore" Version="5.1.3.41-preview04" />
+    <PackageReference Include="SqlSugarCore" Version="5.1.3.41-preview06" />
     <PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.23" />
     <PackageReference Include="UAParser" Version="3.1.47" />
     <PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />

+ 10 - 1
Admin.NET/Admin.NET.Core/Option/DbConnectionOptions.cs

@@ -3,12 +3,21 @@
 /// <summary>
 /// 数据库配置选项
 /// </summary>
-public sealed class DbConnectionOptions : IConfigurableOptions
+public sealed class DbConnectionOptions : IConfigurableOptions<DbConnectionOptions>
 {
     /// <summary>
     /// 数据库集合
     /// </summary>
     public List<DbConnectionConfig> ConnectionConfigs { get; set; }
+
+    public void PostConfigure(DbConnectionOptions options, IConfiguration configuration)
+    {
+        foreach (var dbConfig in options.ConnectionConfigs)
+        {
+            if (string.IsNullOrWhiteSpace(dbConfig.ConfigId))
+                dbConfig.ConfigId = SqlSugarConst.ConfigId;
+        }
+    }
 }
 
 public sealed class DbConnectionConfig : ConnectionConfig

+ 10 - 18
Admin.NET/Admin.NET.Core/Service/CodeGen/SysCodeGenService.cs

@@ -112,8 +112,8 @@ public class SysCodeGenService : IDynamicApiController, ITransient
     [HttpGet("/sysCodeGen/databaseList")]
     public async Task<List<DatabaseOutput>> GetDatabaseList()
     {
-        var dblist = await Task.FromResult(App.GetOptions<DbConnectionOptions>().ConnectionConfigs);
-        return dblist.Adapt<List<DatabaseOutput>>();
+        var dbCongigs = App.GetOptions<DbConnectionOptions>().ConnectionConfigs;
+        return await Task.FromResult(dbCongigs.Adapt<List<DatabaseOutput>>());
     }
 
     /// <summary>
@@ -123,26 +123,18 @@ public class SysCodeGenService : IDynamicApiController, ITransient
     [HttpGet("/sysCodeGen/tableList/{configId}")]
     public async Task<List<TableOutput>> GetTableList(string configId = SqlSugarConst.ConfigId)
     {
-        // 切库---多库代码生成用
         var provider = _db.AsTenant().GetConnectionScope(configId);
-        var dbTableInfos = provider.DbMaintenance.GetTableInfoList(false); // 这里不能走缓存,否则切库不起作用
-
-        var dbTableNames = dbTableInfos.Select(x => x.Name).ToList();
+        var dbTableInfos = provider.DbMaintenance.GetTableInfoList(false); // 不能走缓存,否则切库不起作用
 
+        var dbTableNames = dbTableInfos.Select(u => u.Name).ToList();
         IEnumerable<EntityInfo> entityInfos = await _commonService.GetEntityInfos();
-        entityInfos = entityInfos.Where(x => dbTableNames.Contains(x.DbTableName.ToLower()));
-        var result = new List<TableOutput>();
-        foreach (var item in entityInfos)
+        return entityInfos.Where(u => dbTableNames.Contains(u.DbTableName)).Select(u => new TableOutput()
         {
-            result.Add(new TableOutput()
-            {
-                ConfigId = configId,
-                EntityName = item.EntityName,
-                TableName = item.DbTableName.ToLower(),
-                TableComment = item.TableDescription
-            });
-        }
-        return result;
+            ConfigId = configId,
+            EntityName = u.EntityName,
+            TableName = u.DbTableName.ToLower(),
+            TableComment = u.TableDescription
+        }).ToList();
     }
 
     /// <summary>

+ 1 - 7
Admin.NET/Admin.NET.Core/Service/DataBase/SysDatabaseService.cs

@@ -22,13 +22,7 @@ public class SysDatabaseService : IDynamicApiController, ITransient
     [HttpGet("/sysDatabase/list")]
     public List<dynamic> GetDbList()
     {
-        var connectionConfigs = App.GetOptions<DbConnectionOptions>().ConnectionConfigs;
-        foreach (var config in connectionConfigs)
-        {
-            if (string.IsNullOrWhiteSpace(config.ConfigId))
-                config.ConfigId = SqlSugarConst.ConfigId;
-        }
-        return connectionConfigs.Select(u => u.ConfigId).ToList();
+        return App.GetOptions<DbConnectionOptions>().ConnectionConfigs.Select(u => u.ConfigId).ToList();
     }
 
     /// <summary>

+ 0 - 3
Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs

@@ -41,9 +41,6 @@ public static class SqlSugarSetup
     /// <param name="config"></param>
     public static void SetDbConfig(DbConnectionConfig config)
     {
-        if (string.IsNullOrWhiteSpace(config.ConfigId))
-            config.ConfigId = SqlSugarConst.ConfigId;
-
         var configureExternalServices = new ConfigureExternalServices
         {
             EntityNameService = (type, entity) => // 处理表

+ 4 - 4
Web/src/views/system/codeGen/component/editCodeGenDialog.vue

@@ -11,7 +11,7 @@
 				<el-row :gutter="35">
 					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
 						<el-form-item label="库定位器" prop="configId">
-							<el-select v-model="ruleForm.configId" placeholder="库名" filterable @change="DbChanged()" class="w100">
+							<el-select v-model="ruleForm.configId" placeholder="库名" filterable @change="dbChanged()" class="w100">
 								<el-option v-for="item in dbData" :key="item.configId" :label="item.configId" :value="item.configId" />
 							</el-select>
 						</el-form-item>
@@ -140,8 +140,8 @@ export default defineComponent({
 			state.codeGenTypeList = resDicData.data.result;
 		});
 
-		// DbChanged
-		const DbChanged = async () => {
+		// dbChanged
+		const dbChanged = async () => {
 			if (state.ruleForm.configId === '') return;
 			let res = await getAPI(SysCodeGenApi).sysCodeGenTableListConfigIdGet(state.ruleForm.configId as string);
 			state.tableData = res.data.result ?? [];
@@ -200,7 +200,7 @@ export default defineComponent({
 			cancel,
 			submit,
 			isOrNotSelect,
-			DbChanged,
+			dbChanged,
 			...toRefs(state),
 		};
 	},