From 12b0846ee59a358fbf5bc392f74794b8ef13d8eb Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期五, 13 九月 2024 15:55:06 +0800
Subject: [PATCH] 增加出货数量验证

---
 Tiger.Business/DbBase.cs |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/Tiger.Business/DbBase.cs b/Tiger.Business/DbBase.cs
index 2a6939e..e5175c0 100644
--- a/Tiger.Business/DbBase.cs
+++ b/Tiger.Business/DbBase.cs
@@ -3,6 +3,7 @@
 using Rhea.Common;
 using SqlSugar;
 using System;
+using System.Collections;
 using System.Collections.Generic;
 using System.Data.SqlTypes;
 using System.Linq;
@@ -254,6 +255,7 @@
             {
                 var dbres = isAsync ? await Db.Deleteable<T>().In(primaryKeys).ExecuteCommandAsync() : Db.Deleteable<T>().In(primaryKeys).ExecuteCommand();
                 action.Message = $"Delete {typeof(T).Name} entity by primary keys from database success";
+                action.IsSuccessed = true;
             }
             catch (Exception ex)
             {
@@ -276,6 +278,7 @@
             {
                 var dbres = isAsync ? await Db.Deleteable<T>().Where(entity).ExecuteCommandAsync() : Db.Deleteable<T>().Where(entity).ExecuteCommand();
                 action.Message = $"Delete {typeof(T).Name} entity from database success";
+                action.IsSuccessed = true;
             }
             catch (Exception ex)
             {
@@ -872,5 +875,44 @@
         }
 
         #endregion 鎵цSQL
+
+        #region 鍏堝垹闄ゅ悗鏂板
+        /// <summary>
+        /// 鍒犻櫎瀹屾洿鏂�
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="query"></param>
+        /// <param name="list"></param>
+        /// <returns></returns>
+        public new async Task<ApiAction> AddAfterDeleteAsync<T>(QueryAble<T> query) where T : class, new()
+        {
+            var action = new ApiAction();
+            try
+            {
+                //淇濆瓨鍒版暟鎹簱
+                var db = Business.Biz.Db;
+                var dbTran = db.UseTran(() =>
+                {
+                    var dbres = !query.where.IsNullOrEmpty() ? db.Deleteable<T>().Where(query.where).ExecuteCommand() : db.Deleteable<T>().ExecuteCommand();
+                    if (query.Items.Count > 0)
+                    {
+                        db.Insertable<T>(query.Items).ExecuteCommand();
+                    }
+                });
+                if (!dbTran.IsSuccess)
+                {
+                    action.GetResponse().CatchExceptionWithLog(dbTran.ErrorException, $"浣滀笟淇濆瓨鍒版暟鎹簱寮傚父");
+                }
+                action.Message = $"Delete {typeof(T).Name} entity by where and add list in database success";
+            }
+            catch (Exception ex)
+            {
+                action.CatchExceptionWithLog(ex, $"Delete {typeof(T).Name} entity by where and add list in database exception");
+            }
+            return action;
+        }
+
+        #endregion
+
     }//endClass
 }
\ No newline at end of file

--
Gitblit v1.9.3