Parcourir la source

😁1、增加日志分库配置及特性 2、修改系统表特性名称

zuohuaijun il y a 2 ans
Parent
commit
c245e93f49
47 fichiers modifiés avec 112 ajouts et 64 suppressions
  1. 23 4
      Admin.NET/Admin.NET.Application/Configuration/Database.json
  2. 19 0
      Admin.NET/Admin.NET.Core/Attribute/LogTableAttribute.cs
  3. 1 1
      Admin.NET/Admin.NET.Core/Attribute/SysTableAttribute.cs
  4. 6 1
      Admin.NET/Admin.NET.Core/Const/SqlSugarConst.cs
  5. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysCodeGen.cs
  6. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysCodeGenConfig.cs
  7. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysConfig.cs
  8. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysDictData.cs
  9. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysDictType.cs
  10. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysFile.cs
  11. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysJobCluster.cs
  12. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysJobDetail.cs
  13. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysJobTrigger.cs
  14. 2 1
      Admin.NET/Admin.NET.Core/Entity/SysLogAudit.cs
  15. 2 1
      Admin.NET/Admin.NET.Core/Entity/SysLogDiff.cs
  16. 2 1
      Admin.NET/Admin.NET.Core/Entity/SysLogEx.cs
  17. 2 1
      Admin.NET/Admin.NET.Core/Entity/SysLogOp.cs
  18. 2 1
      Admin.NET/Admin.NET.Core/Entity/SysLogVis.cs
  19. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysMenu.cs
  20. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysNotice.cs
  21. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysNoticeUser.cs
  22. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysOnlineUser.cs
  23. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysOrg.cs
  24. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysPlugin.cs
  25. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysPos.cs
  26. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysPrint.cs
  27. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysRegion.cs
  28. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysRole.cs
  29. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysRoleMenu.cs
  30. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysRoleOrg.cs
  31. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysTenant.cs
  32. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysUser.cs
  33. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysUserExtOrg.cs
  34. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysUserRole.cs
  35. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysWechatPay.cs
  36. 1 1
      Admin.NET/Admin.NET.Core/Entity/SysWechatUser.cs
  37. 1 1
      Admin.NET/Admin.NET.Core/Extension/RepositoryExtension.cs
  38. 1 1
      Admin.NET/Admin.NET.Core/Option/DbConnectionOptions.cs
  39. 1 1
      Admin.NET/Admin.NET.Core/SeedData/SysTenantSeedData.cs
  40. 5 5
      Admin.NET/Admin.NET.Core/Service/CodeGen/CustomViewEngine.cs
  41. 1 1
      Admin.NET/Admin.NET.Core/Service/CodeGen/SysCodeGenConfigService.cs
  42. 3 3
      Admin.NET/Admin.NET.Core/Service/CodeGen/SysCodeGenService.cs
  43. 2 2
      Admin.NET/Admin.NET.Core/Service/DataBase/SysDatabaseService.cs
  44. 4 4
      Admin.NET/Admin.NET.Core/Service/Tenant/SysTenantService.cs
  45. 1 1
      Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarFilter.cs
  46. 4 4
      Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarRepository.cs
  47. 3 3
      Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs

+ 23 - 4
Admin.NET/Admin.NET.Application/Configuration/Database.json

