From 9ff4001a8ecec61fb01ad89aa57b08b081a8dcda Mon Sep 17 00:00:00 2001 From: Rodney Chen <rodney.chen@hotmail.com> Date: 星期六, 12 四月 2025 11:51:08 +0800 Subject: [PATCH] 优化U9接口逻辑 --- Tiger.Business/DbBase.cs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+), 0 deletions(-) diff --git a/Tiger.Business/DbBase.cs b/Tiger.Business/DbBase.cs index 9b07916..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; @@ -874,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