From 966d1fe6077c885db064fcea98bb48cbccb464d6 Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期一, 14 十月 2024 17:23:02 +0800 Subject: [PATCH] WCS --- 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_Core/AOP/SqlSugarAop.cs | 72 ++++++++++++++++++++++++++++++++++++ 1 files changed, 72 insertions(+), 0 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_Core/AOP/SqlSugarAop.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_Core/AOP/SqlSugarAop.cs" new file mode 100644 index 0000000..e0880c9 --- /dev/null +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_Core/AOP/SqlSugarAop.cs" @@ -0,0 +1,72 @@ +锘縰sing SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using WIDESEA_Core.Const; +using WIDESEA_Core.DB.Models; +using WIDESEA_Core.Helper; +using WIDESEA_Core.Tenants; + +namespace WIDESEA_Core.AOP +{ + public static class SqlSugarAop + { + public static void DataExecuting(object oldValue, DataFilterModel entityInfo) + { + if (entityInfo.EntityValue is BaseEntity baseEntity) + { + // 鏂板鎿嶄綔 + if (entityInfo.OperationType == DataFilterType.InsertByObject) + { + if (entityInfo.PropertyName == nameof(BaseEntity.CreateDate)) + { + baseEntity.CreateDate = DateTime.Now; + } + } + + if (entityInfo.OperationType == DataFilterType.UpdateByObject) + { + baseEntity.ModifyDate = DateTime.Now; + } + + + if (App.User?.UserId > 0) + { + switch (entityInfo.OperationType) + { + case DataFilterType.UpdateByObject: + baseEntity.Modifier = App.User.UserName; + break; + case DataFilterType.InsertByObject: + baseEntity.Creater = App.User.UserName; + break; + } + } + } + } + + private static string GetWholeSql(SugarParameter[] paramArr, string sql) + { + foreach (var param in paramArr) + { + sql = sql.Replace(param.ParameterName, $@"'{param.Value.ObjToString()}'"); + } + + return sql; + } + + private static string GetParas(SugarParameter[] pars) + { + string key = "銆怱QL鍙傛暟銆戯細"; + foreach (var param in pars) + { + key += $"{param.ParameterName}:{param.Value}\n"; + } + + return key; + } + } +} -- Gitblit v1.9.3