From 65e37b56bdcf64ffb6ee448b87bc7fb9341573b8 Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Sun, 28 Sep 2025 16:44:51 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=A2=9E=E5=8A=A0=E4=BA=8B=E5=8A=A1?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../template/controller/SimpleControllerSupport.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/lanyuanxiaoyao/service/template/controller/SimpleControllerSupport.java b/src/main/java/com/lanyuanxiaoyao/service/template/controller/SimpleControllerSupport.java index 2c39c16..ed365e5 100644 --- a/src/main/java/com/lanyuanxiaoyao/service/template/controller/SimpleControllerSupport.java +++ b/src/main/java/com/lanyuanxiaoyao/service/template/controller/SimpleControllerSupport.java @@ -7,6 +7,7 @@ import java.util.List; import java.util.Map; import java.util.function.Function; import lombok.extern.slf4j.Slf4j; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -112,6 +113,7 @@ public abstract class SimpleControllerSupport 返回保存后的实体ID * @throws Exception 保存过程中可能抛出的异常 */ + @Transactional(rollbackFor = Throwable.class) @PostMapping(SAVE) @Override public GlobalResponse save(@RequestBody SAVE_ITEM item) throws Exception { @@ -125,6 +127,7 @@ public abstract class SimpleControllerSupport 返回实体列表 * @throws Exception 查询过程中可能抛出的异常 */ + @Transactional(readOnly = true) @GetMapping(LIST) @Override public GlobalResponse> list() throws Exception { @@ -152,6 +155,7 @@ public abstract class SimpleControllerSupport 返回符合条件的实体列表 * @throws Exception 查询过程中可能抛出的异常 */ + @Transactional(readOnly = true) @PostMapping(LIST) @Override public GlobalResponse> list(@RequestBody Query query) throws Exception { @@ -181,6 +185,7 @@ public abstract class SimpleControllerSupport 返回实体详情 * @throws Exception 查询过程中可能抛出的异常 */ + @Transactional(readOnly = true) @GetMapping(DETAIL) @Override public GlobalResponse detail(@PathVariable("id") Long id) throws Exception { @@ -195,6 +200,7 @@ public abstract class SimpleControllerSupport 返回删除结果 * @throws Exception 删除过程中可能抛出的异常 */ + @Transactional(rollbackFor = Throwable.class) @GetMapping(REMOVE) @Override public GlobalResponse remove(@PathVariable("id") Long id) throws Exception {