@@ -5,6 +5,7 @@
   "DbConnection": {
     "ConnectionConfigs": [
       {
+        "ConfigId": "1300000000001", // 默认库标识-禁止修改
         "DbType": "Sqlite", // MySql、SqlServer、Sqlite、Oracle、PostgreSQL、Dm、Kdbndp、Oscar、MySqlConnector、Access、OpenGauss、QuestDB、HG、ClickHouse、GBase、Odbc、Custom
         "ConnectionString": "DataSource=./Admin.NET.db", // 库连接字符串
         "DbSettings": {
@@ -14,11 +15,29 @@
         },
         "TableSettings": {
           "EnableInitTable": true, // 启用表初始化
-          "EnableIncreTable": false // 启用表增量更新
+          "EnableIncreTable": false // 启用表增量更新-特性[IncreTable]
         },
         "SeedSettings": {
           "EnableInitSeed": true, // 启用种子初始化
-          "EnableIncreSeed": false // 启用种子增量更新
+          "EnableIncreSeed": false // 启用种子增量更新-特性[IncreSeed]
+        }
+      },
+      {
+        "ConfigId": "1300000000002", // 日志库标识-禁止修改
+        "DbType": "Sqlite",
+        "ConnectionString": "DataSource=./Admin.NET.Log.db", // 库连接字符串
+        "DbSettings": {
+          "EnableInitDb": true, // 启用库初始化
+          "EnableDiffLog": false, // 启用库表差异日志
+          "EnableUnderLine": false // 启用驼峰转下划线
+        },
+        "TableSettings": {
+          "EnableInitTable": true, // 启用表初始化
+          "EnableIncreTable": false // 启用表增量更新-特性[IncreTable]
+        },
+        "SeedSettings": {
+          "EnableInitSeed": false, // 启用种子初始化
+          "EnableIncreSeed": false // 启用种子增量更新-特性[IncreSeed]
         }
       },
       // 其他数据库配置(可以配置多个)
@@ -33,11 +52,11 @@
         },
         "TableSettings": {
           "EnableInitTable": true, // 启用表初始化
-          "EnableIncreTable": false // 启用表增量更新
+          "EnableIncreTable": false // 启用表增量更新-特性[IncreTable]
         },
         "SeedSettings": {
           "EnableInitSeed": true, // 启用种子初始化
-          "EnableIncreSeed": false // 启用种子增量更新
+          "EnableIncreSeed": false // 启用种子增量更新-特性[IncreSeed]
         }
       }
     ]

+ 19 - 0
Admin.NET/Admin.NET.Core/Attribute/LogTableAttribute.cs

