From 69e4436441fb64b45a43108f5f374cca29554fda Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 17 四月 2026 13:54:12 +0800
Subject: [PATCH] refactor(MybatisPlusConfig): 重构MyBatis Plus配置类

---
 src/main/java/com/ruoyi/framework/config/MybatisPlusConfig.java |   53 +++++++++++++++--------------------------------------
 1 files changed, 15 insertions(+), 38 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..253910a 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;
@@ -23,9 +21,7 @@
 import java.sql.SQLException;
 
 /**
- * Mybatis Plus 閰嶇疆
- *
- * @author ruoyi
+ * MyBatis Plus config.
  */
 @EnableTransactionManagement(proxyTargetClass = true)
 @Configuration
@@ -35,66 +31,47 @@
     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)
+                    throws SQLException {
                 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