Explorar o código

!554 1,解决手动给CreateUserId,CreateOrgId赋值不生效问题。
Merge pull request !554 from 适可而止/next

zuohuaijun %!s(int64=3) %!d(string=hai) anos
pai
achega
4d513b3b2d
Modificáronse 1 ficheiros con 11 adicións e 2 borrados
  1. 11 2
      Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs

+ 11 - 2
Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs

@@ -126,9 +126,18 @@ public static class SqlSugarSetup
                             entityInfo.SetValue(App.User.FindFirst(ClaimConst.TenantId)?.Value);
                     }
                     if (entityInfo.PropertyName == "CreateUserId")
-                        entityInfo.SetValue(App.User.FindFirst(ClaimConst.UserId)?.Value);
+                    {
+                        var createUserId = ((dynamic)entityInfo.EntityValue).CreateUserId;
+                        if (createUserId == 0 || createUserId == null)
+                            entityInfo.SetValue(App.User.FindFirst(ClaimConst.UserId)?.Value);
+                    }
+
                     if (entityInfo.PropertyName == "CreateOrgId")
-                        entityInfo.SetValue(App.User.FindFirst(ClaimConst.OrgId)?.Value);
+                    {
+                        var createOrgId = ((dynamic)entityInfo.EntityValue).CreateOrgId;
+                        if (createOrgId == 0 || createOrgId == null)
+                            entityInfo.SetValue(App.User.FindFirst(ClaimConst.OrgId)?.Value);
+                    }
                 }
             }
             if (entityInfo.OperationType == DataFilterType.UpdateByObject)