mirror of
https://github.com/chillzhuang/blade-tool
synced 2024-12-12 12:19:27 +08:00
🎉 2.7.3.RELEASE 升级多租户模块
This commit is contained in:
parent
c63a6f469a
commit
fe850c71e9
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<version>2.7.2</version>
|
<version>2.7.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -15,7 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.springblade.core.boot.config;
|
package org.springblade.core.boot.config;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springblade.core.mp.plugins.SqlLogInterceptor;
|
import org.springblade.core.mp.plugins.SqlLogInterceptor;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
@ -29,13 +34,32 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
* @author Chill
|
* @author Chill
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@AllArgsConstructor
|
||||||
@MapperScan("org.springblade.**.mapper.**")
|
@MapperScan("org.springblade.**.mapper.**")
|
||||||
public class MybatisPlusConfiguration {
|
public class MybatisPlusConfiguration {
|
||||||
|
|
||||||
|
private final TenantLineHandler tenantLineHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mybatis-plus 拦截器集合
|
||||||
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean(PaginationInterceptor.class)
|
@ConditionalOnMissingBean(MybatisPlusInterceptor.class)
|
||||||
public PaginationInterceptor paginationInterceptor() {
|
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||||
return new PaginationInterceptor();
|
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||||
|
// 配置租户拦截器
|
||||||
|
interceptor.addInnerInterceptor(new TenantLineInnerInterceptor(tenantLineHandler));
|
||||||
|
// 配置分页拦截器
|
||||||
|
interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
|
||||||
|
return interceptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mybatis-plus自3.4.0起采用新的分页插件,一缓和二缓遵循mybatis的规则,需要设置 MybatisConfiguration#useDeprecatedExecutor = false 避免缓存出现问题(该属性会在旧插件移除后一同移除)
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public ConfigurationCustomizer configurationCustomizer() {
|
||||||
|
return configuration -> configuration.setUseDeprecatedExecutor(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.springblade.core.boot.tenant;
|
package org.springblade.core.boot.tenant;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.tenant.TenantHandler;
|
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.sf.jsqlparser.expression.Expression;
|
import net.sf.jsqlparser.expression.Expression;
|
||||||
@ -31,7 +31,7 @@ import org.springblade.core.tool.utils.StringUtil;
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class BladeTenantHandler implements TenantHandler {
|
public class BladeTenantHandler implements TenantLineHandler {
|
||||||
|
|
||||||
private final BladeTenantProperties properties;
|
private final BladeTenantProperties properties;
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ public class BladeTenantHandler implements TenantHandler {
|
|||||||
* @return 租户ID
|
* @return 租户ID
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Expression getTenantId(boolean where) {
|
public Expression getTenantId() {
|
||||||
return new StringValue(Func.toStr(SecureUtil.getTenantId(), TenantConstant.DEFAULT_TENANT_ID));
|
return new StringValue(Func.toStr(SecureUtil.getTenantId(), TenantConstant.DEFAULT_TENANT_ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,10 +59,10 @@ public class BladeTenantHandler implements TenantHandler {
|
|||||||
* 过滤租户表
|
* 过滤租户表
|
||||||
*
|
*
|
||||||
* @param tableName 表名
|
* @param tableName 表名
|
||||||
* @return 是否进行过滤
|
* @return 是否忽略, true:表示忽略,false:需要解析并拼接多租户条件
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean doTableFilter(String tableName) {
|
public boolean ignoreTable(String tableName) {
|
||||||
return !(
|
return !(
|
||||||
(
|
(
|
||||||
(properties.getTables().size() > 0 && properties.getTables().contains(tableName))
|
(properties.getTables().size() > 0 && properties.getTables().contains(tableName))
|
||||||
|
@ -15,10 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.springblade.core.boot.tenant;
|
package org.springblade.core.boot.tenant;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.parser.ISqlParser;
|
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.tenant.TenantHandler;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.tenant.TenantSqlParser;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springblade.core.boot.config.MybatisPlusConfiguration;
|
import org.springblade.core.boot.config.MybatisPlusConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||||
@ -27,9 +24,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
|
|||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 多租户配置类
|
* 多租户配置类
|
||||||
*
|
*
|
||||||
@ -52,8 +46,8 @@ public class TenantConfiguration {
|
|||||||
* @return TenantHandler
|
* @return TenantHandler
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean(TenantHandler.class)
|
@ConditionalOnMissingBean(TenantLineHandler.class)
|
||||||
public TenantHandler bladeTenantHandler() {
|
public TenantLineHandler bladeTenantHandler() {
|
||||||
return new BladeTenantHandler(properties);
|
return new BladeTenantHandler(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,21 +62,4 @@ public class TenantConfiguration {
|
|||||||
return new BladeTenantId();
|
return new BladeTenantId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页插件
|
|
||||||
*
|
|
||||||
* @param tenantHandler 自定义租户处理器
|
|
||||||
* @return PaginationInterceptor
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public PaginationInterceptor paginationInterceptor(TenantHandler tenantHandler) {
|
|
||||||
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
|
|
||||||
List<ISqlParser> sqlParserList = new ArrayList<>();
|
|
||||||
TenantSqlParser tenantSqlParser = new TenantSqlParser();
|
|
||||||
tenantSqlParser.setTenantHandler(tenantHandler);
|
|
||||||
sqlParserList.add(tenantSqlParser);
|
|
||||||
paginationInterceptor.setSqlParserList(sqlParserList);
|
|
||||||
return paginationInterceptor;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ mybatis-plus:
|
|||||||
swagger:
|
swagger:
|
||||||
title: SpringBlade 接口文档系统
|
title: SpringBlade 接口文档系统
|
||||||
description: SpringBlade 接口文档系统
|
description: SpringBlade 接口文档系统
|
||||||
version: 2.7.2
|
version: 2.7.3
|
||||||
license: Powered By SpringBlade
|
license: Powered By SpringBlade
|
||||||
licenseUrl: https://bladex.vip
|
licenseUrl: https://bladex.vip
|
||||||
terms-of-service-url: https://bladex.vip
|
terms-of-service-url: https://bladex.vip
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.7.2</version>
|
<version>2.7.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.7.2</version>
|
<version>2.7.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.7.2</version>
|
<version>2.7.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -25,7 +25,7 @@ public interface AppConstant {
|
|||||||
/**
|
/**
|
||||||
* 应用版本
|
* 应用版本
|
||||||
*/
|
*/
|
||||||
String APPLICATION_VERSION = "2.7.2";
|
String APPLICATION_VERSION = "2.7.3";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基础包
|
* 基础包
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.7.2</version>
|
<version>2.7.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.7.2</version>
|
<version>2.7.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.7.2</version>
|
<version>2.7.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.7.2</version>
|
<version>2.7.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.7.2</version>
|
<version>2.7.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.7.2</version>
|
<version>2.7.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -55,7 +55,7 @@ public class SwaggerProperties {
|
|||||||
/**
|
/**
|
||||||
* 版本
|
* 版本
|
||||||
**/
|
**/
|
||||||
private String version = "2.7.2";
|
private String version = "2.7.3";
|
||||||
/**
|
/**
|
||||||
* 许可证
|
* 许可证
|
||||||
**/
|
**/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<version>2.7.2</version>
|
<version>2.7.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<version>2.7.2</version>
|
<version>2.7.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.7.2</version>
|
<version>2.7.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
8
pom.xml
8
pom.xml
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<version>2.7.2</version>
|
<version>2.7.3</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>blade-tool</name>
|
<name>blade-tool</name>
|
||||||
<description>
|
<description>
|
||||||
@ -36,14 +36,14 @@
|
|||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<blade.tool.version>2.7.2</blade.tool.version>
|
<blade.tool.version>2.7.3</blade.tool.version>
|
||||||
|
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<maven.plugin.version>3.8.0</maven.plugin.version>
|
<maven.plugin.version>3.8.0</maven.plugin.version>
|
||||||
<swagger.version>2.9.2</swagger.version>
|
<swagger.version>2.9.2</swagger.version>
|
||||||
<swagger.models.version>1.5.21</swagger.models.version>
|
<swagger.models.version>1.5.21</swagger.models.version>
|
||||||
<knife4j.version>2.0.4</knife4j.version>
|
<knife4j.version>2.0.4</knife4j.version>
|
||||||
<mybatis.plus.version>3.3.2</mybatis.plus.version>
|
<mybatis.plus.version>3.4.0</mybatis.plus.version>
|
||||||
<protostuff.version>1.6.0</protostuff.version>
|
<protostuff.version>1.6.0</protostuff.version>
|
||||||
<disruptor.version>3.4.2</disruptor.version>
|
<disruptor.version>3.4.2</disruptor.version>
|
||||||
<spring.boot.admin.version>2.3.0</spring.boot.admin.version>
|
<spring.boot.admin.version>2.3.0</spring.boot.admin.version>
|
||||||
@ -52,7 +52,7 @@
|
|||||||
<alibaba.seata.version>1.3.0</alibaba.seata.version>
|
<alibaba.seata.version>1.3.0</alibaba.seata.version>
|
||||||
|
|
||||||
<spring.boot.version>2.2.9.RELEASE</spring.boot.version>
|
<spring.boot.version>2.2.9.RELEASE</spring.boot.version>
|
||||||
<spring.cloud.version>Hoxton.SR7</spring.cloud.version>
|
<spring.cloud.version>Hoxton.SR8</spring.cloud.version>
|
||||||
<spring.platform.version>Cairo-SR8</spring.platform.version>
|
<spring.platform.version>Cairo-SR8</spring.platform.version>
|
||||||
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
Loading…
Reference in New Issue
Block a user