From 1b3d13f691957d4fffdfb3671dc09f66b6e3dfd0 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期四, 23 四月 2026 10:15:33 +0800
Subject: [PATCH] yaml
---
src/main/java/com/ruoyi/framework/config/MybatisPlusConfig.java | 54 ++++++++++++++----------------------------------------
1 files changed, 14 insertions(+), 40 deletions(-)
diff --git a/src/main/java/com/ruoyi/framework/config/MybatisPlusConfig.java b/src/main/java/com/ruoyi/framework/config/MybatisPlusConfig.java
index c46495b..69a5f41 100644
--- a/src/main/java/com/ruoyi/framework/config/MybatisPlusConfig.java
+++ b/src/main/java/com/ruoyi/framework/config/MybatisPlusConfig.java
@@ -7,8 +7,6 @@
import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
-import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
-import com.ruoyi.common.handler.CustomTenantLineHandler;
import com.ruoyi.common.interceptor.DataScopeSqlInterceptor;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.BoundSql;
@@ -20,12 +18,8 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
-import java.sql.SQLException;
-
/**
- * Mybatis Plus 閰嶇疆
- *
- * @author ruoyi
+ * MyBatis Plus config.
*/
@EnableTransactionManagement(proxyTargetClass = true)
@Configuration
@@ -35,66 +29,46 @@
private DataScopeSqlInterceptor dataScopeSqlInterceptor;
@Bean
- public MybatisPlusInterceptor mybatisPlusInterceptor()
- {
+ public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
- // 绉熸埛鎻掍欢
-// TenantLineInnerInterceptor tenantLineInnerInterceptor = new TenantLineInnerInterceptor(new CustomTenantLineHandler());
-// interceptor.addInnerInterceptor(tenantLineInnerInterceptor);
- // 鍒嗛〉鎻掍欢
- interceptor.addInnerInterceptor(paginationInnerInterceptor());
- // 涔愯閿佹彃浠�
- interceptor.addInnerInterceptor(optimisticLockerInnerInterceptor());
- // 闃绘柇鎻掍欢
- interceptor.addInnerInterceptor(blockAttackInnerInterceptor());
- // 鏁版嵁鏉冮檺鎻掍欢
+ // Rewrite the original SQL before pagination generates the count query.
interceptor.addInnerInterceptor(dataScopeSqlInterceptor);
+ interceptor.addInnerInterceptor(paginationInnerInterceptor());
+ interceptor.addInnerInterceptor(optimisticLockerInnerInterceptor());
+ interceptor.addInnerInterceptor(blockAttackInnerInterceptor());
return interceptor;
}
/**
- * 鍒嗛〉鎻掍欢锛岃嚜鍔ㄨ瘑鍒暟鎹簱绫诲瀷 https://baomidou.com/guide/interceptor-pagination.html
+ * Pagination interceptor.
*/
-// public PaginationInnerInterceptor paginationInnerInterceptor()
-// {
-// PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
-// // 璁剧疆鏁版嵁搴撶被鍨嬩负mysql
-// paginationInnerInterceptor.setDbType(DbType.MYSQL);
-// // 璁剧疆鏈�澶у崟椤甸檺鍒舵暟閲忥紝榛樿 500 鏉★紝-1 涓嶅彈闄愬埗
-// paginationInnerInterceptor.setMaxLimit(-1L);
-// return paginationInnerInterceptor;
-// }
-
public PaginationInnerInterceptor paginationInnerInterceptor() {
PaginationInnerInterceptor interceptor = new PaginationInnerInterceptor(DbType.MYSQL) {
@Override
public void beforeQuery(Executor executor, MappedStatement ms, Object parameter,
- RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) throws SQLException {
+ RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) {
IPage<?> page = ParameterUtils.findPage(parameter).orElse(null);
if (page != null && page.getSize() <= 0) {
- // 褰搒ize<=0鏃讹紝涓嶈繘琛屽垎椤�
return;
}
super.beforeQuery(executor, ms, parameter, rowBounds, resultHandler, boundSql);
}
};
- interceptor.setMaxLimit(1000L); // 寤鸿璁剧疆鍚堢悊鐨勬渶澶у��
+ interceptor.setMaxLimit(1000L);
return interceptor;
}
/**
- * 涔愯閿佹彃浠� https://baomidou.com/guide/interceptor-optimistic-locker.html
+ * Optimistic lock interceptor.
*/
- public OptimisticLockerInnerInterceptor optimisticLockerInnerInterceptor()
- {
+ public OptimisticLockerInnerInterceptor optimisticLockerInnerInterceptor() {
return new OptimisticLockerInnerInterceptor();
}
/**
- * 濡傛灉鏄鍏ㄨ〃鐨勫垹闄ゆ垨鏇存柊鎿嶄綔锛屽氨浼氱粓姝㈣鎿嶄綔 https://baomidou.com/guide/interceptor-block-attack.html
+ * Block full-table update and delete.
*/
- public BlockAttackInnerInterceptor blockAttackInnerInterceptor()
- {
+ public BlockAttackInnerInterceptor blockAttackInnerInterceptor() {
return new BlockAttackInnerInterceptor();
}
-}
\ No newline at end of file
+}
--
Gitblit v1.9.3