From 9ca96199d92168fe221dda9aba56f55520a561d8 Mon Sep 17 00:00:00 2001
From: hutongqing <hutongqing@hnkhzn.com>
Date: 星期二, 29 十月 2024 17:30:59 +0800
Subject: [PATCH] 1

---
 WIDESEAWCS_Server/WIDESEAWCS_Core/BaseServices/ServiceBase.cs |   61 +++++++++++++++++++-----------
 1 files changed, 38 insertions(+), 23 deletions(-)

diff --git a/WIDESEAWCS_Server/WIDESEAWCS_Core/BaseServices/ServiceBase.cs b/WIDESEAWCS_Server/WIDESEAWCS_Core/BaseServices/ServiceBase.cs
index 9518cfe..4403d2e 100644
--- a/WIDESEAWCS_Server/WIDESEAWCS_Core/BaseServices/ServiceBase.cs
+++ b/WIDESEAWCS_Server/WIDESEAWCS_Core/BaseServices/ServiceBase.cs
@@ -12,10 +12,10 @@
 using System.Linq.Expressions;
 using System.Reflection;
 using WIDESEAWCS_Core.BaseRepository;
+using WIDESEAWCS_Core.Const;
 using WIDESEAWCS_Core.Enums;
 using WIDESEAWCS_Core.Helper;
 using WIDESEAWCS_Core.Utilities;
-using static OfficeOpenXml.ExcelErrorValue;
 
 namespace WIDESEAWCS_Core.BaseServices
 {
@@ -58,7 +58,6 @@
 
             return pageGridData;
         }
-
 
         protected string ValidatePageOptions(PageDataOptions options)
         {
@@ -105,7 +104,23 @@
                     LinqExpressionType expressionType = searchParametersList[i].DisplayType.GetLinqCondition();
                     if (expressionType == LinqExpressionType.Equal)
                     {
-                        where += $"{searchParametersList[i].Name} = '{results[j].Item3}'";
+                        where += $"{searchParametersList[i].Name} {HtmlElementType.Equal} '{results[j].Item3}'";
+                    }
+                    else if (expressionType == LinqExpressionType.ThanOrEqual)
+                    {
+                        where += $"{searchParametersList[i].Name} {HtmlElementType.ThanOrEqual} '{searchParametersList[i].Value}'";
+                    }
+                    else if (expressionType == LinqExpressionType.LessThanOrEqual)
+                    {
+                        where += $"{searchParametersList[i].Name} {HtmlElementType.LessOrEqual} '{searchParametersList[i].Value}'";
+                    }
+                    else if (expressionType == LinqExpressionType.GreaterThan)
+                    {
+                        where += $"{searchParametersList[i].Name} {HtmlElementType.GT} '{searchParametersList[i].Value}'";
+                    }
+                    else if (expressionType == LinqExpressionType.LessThan)
+                    {
+                        where += $"{searchParametersList[i].Name} {HtmlElementType.LT} '{searchParametersList[i].Value}'";
                     }
                     else
                     {
@@ -133,7 +148,7 @@
         /// <param name="pageData"></param>
         /// <param name="propertyInfo"></param>
         /// <returns></returns>
-        private Dictionary<string, OrderByType> GetPageDataSort(PageDataOptions pageData, PropertyInfo[] propertyInfo)
+        protected Dictionary<string, OrderByType> GetPageDataSort(PageDataOptions pageData, PropertyInfo[] propertyInfo)
         {
             if (!string.IsNullOrEmpty(pageData.Sort))
             {
@@ -263,7 +278,7 @@
                 }
 
                 Type detailType = typeof(TEntity).GetDetailType();
-                MethodInfo? methodInfo = GetType().GetMethod("AddDataIncludesDetail");
+                MethodInfo? methodInfo = GetType().GetMethod(nameof(AddDataIncludesDetail));
                 methodInfo = methodInfo?.MakeGenericMethod(new Type[] { detailType });
                 object? obj = methodInfo?.Invoke(this, new object[] { entity, detailType, saveModel.DetailData });
                 return obj as WebResponseContent;
@@ -373,27 +388,27 @@
 
                 TEntity entity = saveModel.MainData.DicToModel<TEntity>();
 
-                List<string> listCol = new List<string>();
-                foreach (var item in saveModel.MainData)
-                {
-                    PropertyInfo propertyInfo = typeof(TEntity).GetProperty(item.Key);
-                    if (propertyInfo == null)
-                    {
-                        propertyInfo = typeof(TEntity).GetProperty(item.Key.FirstLetterToLower());
-                        if (propertyInfo == null)
-                        {
-                            propertyInfo = typeof(TEntity).GetProperty(item.Key.FirstLetterToUpper());
-                        }
-                    }
+                //List<string> listCol = new List<string>();
+                //foreach (var item in saveModel.MainData)
+                //{
+                //    PropertyInfo propertyInfo = typeof(TEntity).GetProperty(item.Key);
+                //    if (propertyInfo == null)
+                //    {
+                //        propertyInfo = typeof(TEntity).GetProperty(item.Key.FirstLetterToLower());
+                //        if (propertyInfo == null)
+                //        {
+                //            propertyInfo = typeof(TEntity).GetProperty(item.Key.FirstLetterToUpper());
+                //        }
+                //    }
 
-                    listCol.Add(propertyInfo?.Name);
-                }
+                //    listCol.Add(propertyInfo?.Name);
+                //}
 
                 if (saveModel.DetailData == null || saveModel.DetailData.Count == 0)
                 {
-                    if (list != null)
-                        listCol = listCol.Where(x => !list.Contains(x)).ToList();
-                    bool result = BaseDal.UpdateData(entity, listCol, list);
+                    //if (list != null)
+                    //    listCol = listCol.Where(x => !list.Contains(x)).ToList();
+                    bool result = BaseDal.UpdateData(entity);
                     return WebResponseContent.Instance.OK();
                 }
 
@@ -403,7 +418,7 @@
                 }
 
                 Type detailType = typeof(TEntity).GetDetailType();
-                MethodInfo? methodInfo = GetType().GetMethod("UpdateDataInculdesDetail");
+                MethodInfo? methodInfo = GetType().GetMethod(nameof(UpdateDataInculdesDetail));
                 methodInfo = methodInfo?.MakeGenericMethod(new Type[] { detailType });
                 object? obj = methodInfo?.Invoke(this, new object[] { entity, detailType, saveModel.DetailData, saveModel.DelKeys });
                 return obj as WebResponseContent;

--
Gitblit v1.9.3