From 038be4e4ef714710b6a76f230f4a02e55fb1ee51 Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Thu, 28 Mar 2024 20:13:22 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E6=A8=A1=E6=8B=9FId=E3=80=81=E5=88=9B=E5=BB=BA=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=97=A0Id=E9=BB=98=E8=AE=A4Id=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Data/CustomerAuditPropertySetter.cs | 17 ++++++++++++----- .../Security/FakeCurrentPrincipalAccessor.cs | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) 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") } From 10a804b01217f07df4da98cfccbe582b3843c93f Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Fri, 29 Mar 2024 17:45:09 +0800 Subject: [PATCH 2/4] 333 --- src/Shentun.Peis.Domain/DataHelper.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Shentun.Peis.Domain/DataHelper.cs b/src/Shentun.Peis.Domain/DataHelper.cs index 4bfda8b..e30e089 100644 --- a/src/Shentun.Peis.Domain/DataHelper.cs +++ b/src/Shentun.Peis.Domain/DataHelper.cs @@ -449,7 +449,7 @@ namespace Shentun.Peis /// public static void CheckIntIsGeaterThanZero(int value, string parameterName, string ExceptionMessage = "只能为大于0的值") { - if (value > 0) + if (value <= 0) { throw new UserFriendlyException($"{parameterName}{ExceptionMessage}"); } @@ -496,7 +496,7 @@ namespace Shentun.Peis /// public static void CheckDecimalIsGeaterThanZero(decimal value, string parameterName, string ExceptionMessage = "值只能大于0") { - if (value > 0) + if (value <= 0) { throw new UserFriendlyException($"{parameterName}{ExceptionMessage}"); } From f8014520171e6b2d308b6a8782f9732271aa0491 Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Fri, 29 Mar 2024 17:49:02 +0800 Subject: [PATCH 3/4] Revert "333" This reverts commit 10a804b01217f07df4da98cfccbe582b3843c93f. --- src/Shentun.Peis.Domain/DataHelper.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Shentun.Peis.Domain/DataHelper.cs b/src/Shentun.Peis.Domain/DataHelper.cs index e30e089..4bfda8b 100644 --- a/src/Shentun.Peis.Domain/DataHelper.cs +++ b/src/Shentun.Peis.Domain/DataHelper.cs @@ -449,7 +449,7 @@ namespace Shentun.Peis /// public static void CheckIntIsGeaterThanZero(int value, string parameterName, string ExceptionMessage = "只能为大于0的值") { - if (value <= 0) + if (value > 0) { throw new UserFriendlyException($"{parameterName}{ExceptionMessage}"); } @@ -496,7 +496,7 @@ namespace Shentun.Peis /// public static void CheckDecimalIsGeaterThanZero(decimal value, string parameterName, string ExceptionMessage = "值只能大于0") { - if (value <= 0) + if (value > 0) { throw new UserFriendlyException($"{parameterName}{ExceptionMessage}"); } From cf43a22c33939ff249f3479870994d69da635bd4 Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Fri, 29 Mar 2024 17:49:32 +0800 Subject: [PATCH 4/4] Revert "Revert "333"" This reverts commit f8014520171e6b2d308b6a8782f9732271aa0491. --- src/Shentun.Peis.Domain/DataHelper.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Shentun.Peis.Domain/DataHelper.cs b/src/Shentun.Peis.Domain/DataHelper.cs index 4bfda8b..e30e089 100644 --- a/src/Shentun.Peis.Domain/DataHelper.cs +++ b/src/Shentun.Peis.Domain/DataHelper.cs @@ -449,7 +449,7 @@ namespace Shentun.Peis /// public static void CheckIntIsGeaterThanZero(int value, string parameterName, string ExceptionMessage = "只能为大于0的值") { - if (value > 0) + if (value <= 0) { throw new UserFriendlyException($"{parameterName}{ExceptionMessage}"); } @@ -496,7 +496,7 @@ namespace Shentun.Peis /// public static void CheckDecimalIsGeaterThanZero(decimal value, string parameterName, string ExceptionMessage = "值只能大于0") { - if (value > 0) + if (value <= 0) { throw new UserFriendlyException($"{parameterName}{ExceptionMessage}"); }