diff --git a/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs index e5b2d247a..0b7ed2b8b 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs @@ -80,8 +80,13 @@ namespace IRaCIS.Core.API triggerOptions.AddTrigger(); triggerOptions.AddTrigger(); + + triggerOptions.AddTrigger(); + + + }); }); diff --git a/IRaCIS.Core.Application/Triggers/BeforeSaveTrigger/UserLogTrigger.cs b/IRaCIS.Core.Application/Triggers/BeforeSaveTrigger/UserLogTrigger.cs index fcc21dc52..54e3bfbb6 100644 --- a/IRaCIS.Core.Application/Triggers/BeforeSaveTrigger/UserLogTrigger.cs +++ b/IRaCIS.Core.Application/Triggers/BeforeSaveTrigger/UserLogTrigger.cs @@ -58,6 +58,13 @@ namespace IRaCIS.Core.Application.Triggers await _userReposiotry.BatchUpdateNoTrackingAsync(t => t.EMail == user.EMail, u => new User() { IsFirstAdd = true }); } + + //只用初始化其中一个 + if (beforeUser.IsFirstAdd == true && user.IsFirstAdd == false) + { + + await _userReposiotry.BatchUpdateNoTrackingAsync(t => t.EMail == user.EMail, u => new User() { IsFirstAdd = false }); + } if (beforeUser.Password != user.Password) { @@ -67,13 +74,44 @@ namespace IRaCIS.Core.Application.Triggers if (beforeUser.EMail != user.EMail) { - await _userReposiotry.BatchUpdateNoTrackingAsync(t => t.EMail == user.EMail, u => new User() { EMail = user.EMail }); + await _userReposiotry.BatchUpdateNoTrackingAsync(t => t.EMail == beforeUser.EMail, u => new User() { EMail = user.EMail }); } if (beforeUser.CheckCode != user.CheckCode) { await _userReposiotry.BatchUpdateNoTrackingAsync(t => t.EMail == user.EMail, u => new User() { CheckCode = user.CheckCode }); } + + if (beforeUser.FirstName != user.FirstName || beforeUser.LastName != user.LastName) + { + await _userReposiotry.BatchUpdateNoTrackingAsync(t => t.EMail == user.EMail, u => new User() { FirstName = user.FirstName, LastName = user.LastName }); + } + + if (beforeUser.Phone != user.Phone) + { + await _userReposiotry.BatchUpdateNoTrackingAsync(t => t.EMail == user.EMail, u => new User() { Phone = user.Phone }); + } + + if (beforeUser.Sex != user.Sex) + { + await _userReposiotry.BatchUpdateNoTrackingAsync(t => t.EMail == user.EMail, u => new User() { Sex = user.Sex }); + } + + if (beforeUser.IsZhiZhun != user.IsZhiZhun) + { + await _userReposiotry.BatchUpdateNoTrackingAsync(t => t.EMail == user.EMail, u => new User() { IsZhiZhun = user.IsZhiZhun, OrganizationName = user.OrganizationName }); + } + + if (beforeUser.OrganizationName != user.OrganizationName) + { + await _userReposiotry.BatchUpdateNoTrackingAsync(t => t.EMail == user.EMail, u => new User() { OrganizationName = user.OrganizationName }); + } + + if (beforeUser.DepartmentName != user.DepartmentName || beforeUser.PositionName != user.PositionName) + { + await _userReposiotry.BatchUpdateNoTrackingAsync(t => t.EMail == user.EMail, u => new User() { DepartmentName = user.DepartmentName, PositionName = user.PositionName }); + } + } }