Просмотр исходного кода

😁修复清理在线用户job问题及租户库初始化

zuohuaijun 2 лет назад
Родитель
Сommit
2b944e8118

+ 1 - 1
Admin.NET/Admin.NET.Core/Job/OnlineUserJob.cs

@@ -28,7 +28,7 @@ public class OnlineUserJob : IJob
         using var serviceScope = _scopeFactory.CreateScope();
 
         var rep = serviceScope.ServiceProvider.GetService<SqlSugarRepository<SysOnlineUser>>();
-        await rep.AsDeleteable().ExecuteCommandAsync();
+        await rep.AsDeleteable().ExecuteCommandAsync(stoppingToken);
 
         var originColor = Console.ForegroundColor;
         Console.ForegroundColor = ConsoleColor.Red;

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

@@ -367,10 +367,11 @@ public static class SqlSugarSetup
         var db = iTenant.GetConnectionScope(config.ConfigId);
         db.DbMaintenance.CreateDatabase();
 
-        // 获取所有系统表-初始化租户库表结构
-        var entityTypes = App.EffectiveTypes.Where(u => !u.IsInterface && !u.IsAbstract && u.IsClass &&
-            u.IsDefined(typeof(SugarTable), false) && !u.IsDefined(typeof(SysTableAttribute), false) && !u.IsDefined(typeof(TenantAttribute), false)).ToList();
+        // 获取所有业务表-初始化租户库表结构(排除系统表、日志表、特定库表)
+        var entityTypes = App.EffectiveTypes.Where(u => !u.IsInterface && !u.IsAbstract && u.IsClass && u.IsDefined(typeof(SugarTable), false) &&
+            !u.IsDefined(typeof(SysTableAttribute), false) && !u.IsDefined(typeof(LogTableAttribute), false) && !u.IsDefined(typeof(TenantAttribute), false)).ToList();
         if (!entityTypes.Any()) return;
+
         foreach (var entityType in entityTypes)
         {
             var splitTable = entityType.GetCustomAttribute<SplitTableAttribute>();