From 0705cb6170a9ba77ba48bbb6dcebb9cf3d73cbea Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期二, 14 十月 2025 02:12:25 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/MeiRuiAn/HuaiAn
---
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_Core/Utilities/EntityProperties.cs | 68 +++++++++++++++++++++++++++++-----
1 files changed, 58 insertions(+), 10 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/Utilities/EntityProperties.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/Utilities/EntityProperties.cs"
index c351b8b..bf691b9 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/Utilities/EntityProperties.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/Utilities/EntityProperties.cs"
@@ -5,10 +5,12 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
+using System.Linq.Expressions;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Core.Const;
+using WIDESEA_Core.Enums;
using WIDESEA_Core.Helper;
namespace WIDESEA_Core.Utilities
@@ -86,16 +88,19 @@
else
{
- int length = sugarColumn.Length;
- if (length == 0) { return (true, null, null); }
- //鍒ゆ柇鍙屽瓧鑺備笌鍗曞瓧娈�
- else if (length < 8000 &&
- ((dbType.Substring(0, 1) != "n"
- && Encoding.UTF8.GetBytes(val.ToCharArray()).Length > length)
- || val.Length > length)
- )
+ if (sugarColumn != null)
{
- reslutMsg = $"鏈�澶氬彧鑳姐�恵length}銆戜釜瀛楃銆�";
+ int length = sugarColumn.Length;
+ if (length == 0) { return (true, null, null); }
+ //鍒ゆ柇鍙屽瓧鑺備笌鍗曞瓧娈�
+ else if (length < 8000 &&
+ ((dbType.Substring(0, 1) != "n"
+ && Encoding.UTF8.GetBytes(val.ToCharArray()).Length > length)
+ || val.Length > length)
+ )
+ {
+ reslutMsg = $"鏈�澶氬彧鑳姐�恵length}銆戜釜瀛楃銆�";
+ }
}
}
}
@@ -184,7 +189,7 @@
continue;
//涓嶅湪缂栬緫涓殑鍒楋紝鏄惁涔熻蹇呭~
- if (!dic.ContainsKey(property.Name.FirstLetterToLower()) /*&& !dic.ContainsKey(property.Name.FirstLetterToUpper())*/)
+ if (!dic.ContainsKey(property.Name.FirstLetterToLower()))
{
if (!sugarColumn.IsNullable)
{
@@ -318,5 +323,48 @@
}
return null;
}
+
+ public static void ValidatePageOptions<TEntity>(PageDataOptions options, ref ISugarQueryable<TEntity> sugarQueryable)
+ {
+ string where = string.Empty;
+ PropertyInfo[] entityProperties = typeof(TEntity).GetProperties();
+ List<SearchParameters> searchParametersList = new List<SearchParameters>();
+ if (options.Filter != null && options.Filter.Count > 0)
+ {
+ searchParametersList.AddRange(options.Filter);
+ }
+ else if (!string.IsNullOrEmpty(options.Wheres))
+ {
+ try
+ {
+ searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>();
+ options.Filter = searchParametersList;
+ }
+ catch { }
+ }
+ for (int i = 0; i < searchParametersList.Count; i++)
+ {
+ if (string.IsNullOrEmpty(searchParametersList[i].Value))
+ {
+ continue;
+ }
+
+ PropertyInfo? property = entityProperties.Where(c => c.Name.ToUpper() == searchParametersList[i].Name.ToUpper()).FirstOrDefault();
+
+ if (property == null) continue;
+
+ List<(bool, string, object)> results = property.ValidationValueForDbType(searchParametersList[i].Value.Split(',')).ToList();
+ if (results == null || results.Count() == 0)
+ {
+ continue;
+ }
+ for (int j = 0; j < results.Count(); j++)
+ {
+ LinqExpressionType expressionType = searchParametersList[i].DisplayType.GetLinqCondition();
+ Expression<Func<TEntity, bool>> expression = property.GetWhereExpression<TEntity>(results[j].Item3, null, expressionType);
+ sugarQueryable = sugarQueryable.Where(expression);
+ }
+ }
+ }
}
}
--
Gitblit v1.9.3