From ae52ce23901fa3293fb81601ea495fc62d873be4 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Wed, 8 May 2024 12:02:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=85=AC=E5=85=B1=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=AE=A1=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tiobon.Core.Common/DB/Aop/SqlsugarAop.cs | 28 +++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/Tiobon.Core.Common/DB/Aop/SqlsugarAop.cs b/Tiobon.Core.Common/DB/Aop/SqlsugarAop.cs index 015ac7b5..81687b69 100644 --- a/Tiobon.Core.Common/DB/Aop/SqlsugarAop.cs +++ b/Tiobon.Core.Common/DB/Aop/SqlsugarAop.cs @@ -86,7 +86,7 @@ public static class SqlSugarAop // var getType = entityInfo.EntityValue.GetType(); - + int userId = Convert.ToInt32(App.User.ID); switch (entityInfo.OperationType) { case DataFilterType.InsertByObject: @@ -94,7 +94,18 @@ public static class SqlSugarAop var dyCreateTime = getType.GetProperty("CreateTime"); if (App.User?.ID > 0 && dyCreateBy != null && dyCreateBy.GetValue(entityInfo.EntityValue) == null) - dyCreateBy.SetValue(entityInfo.EntityValue, App.User.ID); + { + try + { + dyCreateBy.SetValue(entityInfo.EntityValue, Convert.ToInt32(App.User.ID)); + + } + catch (Exception) + { + dyCreateBy.SetValue(entityInfo.EntityValue, App.User.ID); + + } + } if ((dyCreateTime != null && dyCreateTime.GetValue(entityInfo.EntityValue) is null) || (dyCreateTime != null && dyCreateTime.GetValue(entityInfo.EntityValue) != null && (DateTime)dyCreateTime.GetValue(entityInfo.EntityValue) == DateTime.MinValue)) dyCreateTime.SetValue(entityInfo.EntityValue, DateTime.Now); @@ -105,7 +116,18 @@ public static class SqlSugarAop var dyModifyTime = getType.GetProperty("UpdateTime"); if (App.User?.ID > 0 && UpdateBy != null) - UpdateBy.SetValue(entityInfo.EntityValue, App.User.ID); + { + try + { + UpdateBy.SetValue(entityInfo.EntityValue, Convert.ToInt32(App.User.ID)); + + } + catch (Exception) + { + UpdateBy.SetValue(entityInfo.EntityValue, App.User.ID); + + } + } if (dyModifyTime != null) dyModifyTime.SetValue(entityInfo.EntityValue, DateTime.Now);