From a0fdff7103fc0f394ed4c459c35eed3bc842ea07 Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期三, 11 六月 2025 15:18:34 +0800
Subject: [PATCH] 更新 appsettings.json 配置项

---
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/BaseServices/ServiceBase.cs |  144 +++++++++++++++++++++++++++++++++++++----------
 1 files changed, 112 insertions(+), 32 deletions(-)

diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/BaseServices/ServiceBase.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/BaseServices/ServiceBase.cs
index ded801d..71e0481 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/BaseServices/ServiceBase.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/BaseServices/ServiceBase.cs
@@ -60,6 +60,73 @@
         }
 
 
+        //protected string ValidatePageOptions(PageDataOptions options)
+        //{
+        //    options = options ?? new PageDataOptions();
+        //    string where = "";
+        //    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 { }
+        //    }
+        //    QueryRelativeList?.Invoke(searchParametersList);
+
+        //    for (int i = 0; i < searchParametersList.Count; i++)
+        //    {
+        //        if (string.IsNullOrEmpty(searchParametersList[i].Value))
+        //        {
+        //            continue;
+        //        }
+
+        //        PropertyInfo property = TProperties.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} like '%{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;
+        //}
+
         protected string ValidatePageOptions(PageDataOptions options)
         {
             options = options ?? new PageDataOptions();
@@ -91,38 +158,48 @@
 
                 if (property == null) continue;
 
-                List<(bool, string, object)> results = property.ValidationValueForDbType(searchParametersList[i].Value.Split(',')).ToList();
-                if (results == null || results.Count() == 0)
+                (bool, string, object) result = property.ValidationVal(searchParametersList[i].Value);
+                if (!result.Item1)
                 {
                     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} like '%{results[j].Item3}%'";
-                    }
-                    else
-                    {
-                        where += $"{searchParametersList[i].Name} {searchParametersList[i].DisplayType} '{results[j].Item3}'";
-                    }
 
-                    if (j == results.Count() - 1)
+                LinqExpressionType expressionType = searchParametersList[i].DisplayType.GetLinqCondition();
+                if (expressionType == LinqExpressionType.Equal)
+                {
+                    if (string.IsNullOrEmpty(where))
                     {
-                        where += ")";
+                        // 閽堝瀛楃涓茬被鍨嬬殑瀛楁浣跨敤妯$硦鏌ヨ
+                        //where += $"{searchParametersList[i].Name} like '%{searchParametersList[i].Value}%'";
+                        if (searchParametersList[i].Value.ToLower() == "true" || searchParametersList[i].Value.ToLower() == "false")
+                        {
+                            where += $" {searchParametersList[i].Name} = '{searchParametersList[i].Value.ToLower()}'";
+                        }
+                        else
+                        {
+                            where += $"{searchParametersList[i].Name} like '%{searchParametersList[i].Value}%'";
+                        }
                     }
                     else
                     {
-                        where += " or ";
+                        // 閽堝甯冨皵绫诲瀷瀛楁杩涜绮剧‘鏌ヨ
+                        if (searchParametersList[i].Value.ToLower() == "true" || searchParametersList[i].Value.ToLower() == "false")
+                        {
+                            where += $" and {searchParametersList[i].Name} = '{searchParametersList[i].Value.ToLower()}'";
+                        }
+                        else
+                        {
+                            where += $" and {searchParametersList[i].Name} like '%{searchParametersList[i].Value}%'";
+                        }
                     }
                 }
-                if (i < searchParametersList.Count - 1)
-                    where += " and ";
+                else
+                {
+                    if (string.IsNullOrEmpty(where))
+                        where += $"{searchParametersList[i].Name} {searchParametersList[i].DisplayType} '{searchParametersList[i].Value}'";
+                    else
+                        where += $" and {searchParametersList[i].Name} {searchParametersList[i].DisplayType} '{searchParametersList[i].Value}'";
+                }
             }
             return where;
         }
