Преглед изворни кода

😎1、调整sql语句打印范围 2、清理代码 3、升级依赖

zuohuaijun пре 1 година
родитељ
комит
df39728f1b

+ 5 - 5
Admin.NET/Admin.NET.Core/Admin.NET.Core.csproj

@@ -28,9 +28,9 @@
     <PackageReference Include="Magicodes.IE.Excel" Version="2.7.5.2" />
     <PackageReference Include="Magicodes.IE.Excel" Version="2.7.5.2" />
     <PackageReference Include="Magicodes.IE.Pdf" Version="2.7.5.2" />
     <PackageReference Include="Magicodes.IE.Pdf" Version="2.7.5.2" />
     <PackageReference Include="Magicodes.IE.Word" Version="2.7.5.2" />
     <PackageReference Include="Magicodes.IE.Word" Version="2.7.5.2" />
-    <PackageReference Include="MailKit" Version="4.8.0" />
-    <PackageReference Include="MiniExcel" Version="1.35.0" />
-    <PackageReference Include="MiniWord" Version="0.8.0" />
+    <PackageReference Include="MailKit" Version="4.9.0" />
+    <PackageReference Include="MiniExcel" Version="1.36.0" />
+    <PackageReference Include="MiniWord" Version="0.9.2" />
     <PackageReference Include="NewLife.Redis" Version="6.0.2024.1205" />
     <PackageReference Include="NewLife.Redis" Version="6.0.2024.1205" />
     <PackageReference Include="Novell.Directory.Ldap.NETStandard" Version="3.6.0" />
     <PackageReference Include="Novell.Directory.Ldap.NETStandard" Version="3.6.0" />
     <PackageReference Include="QRCoder" Version="1.6.0" />
     <PackageReference Include="QRCoder" Version="1.6.0" />
@@ -40,10 +40,10 @@
     <PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="3.9.0" />
     <PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="3.9.0" />
     <PackageReference Include="SqlSugarCore" Version="5.1.4.171" />
     <PackageReference Include="SqlSugarCore" Version="5.1.4.171" />
     <PackageReference Include="SSH.NET" Version="2024.2.0" />
     <PackageReference Include="SSH.NET" Version="2024.2.0" />
-    <PackageReference Include="System.Linq.Dynamic.Core" Version="1.5.0" />
+    <PackageReference Include="System.Linq.Dynamic.Core" Version="1.5.1" />
     <PackageReference Include="System.Net.Http" Version="4.3.4" />
     <PackageReference Include="System.Net.Http" Version="4.3.4" />
     <PackageReference Include="System.Private.Uri" Version="4.3.2" />
     <PackageReference Include="System.Private.Uri" Version="4.3.2" />
-    <PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1137" />
+    <PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1143" />
     <PackageReference Include="UAParser" Version="3.1.47" />
     <PackageReference Include="UAParser" Version="3.1.47" />
     <PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
     <PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
   </ItemGroup>
   </ItemGroup>

+ 8 - 9
Admin.NET/Admin.NET.Core/Common/CommonValidationAttribute.cs → Admin.NET/Admin.NET.Core/Attribute/CommonValidationAttribute.cs

@@ -1,10 +1,10 @@
 // Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
 // Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
-// 
+//
 // 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
 // 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
-// 
+//
 // 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
 // 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
 
 
-namespace Admin.NET.Core.Common;
+namespace Admin.NET.Core;
 
 
 /// <summary>
 /// <summary>
 /// 通用接口参数验证特性类
 /// 通用接口参数验证特性类
