From eae849e1e16c1dbaa41b94cb4c4847a40771e425 Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Wed, 16 Oct 2024 17:30:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E4=BA=8B=E5=8A=A1=E6=89=8B?= =?UTF-8?q?=E5=8A=A8=E6=8F=90=E4=BA=A4=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chaozhanggui/system/cashierservice/util/Utils.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/Utils.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/Utils.java index e5b9bf9..8b1d170 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/util/Utils.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/Utils.java @@ -7,6 +7,8 @@ import com.chaozhanggui.system.cashierservice.exception.MsgException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; import java.util.UUID; import java.util.concurrent.TimeUnit; @@ -14,6 +16,7 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; +@Component public class Utils { public static int retryCount = 5; private static final Logger log = LoggerFactory.getLogger(Utils.class); @@ -165,6 +168,11 @@ public class Utils { } } + @Transactional + public R runFunAndTransactional(Supplier runnable) { + return runnable.get(); + } + public static class ForwardCounter { private Integer i;