@@ -225,7 +302,10 @@
                 {
                     return WebResponseContent.Instance.Error("浼犲弬閿欒,鍙傛暟涓嶈兘涓虹┖");
                 }
-                string validResult = typeof(TEntity).ValidateDicInEntity(saveModel.MainData, true, TProperties);
+
+                var x = saveModel.MainData;
+
+                string validResult = typeof(TEntity).ValidateDicInEntity(x, true, TProperties);
 
                 if (!string.IsNullOrEmpty(validResult))
                 {
@@ -286,7 +366,7 @@
 
                 List<TDetail> list = detailDics.DicToIEnumerable<TDetail>();
 
-                ((SqlSugarClient)BaseDal.Db).BeginTran();
+                ((SqlSugarScope)BaseDal.Db).BeginTran();
 
                 int id = BaseDal.Db.Insertable(entity).ExecuteReturnIdentity();
 
@@ -298,13 +378,13 @@
 
                 BaseDal.Db.Insertable(list).ExecuteCommand();
 
-                ((SqlSugarClient)BaseDal.Db).CommitTran();
+                ((SqlSugarScope)BaseDal.Db).CommitTran();
 
                 content = WebResponseContent.Instance.OK();
             }
             catch (Exception ex)
             {
-                ((SqlSugarClient)BaseDal.Db).RollbackTran();
+                ((SqlSugarScope)BaseDal.Db).RollbackTran();
                 content = WebResponseContent.Instance.Error(ex.Message);
             }
             return content;
@@ -457,7 +537,7 @@
                 object mainId = typeof(TEntity).GetPropertyValue(entity, typeof(TEntity).GetKeyName());
                 if (mainId != null)
                 {
-                    ((SqlSugarClient)BaseDal.Db).BeginTran();
+                    ((SqlSugarScope)BaseDal.Db).BeginTran();
 
                     if (dynamicDelKeys.Count > 0)
                         BaseDal.Db.Deleteable<object>().AS(detailType.Name).Where($"{detailType.GetKeyName()} in (@id)", new { id = dynamicDelKeys.ToArray() }).ExecuteCommandHasChange();
@@ -474,7 +554,7 @@
 
                     BaseDal.Db.Insertable(addRows).ExecuteCommand();
 
-                    ((SqlSugarClient)BaseDal.Db).CommitTran();
+                    ((SqlSugarScope)BaseDal.Db).CommitTran();
 
                     content = WebResponseContent.Instance.OK();
                 }
@@ -486,7 +566,7 @@
             }
             catch (Exception ex)
             {
-                ((SqlSugarClient)BaseDal.Db).RollbackTran();
+                ((SqlSugarScope)BaseDal.Db).RollbackTran();
                 content = WebResponseContent.Instance.Error(ex.Message);
             }
             return content;
@@ -532,14 +612,14 @@
                         {
                             dynamicDelKeys.Add(keys[i]);
                         }
-                        ((SqlSugarClient)BaseDal.Db).BeginTran();
+                        ((SqlSugarScope)BaseDal.Db).BeginTran();
 
                         if (dynamicDelKeys.Count > 0)
                             BaseDal.Db.Deleteable<object>().AS(detailType.Name).Where($"{name} in (@id)", new { id = dynamicDelKeys.ToArray() }).ExecuteCommandHasChange();
 
                         BaseDal.DeleteDataByIds(keys);
 
-                        ((SqlSugarClient)BaseDal.Db).CommitTran();
+                        ((SqlSugarScope)BaseDal.Db).CommitTran();
 
                         return WebResponseContent.Instance.OK();
                     }
@@ -551,7 +631,7 @@
             }
             catch (Exception ex)
             {
-                ((SqlSugarClient)BaseDal.Db).RollbackTran();
+                ((SqlSugarScope)BaseDal.Db).RollbackTran();
                 return WebResponseContent.Instance.Error(ex.Message);
             }
         }

--
Gitblit v1.9.3