@@ -14,7 +14,7 @@ public class CommonValidationAttribute : ValidationAttribute
 {
 {
     private readonly Dictionary<string, string> _conditions;
     private readonly Dictionary<string, string> _conditions;
     private static readonly Dictionary<string, Delegate> CompiledConditions = new();
     private static readonly Dictionary<string, Delegate> CompiledConditions = new();
-    
+
     /// <summary>
     /// <summary>
     /// </summary>
     /// </summary>
     /// <param name="conditionPairs">条件对参数,长度必须为偶数<br/>
     /// <param name="conditionPairs">条件对参数,长度必须为偶数<br/>
@@ -25,10 +25,10 @@ public class CommonValidationAttribute : ValidationAttribute
     /// <code lang="C">
     /// <code lang="C">
     /// public class ModelInput {
     /// public class ModelInput {
     ///
     ///
-    /// 
+    ///
     ///     public string A { get; set; }
     ///     public string A { get; set; }
     ///
     ///
-    /// 
+    ///
     ///     [CommonValidation(
     ///     [CommonValidation(
     ///         "A == 1 <value>&amp;&amp;</value> B == null", "当 A == 1时,B不能为空",
     ///         "A == 1 <value>&amp;&amp;</value> B == null", "当 A == 1时,B不能为空",
     ///         "C == 2 <value>&amp;&amp;</value> B == null", "当 C == 2时,B不能为空"
     ///         "C == 2 <value>&amp;&amp;</value> B == null", "当 C == 2时,B不能为空"
@@ -50,7 +50,6 @@ public class CommonValidationAttribute : ValidationAttribute
 
 
     protected override ValidationResult IsValid(object value, ValidationContext validationContext)
     protected override ValidationResult IsValid(object value, ValidationContext validationContext)
     {
     {
-        
         foreach (var (expr, errorMessage) in _conditions)
         foreach (var (expr, errorMessage) in _conditions)
         {
         {
             var conditionKey = $"{validationContext.ObjectType.FullName}.{expr}";
             var conditionKey = $"{validationContext.ObjectType.FullName}.{expr}";
@@ -59,7 +58,7 @@ public class CommonValidationAttribute : ValidationAttribute
                 condition = CreateCondition(validationContext.ObjectType, expr);
                 condition = CreateCondition(validationContext.ObjectType, expr);
                 CompiledConditions[conditionKey] = condition;
                 CompiledConditions[conditionKey] = condition;
             }
             }
-            
+
             if ((bool)condition.DynamicInvoke(validationContext.ObjectInstance)!)
             if ((bool)condition.DynamicInvoke(validationContext.ObjectInstance)!)
             {
             {
                 return new ValidationResult(errorMessage ?? $"[{validationContext.MemberName}]校验失败");
                 return new ValidationResult(errorMessage ?? $"[{validationContext.MemberName}]校验失败");
@@ -75,7 +74,7 @@ public class CommonValidationAttribute : ValidationAttribute
         {
         {
             // 创建参数表达式
             // 创建参数表达式
             var parameter = Expression.Parameter(typeof(object), "x");
             var parameter = Expression.Parameter(typeof(object), "x");
-            
+
             // 构建 Lambda 表达式
             // 构建 Lambda 表达式
             var lambda = DynamicExpressionParser.ParseLambda(new[] { Expression.Parameter(modelType, "x") }, typeof(bool), expression);
             var lambda = DynamicExpressionParser.ParseLambda(new[] { Expression.Parameter(modelType, "x") }, typeof(bool), expression);
 
 

+ 1 - 1
Admin.NET/Admin.NET.Core/Job/EnumToDictJob.cs

@@ -54,7 +54,7 @@ public class EnumToDictJob : IJob
             await storageable1.BulkUpdateAsync();
             await storageable1.BulkUpdateAsync();
 
 
             Console.WriteLine($"【{DateTime.Now}】系统枚举类转字典类型数据: 插入{storageable1.InsertList.Count}条, 更新{storageable1.UpdateList.Count}条, 共{storageable1.TotalList.Count}条。");
             Console.WriteLine($"【{DateTime.Now}】系统枚举类转字典类型数据: 插入{storageable1.InsertList.Count}条, 更新{storageable1.UpdateList.Count}条, 共{storageable1.TotalList.Count}条。");
-            
+
             var config = App.GetOptions<DbConnectionOptions>().ConnectionConfigs.FirstOrDefault(u => SqlSugarConst.MainConfigId.Equals(u.ConfigId));
             var config = App.GetOptions<DbConnectionOptions>().ConnectionConfigs.FirstOrDefault(u => SqlSugarConst.MainConfigId.Equals(u.ConfigId));
             var storageable2 = await db.Storageable(sysDictTypeList.SelectMany(x => x.Children).ToList())
             var storageable2 = await db.Storageable(sysDictTypeList.SelectMany(x => x.Children).ToList())
                 .WhereColumns(it => new { it.DictTypeId, it.Value })
                 .WhereColumns(it => new { it.DictTypeId, it.Value })

+ 1 - 1
Admin.NET/Admin.NET.Core/Service/Dict/Dto/DictDataInput.cs

@@ -21,7 +21,7 @@ public class PageDictDataInput : BasePageInput
     /// 字典文本
     /// 字典文本
     /// </summary>
     /// </summary>
     public string Label { get; set; }
     public string Label { get; set; }
-    
+
     /// <summary>
     /// <summary>
     /// 租户Id
     /// 租户Id
     /// </summary>
     /// </summary>

+ 1 - 1
Admin.NET/Admin.NET.Core/Service/Dict/Dto/DictTypeInput.cs

@@ -21,7 +21,7 @@ public class PageDictTypeInput : BasePageInput
     /// 编码
     /// 编码
     /// </summary>
     /// </summary>
     public string Code { get; set; }
     public string Code { get; set; }
-    
+
     /// <summary>
     /// <summary>
     /// 租户Id
     /// 租户Id
     /// </summary>
     /// </summary>

+ 4 - 4
Admin.NET/Admin.NET.Core/Service/Dict/SysDictDataService.cs

@@ -38,7 +38,7 @@ public class SysDictDataService : IDynamicApiController, ITransient
             .Where(u => u.DictTypeId == input.DictTypeId)
             .Where(u => u.DictTypeId == input.DictTypeId)
             .WhereIF(!_userManager.SuperAdmin, u => ids.Contains(u.TenantId.Value))
             .WhereIF(!_userManager.SuperAdmin, u => ids.Contains(u.TenantId.Value))
             .WhereIF(!string.IsNullOrEmpty(input.Label?.Trim()), u => u.Value.Contains(input.Label))
             .WhereIF(!string.IsNullOrEmpty(input.Label?.Trim()), u => u.Value.Contains(input.Label))
-            .WhereIF(_userManager.SuperAdmin && input.TenantId > 0, u => u.TenantId ==  input.TenantId)
+            .WhereIF(_userManager.SuperAdmin && input.TenantId > 0, u => u.TenantId == input.TenantId)
             .OrderBy(u => new { u.OrderNo, Code = u.Value })
             .OrderBy(u => new { u.OrderNo, Code = u.Value })
             .ToPagedListAsync(input.Page, input.PageSize);
             .ToPagedListAsync(input.Page, input.PageSize);
     }
     }
@@ -148,7 +148,7 @@ public class SysDictDataService : IDynamicApiController, ITransient
     [NonAction]
     [NonAction]
     public async Task<List<SysDictData>> GetDictDataListByDictTypeId(long dictTypeId)
     public async Task<List<SysDictData>> GetDictDataListByDictTypeId(long dictTypeId)
     {
     {
-        var dictType = await App.GetService<SysDictTypeService>().GetDetail(new DictTypeInput { Id= dictTypeId });
+        var dictType = await App.GetService<SysDictTypeService>().GetDetail(new DictTypeInput { Id = dictTypeId });
         var dictDataList = _sysCacheService.Get<List<SysDictData>>($"{CacheConst.KeyDict}{dictTypeId}");
         var dictDataList = _sysCacheService.Get<List<SysDictData>>($"{CacheConst.KeyDict}{dictTypeId}");
 
 
         if (dictDataList == null)
         if (dictDataList == null)
@@ -199,7 +199,7 @@ public class SysDictDataService : IDynamicApiController, ITransient
             .OrderBy((u, a) => new { a.OrderNo, Code = a.Value })
             .OrderBy((u, a) => new { a.OrderNo, Code = a.Value })
             .Select((u, a) => a).ToListAsync();
             .Select((u, a) => a).ToListAsync();
     }
     }
-    
+
     /// <summary>
     /// <summary>
     /// 获取租户Id列表
     /// 获取租户Id列表
     /// </summary>
     /// </summary>
@@ -214,7 +214,7 @@ public class SysDictDataService : IDynamicApiController, ITransient
     [NonAction]
     [NonAction]
     public ISugarQueryable<SysDictData> GetSysDictDataQueryable()
     public ISugarQueryable<SysDictData> GetSysDictDataQueryable()
     {
     {
-        var ids = GetTenantIdList(); 
+        var ids = GetTenantIdList();
         return _sysDictDataRep.AsQueryable().ClearFilter().WhereIF(!_userManager.SuperAdmin, u => ids.Contains(u.TenantId.Value));
         return _sysDictDataRep.AsQueryable().ClearFilter().WhereIF(!_userManager.SuperAdmin, u => ids.Contains(u.TenantId.Value));
     }
     }
 
 

+ 3 - 3
Admin.NET/Admin.NET.Core/Service/Dict/SysDictTypeService.cs

@@ -37,7 +37,7 @@ public class SysDictTypeService : IDynamicApiController, ITransient
     {
     {
         return await _sysDictTypeRep.AsQueryable()
         return await _sysDictTypeRep.AsQueryable()
             .WhereIF(!_userManager.SuperAdmin, u => !SqlFunc.EndsWith(SqlFunc.ToLower(u.Code), nameof(Enum).ToLower()))
             .WhereIF(!_userManager.SuperAdmin, u => !SqlFunc.EndsWith(SqlFunc.ToLower(u.Code), nameof(Enum).ToLower()))
-            .WhereIF(_userManager.SuperAdmin && input.TenantId > 0, u => u.TenantId ==  input.TenantId)
+            .WhereIF(_userManager.SuperAdmin && input.TenantId > 0, u => u.TenantId == input.TenantId)
             .WhereIF(!string.IsNullOrEmpty(input.Code?.Trim()), u => u.Code.Contains(input.Code))
             .WhereIF(!string.IsNullOrEmpty(input.Code?.Trim()), u => u.Code.Contains(input.Code))
             .WhereIF(!string.IsNullOrEmpty(input.Name?.Trim()), u => u.Name.Contains(input.Name))
             .WhereIF(!string.IsNullOrEmpty(input.Name?.Trim()), u => u.Name.Contains(input.Name))
             .OrderBy(u => new { u.OrderNo, u.Code })
             .OrderBy(u => new { u.OrderNo, u.Code })
@@ -164,7 +164,7 @@ public class SysDictTypeService : IDynamicApiController, ITransient
             .ToListAsync();
             .ToListAsync();
         return ds.OrderBy(u => u.OrderNo).GroupBy(u => u.TypeCode).ToDictionary(u => u.Key, u => u);
         return ds.OrderBy(u => u.OrderNo).GroupBy(u => u.TypeCode).ToDictionary(u => u.Key, u => u);
     }
     }
-    
+
     /// <summary>
     /// <summary>
     /// 获取SysDictData表查询实例
     /// 获取SysDictData表查询实例
     /// </summary>
     /// </summary>
@@ -175,7 +175,7 @@ public class SysDictTypeService : IDynamicApiController, ITransient
         var ids = GetTenantIdList();
         var ids = GetTenantIdList();
         return _sysDictTypeRep.AsQueryable().ClearFilter().WhereIF(!_userManager.SuperAdmin, u => ids.Contains(u.TenantId.Value));
         return _sysDictTypeRep.AsQueryable().ClearFilter().WhereIF(!_userManager.SuperAdmin, u => ids.Contains(u.TenantId.Value));
     }
     }
-    
+
     /// <summary>
     /// <summary>
     /// 获取租户Id列表
     /// 获取租户Id列表
     /// </summary>
     /// </summary>

+ 28 - 27
Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs

@@ -149,34 +149,35 @@ public static class SqlSugarSetup
                 Console.ForegroundColor = originColor;
                 Console.ForegroundColor = originColor;
                 App.PrintToMiniProfiler("SqlSugar", "Info", log);
                 App.PrintToMiniProfiler("SqlSugar", "Info", log);
             };
             };
-            db.Aop.OnError = ex =>
-            {
-                if (ex.Parametres == null) return;
-                var log = $"【{DateTime.Now}——错误SQL】\r\n{UtilMethods.GetNativeSql(ex.Sql, (SugarParameter[])ex.Parametres)}\r\n";
-                Log.Error(log, ex);
-                App.PrintToMiniProfiler("SqlSugar", "Error", log);
-            };
-            db.Aop.OnLogExecuted = (sql, pars) =>
-            {
-                //// 若参数值超过100个字符则进行截取
-                //foreach (var par in pars)
-                //{
-                //    if (par.DbType != System.Data.DbType.String || par.Value == null) continue;
-                //    if (par.Value.ToString().Length > 100)
-                //        par.Value = string.Concat(par.Value.ToString()[..100], "......");
-                //}
-
-                // 执行时间超过5秒时
-                if (!(db.Ado.SqlExecutionTime.TotalSeconds > 5)) return;
-
-                var fileName = db.Ado.SqlStackTrace.FirstFileName; // 文件名
-                var fileLine = db.Ado.SqlStackTrace.FirstLine; // 行号
-                var firstMethodName = db.Ado.SqlStackTrace.FirstMethodName; // 方法名
-                var log = $"【{DateTime.Now}——超时SQL】\r\n【所在文件名】:{fileName}\r\n【代码行数】:{fileLine}\r\n【方法名】:{firstMethodName}\r\n" + $"【SQL语句】:{UtilMethods.GetNativeSql(sql, pars)}";
-                Log.Warning(log);
-                App.PrintToMiniProfiler("SqlSugar", "Slow", log);
-            };
         }
         }
