Forráskód Böngészése

!1969 解决在事件总线中给更新人信息重新赋值NULL的问题

Merge pull request !1969 from 贺灿悔/v2
zuohuaijun 1 hónapja
szülő
commit
77ee5943a2
1 módosított fájl, 7 hozzáadás és 4 törlés
  1. 7 4
      Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs

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

@@ -241,10 +241,6 @@ public static class SqlSugarSetup
             {
                 if (entityInfo.PropertyName == nameof(EntityBase.UpdateTime))
                     entityInfo.SetValue(DateTime.Now);
-                else if (entityInfo.PropertyName == nameof(EntityBase.UpdateUserId))
-                    entityInfo.SetValue(App.User?.FindFirst(ClaimConst.UserId)?.Value);
-                else if (entityInfo.PropertyName == nameof(EntityBase.UpdateUserName))
-                    entityInfo.SetValue(App.User?.FindFirst(ClaimConst.RealName)?.Value);
                 else if (entityInfo.PropertyName == nameof(EntityBaseDel.DeleteTime))
                 {
                     dynamic entityValue = entityInfo.EntityValue;
@@ -254,6 +250,13 @@ public static class SqlSugarSetup
                         entityInfo.SetValue(DateTime.Now);
                     }
                 }
+                // 若当前用户为空(非web线程时)
+                if (App.User == null) return;
+
+                if (entityInfo.PropertyName == nameof(EntityBase.UpdateUserId))
+                    entityInfo.SetValue(App.User?.FindFirst(ClaimConst.UserId)?.Value);
+                else if (entityInfo.PropertyName == nameof(EntityBase.UpdateUserName))
+                    entityInfo.SetValue(App.User?.FindFirst(ClaimConst.RealName)?.Value);
             }
         };