@@ -0,0 +1,19 @@
+// 麻省理工学院许可证
+//
+// 版权所有 (c) 2021-2023 zuohuaijun,大名科技(天津)有限公司  联系电话/微信:18020030720  QQ:515096995
+//
+// 特此免费授予获得本软件的任何人以处理本软件的权利,但须遵守以下条件:在所有副本或重要部分的软件中必须包括上述版权声明和本许可声明。
+//
+// 软件按“原样”提供,不提供任何形式的明示或暗示的保证,包括但不限于对适销性、适用性和非侵权的保证。
+// 在任何情况下,作者或版权持有人均不对任何索赔、损害或其他责任负责,无论是因合同、侵权或其他方式引起的,与软件或其使用或其他交易有关。
+
+namespace Admin.NET.Core;
+
+/// <summary>
+/// 日志表特性
+/// </summary>
+[SuppressSniffer]
+[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
+public class LogTableAttribute : Attribute
+{
+}

+ 1 - 1
Admin.NET/Admin.NET.Core/Attribute/SystemTableAttribute.cs → Admin.NET/Admin.NET.Core/Attribute/SysTableAttribute.cs

@@ -14,6 +14,6 @@ namespace Admin.NET.Core;
 /// </summary>
 [SuppressSniffer]
 [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
-public class SystemTableAttribute : Attribute
+public class SysTableAttribute : Attribute
 {
 }

+ 6 - 1
Admin.NET/Admin.NET.Core/Const/SqlSugarConst.cs

@@ -17,7 +17,12 @@ public class SqlSugarConst
     /// <summary>
     /// 默认数据库标识(默认租户)
     /// </summary>
-    public const string ConfigId = "1300000000001";
+    public const string MainConfigId = "1300000000001";
+
+    /// <summary>
+    /// 日志数据库标识
+    /// </summary>
+    public const string LogConfigId = "1300000000002";
 
     /// <summary>
     /// 默认表主键

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysCodeGen.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 代码生成表
 /// </summary>
 [SugarTable(null, "代码生成表")]
-[SystemTable]
+[SysTable]
 public class SysCodeGen : EntityBase
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysCodeGenConfig.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 代码生成字段配置表
 /// </summary>
 [SugarTable(null, "代码生成字段配置表")]
-[SystemTable]
+[SysTable]
 public class SysCodeGenConfig : EntityBase
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysConfig.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 系统参数配置表
 /// </summary>
 [SugarTable(null, "系统参数配置表")]
-[SystemTable]
+[SysTable]
 public class SysConfig : EntityBase
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysDictData.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 系统字典值表
 /// </summary>
 [SugarTable(null, "系统字典值表")]
-[SystemTable]
+[SysTable]
 public class SysDictData : EntityBase
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysDictType.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 系统字典类型表
 /// </summary>
 [SugarTable(null, "系统字典类型表")]
-[SystemTable]
+[SysTable]
 public class SysDictType : EntityBase
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysFile.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 系统文件表
 /// </summary>
 [SugarTable(null, "系统文件表")]
-[SystemTable]
+[SysTable]
 public class SysFile : EntityBase
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysJobCluster.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 系统作业集群表
 /// </summary>
 [SugarTable(null, "系统作业集群表")]
-[SystemTable]
+[SysTable]
 public class SysJobCluster : EntityBaseId
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysJobDetail.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 系统作业信息表
 /// </summary>
 [SugarTable(null, "系统作业信息表")]
-[SystemTable]
+[SysTable]
 public class SysJobDetail : EntityBaseId
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysJobTrigger.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 系统作业触发器表
 /// </summary>
 [SugarTable(null, "系统作业触发器表")]
-[SystemTable]
+[SysTable]
 public class SysJobTrigger : EntityBaseId
 {
     /// <summary>

+ 2 - 1
Admin.NET/Admin.NET.Core/Entity/SysLogAudit.cs

@@ -13,7 +13,8 @@ namespace Admin.NET.Core;
 /// 系统审计日志表
 /// </summary>
 [SugarTable(null, "系统审计日志表")]
-[SystemTable]
+[SysTable]
+[LogTable]
 public class SysLogAudit : EntityBase
 {
     /// <summary>

+ 2 - 1
Admin.NET/Admin.NET.Core/Entity/SysLogDiff.cs

@@ -13,7 +13,8 @@ namespace Admin.NET.Core;
 /// 系统差异日志表
 /// </summary>
 [SugarTable(null, "系统差异日志表")]
-[SystemTable]
+[SysTable]
+[LogTable]
 public class SysLogDiff : EntityBase
 {
     /// <summary>

+ 2 - 1
Admin.NET/Admin.NET.Core/Entity/SysLogEx.cs

@@ -13,7 +13,8 @@ namespace Admin.NET.Core;
 /// 系统异常日志表
 /// </summary>
 [SugarTable(null, "系统异常日志表")]
-[SystemTable]
+[SysTable]
+[LogTable]
 public class SysLogEx : SysLogVis
 {
     /// <summary>

+ 2 - 1
Admin.NET/Admin.NET.Core/Entity/SysLogOp.cs

@@ -13,7 +13,8 @@ namespace Admin.NET.Core;
 /// 系统操作日志表
 /// </summary>
 [SugarTable(null, "系统操作日志表")]
-[SystemTable]
+[SysTable]
+[LogTable]
 public class SysLogOp : SysLogVis
 {
     /// <summary>

+ 2 - 1
Admin.NET/Admin.NET.Core/Entity/SysLogVis.cs

@@ -13,7 +13,8 @@ namespace Admin.NET.Core;
 /// 系统访问日志表
 /// </summary>
 [SugarTable(null, "系统访问日志表")]
-[SystemTable]
+[SysTable]
+[LogTable]
 public class SysLogVis : EntityTenant
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysMenu.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 系统菜单表
 /// </summary>
 [SugarTable(null, "系统菜单表")]
-[SystemTable]
+[SysTable]
 public class SysMenu : EntityBase
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysNotice.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 系统通知公告表
 /// </summary>
 [SugarTable(null, "系统通知公告表")]
-[SystemTable]
+[SysTable]
 public class SysNotice : EntityBase
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysNoticeUser.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 系统通知公告用户表
 /// </summary>
 [SugarTable(null, "系统通知公告用户表")]
-[SystemTable]
+[SysTable]
 public class SysNoticeUser
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysOnlineUser.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 系统在线用户表
 /// </summary>
 [SugarTable(null, "系统在线用户表")]
-[SystemTable]
+[SysTable]
 public class SysOnlineUser : EntityTenantId
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysOrg.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 系统机构表
 /// </summary>
 [SugarTable(null, "系统机构表")]
-[SystemTable]
+[SysTable]
 public class SysOrg : EntityTenant
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysPlugin.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 系统动态插件表
 /// </summary>
 [SugarTable(null, "系统动态插件表")]
-[SystemTable]
+[SysTable]
 public class SysPlugin : EntityTenant
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysPos.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 系统职位表
 /// </summary>
 [SugarTable(null, "系统职位表")]
-[SystemTable]
+[SysTable]
 public class SysPos : EntityTenant
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysPrint.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 系统打印模板表
 /// </summary>
 [SugarTable(null, "系统打印模板表")]
-[SystemTable]
+[SysTable]
 public class SysPrint : EntityTenant
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysRegion.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 系统行政地区表
 /// </summary>
 [SugarTable(null, "系统行政地区表")]
-[SystemTable]
+[SysTable]
 public class SysRegion : EntityBaseId
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysRole.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 系统角色表
 /// </summary>
 [SugarTable(null, "系统角色表")]
-[SystemTable]
+[SysTable]
 public class SysRole : EntityTenant
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysRoleMenu.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 系统角色菜单表
 /// </summary>
 [SugarTable(null, "系统角色菜单表")]
-[SystemTable]
+[SysTable]
 public class SysRoleMenu : EntityBaseId
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysRoleOrg.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 系统角色机构表
 /// </summary>
 [SugarTable(null, "系统角色机构表")]
-[SystemTable]
+[SysTable]
 public class SysRoleOrg : EntityBaseId
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysTenant.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 系统租户表
 /// </summary>
 [SugarTable(null, "系统租户表")]
-[SystemTable]
+[SysTable]
 public class SysTenant : EntityBase
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysUser.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 系统用户表
 /// </summary>
 [SugarTable(null, "系统用户表")]
-[SystemTable]
+[SysTable]
 public class SysUser : EntityTenant
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysUserExtOrg.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 系统用户扩展机构表
 /// </summary>
 [SugarTable(null, "系统用户扩展机构表")]
-[SystemTable]
+[SysTable]
 public class SysUserExtOrg : EntityBaseId
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysUserRole.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 系统用户角色表
 /// </summary>
 [SugarTable(null, "系统用户角色表")]
-[SystemTable]
+[SysTable]
 public class SysUserRole : EntityBaseId
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysWechatPay.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 系统微信支付表
 /// </summary>
 [SugarTable(null, "系统微信支付表")]
-[SystemTable]
+[SysTable]
 public class SysWechatPay : EntityBase
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Entity/SysWechatUser.cs

@@ -13,7 +13,7 @@ namespace Admin.NET.Core;
 /// 系统微信用户表
 /// </summary>
 [SugarTable(null, "系统微信用户表")]
-[SystemTable]
+[SysTable]
 public class SysWechatUser : EntityBase
 {
     /// <summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Extension/RepositoryExtension.cs

@@ -270,7 +270,7 @@ public static class RepositoryExtension
     {
         var entityType = typeof(T);
         var attr = entityType.GetCustomAttribute<TenantAttribute>();
-        var configId = attr == null ? SqlSugarConst.ConfigId : attr.configId.ToString();
+        var configId = attr == null ? SqlSugarConst.MainConfigId : attr.configId.ToString();
         var tableName = entityType.GetCustomAttribute<SugarTable>().TableName;
         return new Tuple<string, string>(configId, tableName);
     }

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

@@ -24,7 +24,7 @@ public sealed class DbConnectionOptions : IConfigurableOptions<DbConnectionOptio
         foreach (var dbConfig in options.ConnectionConfigs)
         {
             if (string.IsNullOrWhiteSpace(dbConfig.ConfigId))
-                dbConfig.ConfigId = SqlSugarConst.ConfigId;
+                dbConfig.ConfigId = SqlSugarConst.MainConfigId;
         }
     }
 }

+ 1 - 1
Admin.NET/Admin.NET.Core/SeedData/SysTenantSeedData.cs

@@ -24,7 +24,7 @@ public class SysTenantSeedData : ISqlSugarEntitySeedData<SysTenant>
 
         return new[]
         {
-            new SysTenant{ Id=1300000000001, OrgId=1300000000101, UserId=1300000000111, Host="www.dilon.vip", TenantType=TenantTypeEnum.Id, DbType=defaultDbConfig.DbType, Connection=defaultDbConfig.ConnectionString, ConfigId=SqlSugarConst.ConfigId, Remark="系统默认", CreateTime=DateTime.Parse("2022-02-10 00:00:00") },
+            new SysTenant{ Id=1300000000001, OrgId=1300000000101, UserId=1300000000111, Host="www.dilon.vip", TenantType=TenantTypeEnum.Id, DbType=defaultDbConfig.DbType, Connection=defaultDbConfig.ConnectionString, ConfigId=SqlSugarConst.MainConfigId, Remark="系统默认", CreateTime=DateTime.Parse("2022-02-10 00:00:00") },
         };
     }
 }

+ 5 - 5
Admin.NET/Admin.NET.Core/Service/CodeGen/CustomViewEngine.cs

@@ -25,7 +25,7 @@ public class CustomViewEngine : ViewEngineModel
     /// <summary>
     /// 库定位器
     /// </summary>
-    public string ConfigId { get; set; } = SqlSugarConst.ConfigId;
+    public string ConfigId { get; set; } = SqlSugarConst.MainConfigId;
 
     public string AuthorName { get; set; }
 
@@ -68,16 +68,16 @@ public class CustomViewEngine : ViewEngineModel
     public List<ColumnOuput> GetColumnListByTableName(string tableName)
     {
         // 多库代码生成切换库
-        var provider = _db.AsTenant().GetConnectionScope(ConfigId != SqlSugarConst.ConfigId ? ConfigId : SqlSugarConst.ConfigId);
+        var provider = _db.AsTenant().GetConnectionScope(ConfigId != SqlSugarConst.MainConfigId ? ConfigId : SqlSugarConst.MainConfigId);
 
         // 获取实体类型属性
         var entityType = provider.DbMaintenance.GetTableInfoList().FirstOrDefault(u => u.Name == tableName);
 
         // 因为ConfigId的表通常也会用到主库的表来做连接,所以这里如果在ConfigId中找不到实体也尝试一下在主库中查找
-        if (ConfigId == SqlSugarConst.ConfigId && entityType == null) return null;
-        if (ConfigId != SqlSugarConst.ConfigId)
+        if (ConfigId == SqlSugarConst.MainConfigId && entityType == null) return null;
+        if (ConfigId != SqlSugarConst.MainConfigId)
         {
-            provider = _db.AsTenant().GetConnectionScope(SqlSugarConst.ConfigId);
+            provider = _db.AsTenant().GetConnectionScope(SqlSugarConst.MainConfigId);
             entityType = provider.DbMaintenance.GetTableInfoList().FirstOrDefault(u => u.Name == tableName);
             if (entityType == null) return null;
         }

+ 1 - 1
Admin.NET/Admin.NET.Core/Service/CodeGen/SysCodeGenConfigService.cs

@@ -135,7 +135,7 @@ public class SysCodeGenConfigService : IDynamicApiController, ITransient
             orderNo += 10; // 每个配置排序间隔10
         }
         // 多库代码生成---这里要切回主库
-        var provider = _db.AsTenant().GetConnectionScope(SqlSugarConst.ConfigId);
+        var provider = _db.AsTenant().GetConnectionScope(SqlSugarConst.MainConfigId);
         provider.Insertable(codeGenConfigs).ExecuteCommand();
     }
 

+ 3 - 3
Admin.NET/Admin.NET.Core/Service/CodeGen/SysCodeGenService.cs

@@ -132,7 +132,7 @@ public class SysCodeGenService : IDynamicApiController, ITransient
     /// </summary>
     /// <returns></returns>
     [DisplayName("获取数据库表(实体)集合")]
-    public async Task<List<TableOutput>> GetTableList(string configId = SqlSugarConst.ConfigId)
+    public async Task<List<TableOutput>> GetTableList(string configId = SqlSugarConst.MainConfigId)
     {
         var provider = _db.AsTenant().GetConnectionScope(configId);
         var dbTableInfos = provider.DbMaintenance.GetTableInfoList(false); // 不能走缓存,否则切库不起作用
@@ -163,7 +163,7 @@ public class SysCodeGenService : IDynamicApiController, ITransient
     /// </summary>
     /// <returns></returns>
     [DisplayName("根据表名获取列集合")]
-    public List<ColumnOuput> GetColumnListByTableName([Required] string tableName, string configId = SqlSugarConst.ConfigId)
+    public List<ColumnOuput> GetColumnListByTableName([Required] string tableName, string configId = SqlSugarConst.MainConfigId)
     {
         // 切库---多库代码生成用
         var provider = _db.AsTenant().GetConnectionScope(configId);
@@ -195,7 +195,7 @@ public class SysCodeGenService : IDynamicApiController, ITransient
             return null;
 
         // 切库---多库代码生成用
-        var provider = _db.AsTenant().GetConnectionScope(!string.IsNullOrEmpty(input.ConfigId) ? input.ConfigId : SqlSugarConst.ConfigId);
+        var provider = _db.AsTenant().GetConnectionScope(!string.IsNullOrEmpty(input.ConfigId) ? input.ConfigId : SqlSugarConst.MainConfigId);
 
         var config = App.GetOptions<DbConnectionOptions>().ConnectionConfigs.FirstOrDefault(u => u.ConfigId == input.ConfigId);
         var dbTableName = config.DbSettings.EnableUnderLine ? UtilMethods.ToUnderLine(entityType.DbTableName) : entityType.DbTableName;

+ 2 - 2
Admin.NET/Admin.NET.Core/Service/DataBase/SysDatabaseService.cs

@@ -46,7 +46,7 @@ public class SysDatabaseService : IDynamicApiController, ITransient
     /// <returns></returns>
     [AllowAnonymous]
     [DisplayName("获取字段列表")]
-    public List<DbColumnOutput> GetColumnList(string tableName, string configId = SqlSugarConst.ConfigId)
+    public List<DbColumnOutput> GetColumnList(string tableName, string configId = SqlSugarConst.MainConfigId)
     {
         var db = _db.AsTenant().GetConnectionScope(configId);
         if (string.IsNullOrWhiteSpace(tableName))
@@ -114,7 +114,7 @@ public class SysDatabaseService : IDynamicApiController, ITransient
     /// <param name="configId">ConfigId</param>
     /// <returns></returns>
     [DisplayName("获取表列表")]
-    public List<DbTableInfo> GetTableList(string configId = SqlSugarConst.ConfigId)
+    public List<DbTableInfo> GetTableList(string configId = SqlSugarConst.MainConfigId)
     {
         var db = _db.AsTenant().GetConnectionScope(configId);
         return db.DbMaintenance.GetTableInfoList(false);

+ 4 - 4
Admin.NET/Admin.NET.Core/Service/Tenant/SysTenantService.cs

@@ -138,7 +138,7 @@ public class SysTenantService : IDynamicApiController, ITransient
     public async Task<int> SetStatus(TenantInput input)
     {
         var tenant = await _sysTenantRep.GetFirstAsync(u => u.Id == input.Id);
-        if (tenant == null || tenant.ConfigId == SqlSugarConst.ConfigId)
+        if (tenant == null || tenant.ConfigId == SqlSugarConst.MainConfigId)
             throw Oops.Oh(ErrorCodeEnum.Z1001);
 
         if (!Enum.IsDefined(typeof(StatusEnum), input.Status))
@@ -241,7 +241,7 @@ public class SysTenantService : IDynamicApiController, ITransient
     public async Task DeleteTenant(DeleteTenantInput input)
     {
         // 禁止删除默认租户
-        if (input.Id.ToString() == SqlSugarConst.ConfigId)
+        if (input.Id.ToString() == SqlSugarConst.MainConfigId)
             throw Oops.Oh(ErrorCodeEnum.D1023);
 
         await _sysTenantRep.DeleteAsync(u => u.Id == input.Id);
@@ -348,11 +348,11 @@ public class SysTenantService : IDynamicApiController, ITransient
 
         var iTenant = _sysTenantRep.AsTenant();
         var tenantList = await _sysTenantRep.GetListAsync();
-        var defaultTenant = tenantList.FirstOrDefault(u => u.Id.ToString() == SqlSugarConst.ConfigId);
+        var defaultTenant = tenantList.FirstOrDefault(u => u.Id.ToString() == SqlSugarConst.MainConfigId);
         foreach (var tenant in tenantList)
         {
             var tenantId = tenant.Id.ToString();
-            if (tenantId == SqlSugarConst.ConfigId) continue;
+            if (tenantId == SqlSugarConst.MainConfigId) continue;
 
             // Id模式隔离的租户数据库与宿主一致
             if (tenant.TenantType == TenantTypeEnum.Id)

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

@@ -153,7 +153,7 @@ public static class SqlSugarFilter
                     // 排除非当前数据库实体
                     var tAtt = entityType.GetCustomAttribute<TenantAttribute>();
                     if ((tAtt != null && db.CurrentConnectionConfig.ConfigId.ToString() != tAtt.configId.ToString()) ||
-                        (tAtt == null && db.CurrentConnectionConfig.ConfigId.ToString() != SqlSugarConst.ConfigId))
+                        (tAtt == null && db.CurrentConnectionConfig.ConfigId.ToString() != SqlSugarConst.MainConfigId))
                         return;
 
                     tableFilterItems.Add(tableFilterItem);

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

@@ -29,15 +29,15 @@ public class SqlSugarRepository<T> : SimpleClient<T> where T : class, new()
         }
 
         // 若实体贴有系统表特性,则返回默认的连接
-        if (typeof(T).IsDefined(typeof(SystemTableAttribute), false))
+        if (typeof(T).IsDefined(typeof(SysTableAttribute), false))
         {
-            base.Context = iTenant.GetConnectionScope(SqlSugarConst.ConfigId);
+            base.Context = iTenant.GetConnectionScope(SqlSugarConst.MainConfigId);
             return;
         }
 
         // 若当前未登录或是默认租户Id,则返回默认的连接
         var tenantId = App.GetRequiredService<UserManager>().TenantId;
-        if (tenantId < 1 || tenantId.ToString() == SqlSugarConst.ConfigId) return;
+        if (tenantId < 1 || tenantId.ToString() == SqlSugarConst.MainConfigId) return;
 
         var tenant = App.GetRequiredService<SysCacheService>().Get<List<SysTenant>>(CacheConst.KeyTenant).FirstOrDefault(u => u.Id == tenantId);
         if (tenant is null || tenant is { TenantType: TenantTypeEnum.Id }) return;
@@ -47,7 +47,7 @@ public class SqlSugarRepository<T> : SimpleClient<T> where T : class, new()
         {
             // 获取主库连接配置
             var dbOptions = App.GetOptions<DbConnectionOptions>();
-            var mainConnConfig = dbOptions.ConnectionConfigs.First(u => u.ConfigId == SqlSugarConst.ConfigId);
+            var mainConnConfig = dbOptions.ConnectionConfigs.First(u => u.ConfigId == SqlSugarConst.MainConfigId);
 
             // 连接配置
             var connectionConfig = new DbConnectionConfig

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

@@ -283,7 +283,7 @@ public static class SqlSugarSetup
                 {
                     var tAtt = entityType.GetCustomAttribute<TenantAttribute>();
                     if (tAtt != null && tAtt.configId.ToString() != config.ConfigId) continue;
-                    if (tAtt == null && config.ConfigId != SqlSugarConst.ConfigId) continue;
+                    if (tAtt == null && config.ConfigId != SqlSugarConst.MainConfigId) continue;
 
                     if (entityType.GetCustomAttribute<SplitTableAttribute>() == null)
                         dbProvider.CodeFirst.InitTables(entityType);
@@ -311,7 +311,7 @@ public static class SqlSugarSetup
                     var entityType = seedType.GetInterfaces().First().GetGenericArguments().First();
                     var tAtt = entityType.GetCustomAttribute<TenantAttribute>();
                     if (tAtt != null && tAtt.configId.ToString() != config.ConfigId) continue;
-                    if (tAtt == null && config.ConfigId != SqlSugarConst.ConfigId) continue;
+                    if (tAtt == null && config.ConfigId != SqlSugarConst.MainConfigId) continue;
 
                     var entityInfo = dbProvider.EntityMaintenance.GetEntityInfo(entityType);
                     if (entityInfo.Columns.Any(u => u.IsPrimarykey))
@@ -347,7 +347,7 @@ public static class SqlSugarSetup
 
         // 获取所有实体表-初始化租户业务表
         var entityTypes = App.EffectiveTypes.Where(u => !u.IsInterface && !u.IsAbstract && u.IsClass
-            && u.IsDefined(typeof(SugarTable), false) && !u.IsDefined(typeof(SystemTableAttribute), false)).ToList();
+            && u.IsDefined(typeof(SugarTable), false) && !u.IsDefined(typeof(SysTableAttribute), false)).ToList();
         if (!entityTypes.Any()) return;
         foreach (var entityType in entityTypes)
         {