+        db.Aop.OnError = ex =>
+        {
+            if (ex.Parametres == null) return;
+            var log = $"【{DateTime.Now}——错误SQL】\r\n{UtilMethods.GetNativeSql(ex.Sql, (SugarParameter[])ex.Parametres)}\r\n";
+            Log.Error(log, ex);
+            App.PrintToMiniProfiler("SqlSugar", "Error", log);
+        };
+        db.Aop.OnLogExecuted = (sql, pars) =>
+        {
+            //// 若参数值超过100个字符则进行截取
+            //foreach (var par in pars)
+            //{
+            //    if (par.DbType != System.Data.DbType.String || par.Value == null) continue;
+            //    if (par.Value.ToString().Length > 100)
+            //        par.Value = string.Concat(par.Value.ToString()[..100], "......");
+            //}
+
+            // 执行时间超过5秒时
+            if (!(db.Ado.SqlExecutionTime.TotalSeconds > 5)) return;
+
+            var fileName = db.Ado.SqlStackTrace.FirstFileName; // 文件名
+            var fileLine = db.Ado.SqlStackTrace.FirstLine; // 行号
+            var firstMethodName = db.Ado.SqlStackTrace.FirstMethodName; // 方法名
+            var log = $"【{DateTime.Now}——超时SQL】\r\n【所在文件名】:{fileName}\r\n【代码行数】:{fileLine}\r\n【方法名】:{firstMethodName}\r\n" + $"【SQL语句】:{UtilMethods.GetNativeSql(sql, pars)}";
+            Log.Warning(log);
+            App.PrintToMiniProfiler("SqlSugar", "Slow", log);
+        };
+
         // 数据审计
         // 数据审计
         db.Aop.DataExecuting = (_, entityInfo) =>
         db.Aop.DataExecuting = (_, entityInfo) =>
         {
         {

+ 1 - 1
Admin.NET/Plugins/Admin.NET.Plugin.ReZero/Admin.NET.Plugin.ReZero.csproj

@@ -25,7 +25,7 @@
 
 
   <ItemGroup>
   <ItemGroup>
     <PackageReference Include="DocumentFormat.OpenXml" Version="3.2.0" />
     <PackageReference Include="DocumentFormat.OpenXml" Version="3.2.0" />
-    <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.11.0" />
+    <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.12.0" />
     <PackageReference Include="Rezero.Api" Version="1.7.12" />
     <PackageReference Include="Rezero.Api" Version="1.7.12" />
   </ItemGroup>
   </ItemGroup>