From 5a15fa73d5f6a39917013871a65eb11a8c013391 Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期三, 05 十一月 2025 17:30:56 +0800
Subject: [PATCH] 1

---
 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseModels/PageDataOptions.cs |   68 ++++++++++++++++++++++++++++++++++
 1 files changed, 68 insertions(+), 0 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseModels/PageDataOptions.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseModels/PageDataOptions.cs"
index bffe798..a476723 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseModels/PageDataOptions.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseModels/PageDataOptions.cs"
@@ -1,8 +1,12 @@
 锘縰sing System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Reflection;
 using System.Text;
 using System.Threading.Tasks;
+using WIDESEA_Core.Enums;
+using WIDESEA_Core.Helper;
+using WIDESEA_Core.Utilities;
 
 namespace WIDESEA_Core
 {
@@ -24,6 +28,69 @@
         /// 鏌ヨ鏉′欢
         /// </summary>
         public List<SearchParameters> Filter { get; set; }
+        public string ValidatePageOptions(PropertyInfo[] entityProperties)
+        {
+            string where = string.Empty;
+            List<SearchParameters> searchParametersList = new List<SearchParameters>();
+            if (this.Filter != null && this.Filter.Count > 0)
+            {
+                searchParametersList.AddRange(Filter);
+            }
+            else if (!string.IsNullOrEmpty(Wheres))
+            {
+                try
+                {
+                    searchParametersList = Wheres.DeserializeObject<List<SearchParameters>>();
+                    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++)
+                {
+                    if (j == 0)
+                    {
+                        where += "(";
+                    }
+                    LinqExpressionType expressionType = searchParametersList[i].DisplayType.GetLinqCondition();
+                    if (expressionType == LinqExpressionType.Equal)
+                    {
+                        where += $"{searchParametersList[i].Name} = '{results[j].Item3}'";
+                    }
+                    else
+                    {
+                        where += $"{searchParametersList[i].Name} {searchParametersList[i].DisplayType} '{results[j].Item3}'";
+                    }
+
+                    if (j == results.Count() - 1)
+                    {
+                        where += ")";
+                    }
+                    else
+                    {
+                        where += " or ";
+                    }
+                }
+                if (i < searchParametersList.Count - 1)
+                    where += " and ";
+            }
+            return where;
+        }
     }
     public class SearchParameters
     {
@@ -32,4 +99,5 @@
         //鏌ヨ绫诲瀷锛歀inqExpressionType
         public string DisplayType { get; set; }
     }
+
 }

--
Gitblit v1.9.3