diff --git a/spring-cloud-starter/src/main/java/com/jmsoftware/maf/springcloudstarter/database/MyBatisPlusConfiguration.java b/spring-cloud-starter/src/main/java/com/jmsoftware/maf/springcloudstarter/database/MyBatisPlusConfiguration.java index e87593a0..f277ef52 100644 --- a/spring-cloud-starter/src/main/java/com/jmsoftware/maf/springcloudstarter/database/MyBatisPlusConfiguration.java +++ b/spring-cloud-starter/src/main/java/com/jmsoftware/maf/springcloudstarter/database/MyBatisPlusConfiguration.java @@ -2,14 +2,17 @@ import com.baomidou.mybatisplus.annotation.DbType; import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration; +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; import lombok.extern.slf4j.Slf4j; import lombok.val; +import org.apache.ibatis.plugin.Interceptor; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; +import org.springframework.core.annotation.Order; import org.springframework.transaction.annotation.EnableTransactionManagement; /** @@ -39,8 +42,28 @@ public BlockAttackInnerInterceptor blockAttackInnerInterceptor() { return new BlockAttackInnerInterceptor(); } + /** + * Mybatis plus interceptor mybatis plus interceptor. + * + * @param paginationInnerInterceptor the pagination inner interceptor + * @param blockAttackInnerInterceptor the block attack inner interceptor + * @return the mybatis plus interceptor + * @see MybatisPlusInterceptor + */ @Bean - public DynamicDataSourceInterceptor dynamicDataSourceInterceptor() { + @Order(1) + public Interceptor mybatisPlusInterceptor(PaginationInnerInterceptor paginationInnerInterceptor, + BlockAttackInnerInterceptor blockAttackInnerInterceptor) { + log.warn("Initial bean array: '{}'", MybatisPlusInterceptor.class.getSimpleName()); + MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor(); + mybatisPlusInterceptor.addInnerInterceptor(paginationInnerInterceptor); + mybatisPlusInterceptor.addInnerInterceptor(blockAttackInnerInterceptor); + return mybatisPlusInterceptor; + } + + @Bean + @Order(2) + public Interceptor dynamicDataSourceInterceptor() { log.warn("Initial bean: '{}'", DynamicDataSourceInterceptor.class.getSimpleName()); return new DynamicDataSourceInterceptor(); }