From 2ec78835e454cecb95e48a2be2cb0b8393674ec5 Mon Sep 17 00:00:00 2001
From: xiazhengtongxue <133085197+xiazhengtongxue@users.noreply.github.com>
Date: 星期二, 31 三月 2026 10:27:16 +0800
Subject: [PATCH] fix(Sys_Dictionary): 修复数字字典中文映射
---
Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseServices/ServiceBase.cs | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseServices/ServiceBase.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseServices/ServiceBase.cs
index 6a89499..da3bb86 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseServices/ServiceBase.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseServices/ServiceBase.cs
@@ -36,6 +36,51 @@
public ISqlSugarClient Db => BaseDal.Db;
+ protected async Task<WebResponseContent> ExecuteWithinTransactionAsync(Func<Task<WebResponseContent>> operation)
+ {
+ var db = Db as SqlSugarClient;
+ if (db == null)
+ {
+ return WebResponseContent.Instance.Error("Database context does not support transactions");
+ }
+
+ var ownsTransaction = db.Ado.Transaction == null;
+ try
+ {
+ if (ownsTransaction)
+ {
+ db.BeginTran();
+ }
+
+ var result = await operation();
+ if (result?.Status == true)
+ {
+ if (ownsTransaction)
+ {
+ db.CommitTran();
+ }
+
+ return result;
+ }
+
+ if (ownsTransaction)
+ {
+ db.RollbackTran();
+ }
+
+ return result ?? WebResponseContent.Instance.Error("Transaction failed");
+ }
+ catch
+ {
+ if (ownsTransaction)
+ {
+ db.RollbackTran();
+ }
+
+ throw;
+ }
+ }
+
private PropertyInfo[] _propertyInfo { get; set; } = null;
public PropertyInfo[] TProperties
{
--
Gitblit v1.9.3