From 97a12075b1a14963baf0afd5b5685dfcae97e61a Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期三, 24 十一月 2021 10:58:10 +0800
Subject: [PATCH] update 初始化数据转移到 ApplicationRunner 统一处理
---
ruoyi-framework/src/main/java/com/ruoyi/framework/config/MybatisPlusConfig.java | 53 +++++++++++++++--------------------------------------
1 files changed, 15 insertions(+), 38 deletions(-)
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MybatisPlusConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MybatisPlusConfig.java
index dc2ff86..db81b74 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MybatisPlusConfig.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MybatisPlusConfig.java
@@ -1,6 +1,5 @@
package com.ruoyi.framework.config;
-import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
@@ -10,7 +9,7 @@
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.ruoyi.common.core.mybatisplus.methods.InsertAll;
-import com.ruoyi.framework.mybatisplus.CreateAndUpdateMetaObjectHandler;
+import com.ruoyi.framework.handler.CreateAndUpdateMetaObjectHandler;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -19,13 +18,12 @@
import java.util.List;
/**
- * mybatis-plus閰嶇疆绫�
+ * mybatis-plus閰嶇疆绫�(涓嬫柟娉ㄩ噴鏈夋彃浠朵粙缁�)
*
* @author Lion Li
*/
@EnableTransactionManagement(proxyTargetClass = true)
@Configuration
-// 鎸囧畾瑕佹壂鎻忕殑Mapper绫荤殑鍖呯殑璺緞
@MapperScan("${mybatis-plus.mapperPackage}")
public class MybatisPlusConfig {
@@ -36,19 +34,14 @@
interceptor.addInnerInterceptor(paginationInnerInterceptor());
// 涔愯閿佹彃浠�
interceptor.addInnerInterceptor(optimisticLockerInnerInterceptor());
- // 闃绘柇鎻掍欢
-// interceptor.addInnerInterceptor(blockAttackInnerInterceptor());
return interceptor;
}
/**
* 鍒嗛〉鎻掍欢锛岃嚜鍔ㄨ瘑鍒暟鎹簱绫诲瀷
- * https://baomidou.com/guide/interceptor-pagination.html
*/
public PaginationInnerInterceptor paginationInnerInterceptor() {
PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
- // 璁剧疆鏁版嵁搴撶被鍨嬩负mysql
- paginationInnerInterceptor.setDbType(DbType.MYSQL);
// 璁剧疆鏈�澶у崟椤甸檺鍒舵暟閲忥紝榛樿 500 鏉★紝-1 涓嶅彈闄愬埗
paginationInnerInterceptor.setMaxLimit(-1L);
// 鍒嗛〉鍚堢悊鍖�
@@ -58,41 +51,13 @@
/**
* 涔愯閿佹彃浠�
- * https://baomidou.com/guide/interceptor-optimistic-locker.html
*/
public OptimisticLockerInnerInterceptor optimisticLockerInnerInterceptor() {
return new OptimisticLockerInnerInterceptor();
}
/**
- * 濡傛灉鏄鍏ㄨ〃鐨勫垹闄ゆ垨鏇存柊鎿嶄綔锛屽氨浼氱粓姝㈣鎿嶄綔
- * https://baomidou.com/guide/interceptor-block-attack.html
- */
-// public BlockAttackInnerInterceptor blockAttackInnerInterceptor() {
-// return new BlockAttackInnerInterceptor();
-// }
-
- /**
- * sql鎬ц兘瑙勮寖鎻掍欢(鍨冨溇SQL鎷︽埅)
- * 濡傛湁闇�瑕佸彲浠ュ惎鐢�
- */
-// public IllegalSQLInnerInterceptor illegalSQLInnerInterceptor() {
-// return new IllegalSQLInnerInterceptor();
-// }
-
-
- /**
- * 鑷畾涔変富閿瓥鐣�
- * https://baomidou.com/guide/id-generator.html
- */
-// @Bean
-// public IdentifierGenerator idGenerator() {
-// return new CustomIdGenerator();
-// }
-
- /**
* 鍏冨璞″瓧娈靛~鍏呮帶鍒跺櫒
- * https://baomidou.com/guide/auto-fill-metainfo.html
*/
@Bean
public MetaObjectHandler metaObjectHandler() {
@@ -101,7 +66,6 @@
/**
* sql娉ㄥ叆鍣ㄩ厤缃�
- * https://baomidou.com/guide/sql-injector.html
*/
@Bean
public ISqlInjector sqlInjector() {
@@ -116,6 +80,19 @@
}
/**
+ * PaginationInnerInterceptor 鍒嗛〉鎻掍欢锛岃嚜鍔ㄨ瘑鍒暟鎹簱绫诲瀷
+ * https://baomidou.com/guide/interceptor-pagination.html
+ * OptimisticLockerInnerInterceptor 涔愯閿佹彃浠�
+ * https://baomidou.com/guide/interceptor-optimistic-locker.html
+ * MetaObjectHandler 鍏冨璞″瓧娈靛~鍏呮帶鍒跺櫒
+ * https://baomidou.com/guide/auto-fill-metainfo.html
+ * ISqlInjector sql娉ㄥ叆鍣�
+ * https://baomidou.com/guide/sql-injector.html
+ * BlockAttackInnerInterceptor 濡傛灉鏄鍏ㄨ〃鐨勫垹闄ゆ垨鏇存柊鎿嶄綔锛屽氨浼氱粓姝㈣鎿嶄綔
+ * https://baomidou.com/guide/interceptor-block-attack.html
+ * IllegalSQLInnerInterceptor sql鎬ц兘瑙勮寖鎻掍欢(鍨冨溇SQL鎷︽埅)
+ * IdentifierGenerator 鑷畾涔変富閿瓥鐣�
+ * https://baomidou.com/guide/id-generator.html
* TenantLineInnerInterceptor 澶氱鎴锋彃浠�
* https://baomidou.com/guide/interceptor-tenant-line.html
* DynamicTableNameInnerInterceptor 鍔ㄦ�佽〃鍚嶆彃浠�
--
Gitblit v1.9.3