diff --git a/src/Shentun.Peis.Domain/Data/CustomerAuditPropertySetter.cs b/src/Shentun.Peis.Domain/Data/CustomerAuditPropertySetter.cs index 1c761a1..2991a7a 100644 --- a/src/Shentun.Peis.Domain/Data/CustomerAuditPropertySetter.cs +++ b/src/Shentun.Peis.Domain/Data/CustomerAuditPropertySetter.cs @@ -1,4 +1,5 @@ -using System; +using Microsoft.Extensions.Configuration; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -24,16 +25,20 @@ namespace Shentun.Peis.Data { protected ICurrentUser CurrentUser { get; } protected ICurrentTenant CurrentTenant { get; } + + private readonly IConfiguration _configuration; protected IClock Clock { get; } public CustomerAuditPropertySetter( ICurrentUser currentUser, ICurrentTenant currentTenant, - IClock clock) + IClock clock, + IConfiguration configuration) { CurrentUser = currentUser; CurrentTenant = currentTenant; Clock = clock; + _configuration = configuration; } public void SetCreationProperties(object targetObject) @@ -71,10 +76,12 @@ namespace Shentun.Peis.Data { if (!CurrentUser.Id.HasValue) { + var defaultCreatorId = _configuration.GetValue("AdminId"); + #region 无登录操作 if (targetObject is IMayHaveCreator mayHaveCreatorObjectNoLogin) { - ObjectHelper.TrySetProperty(mayHaveCreatorObjectNoLogin, x => x.CreatorId, () => Guid.Parse("3a0c4180-107c-0c89-b25b-0bd34666dcec")); + ObjectHelper.TrySetProperty(mayHaveCreatorObjectNoLogin, x => x.CreatorId, () => Guid.Parse(defaultCreatorId)); } #endregion return; @@ -135,9 +142,9 @@ namespace Shentun.Peis.Data { //modificationAuditedObject.LastModifierId = null; //return; - + var defaultCreatorId = _configuration.GetValue("AdminId"); #region 无登录操作 - modificationAuditedObject.LastModifierId = Guid.Parse("3a0c4180-107c-0c89-b25b-0bd34666dcec"); + modificationAuditedObject.LastModifierId = Guid.Parse(defaultCreatorId); return; #endregion } diff --git a/test/Shentun.Peis.TestBase/Security/FakeCurrentPrincipalAccessor.cs b/test/Shentun.Peis.TestBase/Security/FakeCurrentPrincipalAccessor.cs index da0a592..4de5699 100644 --- a/test/Shentun.Peis.TestBase/Security/FakeCurrentPrincipalAccessor.cs +++ b/test/Shentun.Peis.TestBase/Security/FakeCurrentPrincipalAccessor.cs @@ -27,7 +27,7 @@ public class FakeCurrentPrincipalAccessor : ThreadCurrentPrincipalAccessor new ClaimsIdentity( new List { - new Claim(AbpClaimTypes.UserId,"2e701e62-0953-4dd3-910b-dc6cc93ccb0d"), + new Claim(AbpClaimTypes.UserId,"3a0c4180-107c-0c89-b25b-0bd34666dcec"), new Claim(AbpClaimTypes.UserName,"admin"), new Claim(AbpClaimTypes.Email,"admin@abp.io") }