mirror of
https://github.com/continew-org/continew-starter.git
synced 2025-09-19 00:57:13 +08:00
refactor: 优化部分代码
1.修复 Sonar 扫描问题 2.使用常量替代部分魔法值
This commit is contained in:
@@ -38,6 +38,7 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
|||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
import top.charles7c.continew.starter.core.autoconfigure.project.ProjectProperties;
|
import top.charles7c.continew.starter.core.autoconfigure.project.ProjectProperties;
|
||||||
|
import top.charles7c.continew.starter.core.constant.PropertiesConstants;
|
||||||
import top.charles7c.continew.starter.core.util.GeneralPropertySourceFactory;
|
import top.charles7c.continew.starter.core.util.GeneralPropertySourceFactory;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -53,7 +54,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
@AutoConfiguration
|
@AutoConfiguration
|
||||||
@ConditionalOnProperty(name = "springdoc.swagger-ui.enabled", havingValue = "true")
|
@ConditionalOnProperty(prefix = PropertiesConstants.SPRINGDOC_SWAGGER_UI, name = PropertiesConstants.ENABLED, havingValue = "true")
|
||||||
@EnableConfigurationProperties(SpringDocExtensionProperties.class)
|
@EnableConfigurationProperties(SpringDocExtensionProperties.class)
|
||||||
@PropertySource(value = "classpath:default-api-doc.yml", factory = GeneralPropertySourceFactory.class)
|
@PropertySource(value = "classpath:default-api-doc.yml", factory = GeneralPropertySourceFactory.class)
|
||||||
public class SpringDocAutoConfiguration implements WebMvcConfigurer {
|
public class SpringDocAutoConfiguration implements WebMvcConfigurer {
|
||||||
|
@@ -20,6 +20,7 @@ import io.swagger.v3.oas.models.Components;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||||
|
import top.charles7c.continew.starter.core.constant.PropertiesConstants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API 文档扩展配置属性
|
* API 文档扩展配置属性
|
||||||
@@ -28,7 +29,7 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
|||||||
* @since 1.0.1
|
* @since 1.0.1
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@ConfigurationProperties(prefix = "springdoc")
|
@ConfigurationProperties(prefix = PropertiesConstants.SPRINGDOC)
|
||||||
public class SpringDocExtensionProperties {
|
public class SpringDocExtensionProperties {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -25,6 +25,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import top.charles7c.continew.starter.auth.justauth.core.JustAuthStateCacheRedisImpl;
|
import top.charles7c.continew.starter.auth.justauth.core.JustAuthStateCacheRedisImpl;
|
||||||
|
import top.charles7c.continew.starter.core.constant.PropertiesConstants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JustAuth 自动配置
|
* JustAuth 自动配置
|
||||||
@@ -34,7 +35,7 @@ import top.charles7c.continew.starter.auth.justauth.core.JustAuthStateCacheRedis
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@AutoConfiguration(before = com.xkcoding.justauth.autoconfigure.JustAuthAutoConfiguration.class)
|
@AutoConfiguration(before = com.xkcoding.justauth.autoconfigure.JustAuthAutoConfiguration.class)
|
||||||
@ConditionalOnProperty(prefix = "justauth", value = "enabled", havingValue = "true", matchIfMissing = true)
|
@ConditionalOnProperty(prefix = "justauth", name = PropertiesConstants.ENABLED, havingValue = "true", matchIfMissing = true)
|
||||||
public class JustAuthAutoConfiguration {
|
public class JustAuthAutoConfiguration {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,7 +43,7 @@ public class JustAuthAutoConfiguration {
|
|||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnClass(RedisClient.class)
|
@ConditionalOnClass(RedisClient.class)
|
||||||
@ConditionalOnProperty(prefix = "justauth.cache", value = "type", havingValue = "redis")
|
@ConditionalOnProperty(prefix = "justauth.cache", name = "type", havingValue = "redis")
|
||||||
public AuthStateCache authStateCache() {
|
public AuthStateCache authStateCache() {
|
||||||
JustAuthStateCacheRedisImpl impl = new JustAuthStateCacheRedisImpl();
|
JustAuthStateCacheRedisImpl impl = new JustAuthStateCacheRedisImpl();
|
||||||
log.debug("[ContiNew Starter] - Auto Configuration 'JustAuth-AuthStateCache-Redis' completed initialization.");
|
log.debug("[ContiNew Starter] - Auto Configuration 'JustAuth-AuthStateCache-Redis' completed initialization.");
|
||||||
|
@@ -32,6 +32,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
|
|||||||
import org.springframework.context.annotation.*;
|
import org.springframework.context.annotation.*;
|
||||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
import top.charles7c.continew.starter.core.constant.PropertiesConstants;
|
||||||
import top.charles7c.continew.starter.core.constant.StringConstants;
|
import top.charles7c.continew.starter.core.constant.StringConstants;
|
||||||
import top.charles7c.continew.starter.core.util.GeneralPropertySourceFactory;
|
import top.charles7c.continew.starter.core.util.GeneralPropertySourceFactory;
|
||||||
|
|
||||||
@@ -46,7 +47,7 @@ import top.charles7c.continew.starter.core.util.GeneralPropertySourceFactory;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@ComponentScan("top.charles7c.continew.starter.auth.satoken.exception")
|
@ComponentScan("top.charles7c.continew.starter.auth.satoken.exception")
|
||||||
@EnableConfigurationProperties(SaTokenExtensionProperties.class)
|
@EnableConfigurationProperties(SaTokenExtensionProperties.class)
|
||||||
@ConditionalOnProperty(prefix = "sa-token.extension", name = "enabled", havingValue = "true")
|
@ConditionalOnProperty(prefix = "sa-token.extension", name = PropertiesConstants.ENABLED, havingValue = "true")
|
||||||
@PropertySource(value = "classpath:default-auth-satoken.yml", factory = GeneralPropertySourceFactory.class)
|
@PropertySource(value = "classpath:default-auth-satoken.yml", factory = GeneralPropertySourceFactory.class)
|
||||||
public class SaTokenAutoConfiguration implements WebMvcConfigurer {
|
public class SaTokenAutoConfiguration implements WebMvcConfigurer {
|
||||||
|
|
||||||
|
@@ -24,6 +24,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.redisson.codec.JsonJacksonCodec;
|
import org.redisson.codec.JsonJacksonCodec;
|
||||||
import org.redisson.config.ClusterServersConfig;
|
import org.redisson.config.ClusterServersConfig;
|
||||||
|
import org.redisson.config.Config;
|
||||||
import org.redisson.config.SentinelServersConfig;
|
import org.redisson.config.SentinelServersConfig;
|
||||||
import org.redisson.config.SingleServerConfig;
|
import org.redisson.config.SingleServerConfig;
|
||||||
import org.redisson.spring.starter.RedissonAutoConfigurationCustomizer;
|
import org.redisson.spring.starter.RedissonAutoConfigurationCustomizer;
|
||||||
@@ -32,6 +33,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|||||||
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
|
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import top.charles7c.continew.starter.core.constant.PropertiesConstants;
|
||||||
import top.charles7c.continew.starter.core.constant.StringConstants;
|
import top.charles7c.continew.starter.core.constant.StringConstants;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -46,7 +48,7 @@ import java.util.List;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@AutoConfiguration
|
@AutoConfiguration
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@ConditionalOnProperty(prefix = "spring.data.redisson", name = "enabled", havingValue = "true")
|
@ConditionalOnProperty(prefix = "spring.data.redisson", name = PropertiesConstants.ENABLED, havingValue = "true")
|
||||||
@EnableConfigurationProperties(RedissonProperties.class)
|
@EnableConfigurationProperties(RedissonProperties.class)
|
||||||
public class RedissonAutoConfiguration {
|
public class RedissonAutoConfiguration {
|
||||||
|
|
||||||
@@ -60,63 +62,85 @@ public class RedissonAutoConfiguration {
|
|||||||
RedissonProperties.Mode mode = properties.getMode();
|
RedissonProperties.Mode mode = properties.getMode();
|
||||||
String protocol = redisProperties.getSsl().isEnabled() ? "rediss://" : "redis://";
|
String protocol = redisProperties.getSsl().isEnabled() ? "rediss://" : "redis://";
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case CLUSTER -> {
|
case CLUSTER -> this.buildClusterModeConfig(config, protocol);
|
||||||
ClusterServersConfig clusterServersConfig = config.useClusterServers();
|
case SENTINEL -> this.buildSentinelModeConfig(config, protocol);
|
||||||
ClusterServersConfig customClusterServersConfig = properties.getClusterServersConfig();
|
default -> this.buildSingleModeConfig(config, protocol);
|
||||||
if (null != customClusterServersConfig) {
|
|
||||||
BeanUtil.copyProperties(customClusterServersConfig, clusterServersConfig);
|
|
||||||
clusterServersConfig.setNodeAddresses(customClusterServersConfig.getNodeAddresses());
|
|
||||||
}
|
|
||||||
// 下方配置如果为空,则使用 Redis 的配置
|
|
||||||
if (CollUtil.isEmpty(clusterServersConfig.getNodeAddresses())) {
|
|
||||||
List<String> nodeList = redisProperties.getCluster().getNodes();
|
|
||||||
nodeList.stream().map(node -> protocol + node).forEach(clusterServersConfig::addNodeAddress);
|
|
||||||
}
|
|
||||||
if (StrUtil.isBlank(clusterServersConfig.getPassword())) {
|
|
||||||
clusterServersConfig.setPassword(redisProperties.getPassword());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case SENTINEL -> {
|
|
||||||
SentinelServersConfig sentinelServersConfig = config.useSentinelServers();
|
|
||||||
SentinelServersConfig customSentinelServersConfig = properties.getSentinelServersConfig();
|
|
||||||
if (null != customSentinelServersConfig) {
|
|
||||||
BeanUtil.copyProperties(customSentinelServersConfig, sentinelServersConfig);
|
|
||||||
sentinelServersConfig.setSentinelAddresses(customSentinelServersConfig.getSentinelAddresses());
|
|
||||||
}
|
|
||||||
// 下方配置如果为空,则使用 Redis 的配置
|
|
||||||
if (CollUtil.isEmpty(sentinelServersConfig.getSentinelAddresses())) {
|
|
||||||
List<String> nodeList = redisProperties.getSentinel().getNodes();
|
|
||||||
nodeList.stream()
|
|
||||||
.map(node -> protocol + node)
|
|
||||||
.forEach(sentinelServersConfig::addSentinelAddress);
|
|
||||||
}
|
|
||||||
if (StrUtil.isBlank(sentinelServersConfig.getPassword())) {
|
|
||||||
sentinelServersConfig.setPassword(redisProperties.getPassword());
|
|
||||||
}
|
|
||||||
if (StrUtil.isBlank(sentinelServersConfig.getMasterName())) {
|
|
||||||
sentinelServersConfig.setMasterName(redisProperties.getSentinel().getMaster());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
SingleServerConfig singleServerConfig = config.useSingleServer();
|
|
||||||
SingleServerConfig customSingleServerConfig = properties.getSingleServerConfig();
|
|
||||||
if (null != customSingleServerConfig) {
|
|
||||||
BeanUtil.copyProperties(properties.getSingleServerConfig(), singleServerConfig);
|
|
||||||
}
|
|
||||||
// 下方配置如果为空,则使用 Redis 的配置
|
|
||||||
singleServerConfig.setDatabase(redisProperties.getDatabase());
|
|
||||||
if (StrUtil.isBlank(singleServerConfig.getPassword())) {
|
|
||||||
singleServerConfig.setPassword(redisProperties.getPassword());
|
|
||||||
}
|
|
||||||
if (StrUtil.isBlank(singleServerConfig.getAddress())) {
|
|
||||||
singleServerConfig.setAddress(protocol + redisProperties
|
|
||||||
.getHost() + StringConstants.COLON + redisProperties.getPort());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Jackson 处理
|
// Jackson 处理
|
||||||
config.setCodec(new JsonJacksonCodec(objectMapper));
|
config.setCodec(new JsonJacksonCodec(objectMapper));
|
||||||
log.debug("[ContiNew Starter] - Auto Configuration 'Redisson' completed initialization.");
|
log.debug("[ContiNew Starter] - Auto Configuration 'Redisson' completed initialization.");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建集群模式配置
|
||||||
|
*
|
||||||
|
* @param config 配置
|
||||||
|
* @param protocol 协议
|
||||||
|
*/
|
||||||
|
private void buildClusterModeConfig(Config config, String protocol) {
|
||||||
|
ClusterServersConfig clusterServersConfig = config.useClusterServers();
|
||||||
|
ClusterServersConfig customClusterServersConfig = properties.getClusterServersConfig();
|
||||||
|
if (null != customClusterServersConfig) {
|
||||||
|
BeanUtil.copyProperties(customClusterServersConfig, clusterServersConfig);
|
||||||
|
clusterServersConfig.setNodeAddresses(customClusterServersConfig.getNodeAddresses());
|
||||||
|
}
|
||||||
|
// 下方配置如果为空,则使用 Redis 的配置
|
||||||
|
if (CollUtil.isEmpty(clusterServersConfig.getNodeAddresses())) {
|
||||||
|
List<String> nodeList = redisProperties.getCluster().getNodes();
|
||||||
|
nodeList.stream().map(node -> protocol + node).forEach(clusterServersConfig::addNodeAddress);
|
||||||
|
}
|
||||||
|
if (StrUtil.isBlank(clusterServersConfig.getPassword())) {
|
||||||
|
clusterServersConfig.setPassword(redisProperties.getPassword());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建哨兵模式配置
|
||||||
|
*
|
||||||
|
* @param config 配置
|
||||||
|
* @param protocol 协议
|
||||||
|
*/
|
||||||
|
private void buildSentinelModeConfig(Config config, String protocol) {
|
||||||
|
SentinelServersConfig sentinelServersConfig = config.useSentinelServers();
|
||||||
|
SentinelServersConfig customSentinelServersConfig = properties.getSentinelServersConfig();
|
||||||
|
if (null != customSentinelServersConfig) {
|
||||||
|
BeanUtil.copyProperties(customSentinelServersConfig, sentinelServersConfig);
|
||||||
|
sentinelServersConfig.setSentinelAddresses(customSentinelServersConfig.getSentinelAddresses());
|
||||||
|
}
|
||||||
|
// 下方配置如果为空,则使用 Redis 的配置
|
||||||
|
if (CollUtil.isEmpty(sentinelServersConfig.getSentinelAddresses())) {
|
||||||
|
List<String> nodeList = redisProperties.getSentinel().getNodes();
|
||||||
|
nodeList.stream().map(node -> protocol + node).forEach(sentinelServersConfig::addSentinelAddress);
|
||||||
|
}
|
||||||
|
if (StrUtil.isBlank(sentinelServersConfig.getPassword())) {
|
||||||
|
sentinelServersConfig.setPassword(redisProperties.getPassword());
|
||||||
|
}
|
||||||
|
if (StrUtil.isBlank(sentinelServersConfig.getMasterName())) {
|
||||||
|
sentinelServersConfig.setMasterName(redisProperties.getSentinel().getMaster());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建单机模式配置
|
||||||
|
*
|
||||||
|
* @param config 配置
|
||||||
|
* @param protocol 协议
|
||||||
|
*/
|
||||||
|
private void buildSingleModeConfig(Config config, String protocol) {
|
||||||
|
SingleServerConfig singleServerConfig = config.useSingleServer();
|
||||||
|
SingleServerConfig customSingleServerConfig = properties.getSingleServerConfig();
|
||||||
|
if (null != customSingleServerConfig) {
|
||||||
|
BeanUtil.copyProperties(properties.getSingleServerConfig(), singleServerConfig);
|
||||||
|
}
|
||||||
|
// 下方配置如果为空,则使用 Redis 的配置
|
||||||
|
singleServerConfig.setDatabase(redisProperties.getDatabase());
|
||||||
|
if (StrUtil.isBlank(singleServerConfig.getPassword())) {
|
||||||
|
singleServerConfig.setPassword(redisProperties.getPassword());
|
||||||
|
}
|
||||||
|
if (StrUtil.isBlank(singleServerConfig.getAddress())) {
|
||||||
|
singleServerConfig.setAddress(protocol + redisProperties.getHost() + StringConstants.COLON + redisProperties
|
||||||
|
.getPort());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -42,6 +42,16 @@ public class PropertiesConstants {
|
|||||||
*/
|
*/
|
||||||
public static final String THREAD_POOL = CONTINEW_STARTER + ".thread-pool";
|
public static final String THREAD_POOL = CONTINEW_STARTER + ".thread-pool";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spring Doc 配置
|
||||||
|
*/
|
||||||
|
public static final String SPRINGDOC = "springdoc";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spring Doc Swagger UI 配置
|
||||||
|
*/
|
||||||
|
public static final String SPRINGDOC_SWAGGER_UI = SPRINGDOC + ".swagger-ui";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Web 配置
|
* Web 配置
|
||||||
*/
|
*/
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
package top.charles7c.continew.starter.data.mybatis.plus.autoconfigure;
|
package top.charles7c.continew.starter.data.mybatis.plus.autoconfigure;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import top.charles7c.continew.starter.core.constant.PropertiesConstants;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
@@ -29,6 +30,6 @@ import java.lang.annotation.*;
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||||
@Documented
|
@Documented
|
||||||
@ConditionalOnProperty(prefix = "mybatis-plus.extension.data-permission", name = "enabled", havingValue = "true")
|
@ConditionalOnProperty(prefix = "mybatis-plus.extension.data-permission", name = PropertiesConstants.ENABLED, havingValue = "true")
|
||||||
public @interface ConditionalOnEnabledDataPermission {
|
public @interface ConditionalOnEnabledDataPermission {
|
||||||
}
|
}
|
@@ -35,6 +35,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
|
|||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.PropertySource;
|
import org.springframework.context.annotation.PropertySource;
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
import top.charles7c.continew.starter.core.constant.PropertiesConstants;
|
||||||
import top.charles7c.continew.starter.core.util.GeneralPropertySourceFactory;
|
import top.charles7c.continew.starter.core.util.GeneralPropertySourceFactory;
|
||||||
import top.charles7c.continew.starter.data.mybatis.plus.datapermission.DataPermissionFilter;
|
import top.charles7c.continew.starter.data.mybatis.plus.datapermission.DataPermissionFilter;
|
||||||
import top.charles7c.continew.starter.data.mybatis.plus.datapermission.DataPermissionHandlerImpl;
|
import top.charles7c.continew.starter.data.mybatis.plus.datapermission.DataPermissionHandlerImpl;
|
||||||
@@ -50,7 +51,7 @@ import top.charles7c.continew.starter.data.mybatis.plus.datapermission.DataPermi
|
|||||||
@MapperScan("${mybatis-plus.extension.mapper-package}")
|
@MapperScan("${mybatis-plus.extension.mapper-package}")
|
||||||
@EnableTransactionManagement(proxyTargetClass = true)
|
@EnableTransactionManagement(proxyTargetClass = true)
|
||||||
@EnableConfigurationProperties(MyBatisPlusExtensionProperties.class)
|
@EnableConfigurationProperties(MyBatisPlusExtensionProperties.class)
|
||||||
@ConditionalOnProperty(prefix = "mybatis-plus.extension", name = "enabled", havingValue = "true")
|
@ConditionalOnProperty(prefix = "mybatis-plus.extension", name = PropertiesConstants.ENABLED, havingValue = "true")
|
||||||
@PropertySource(value = "classpath:default-data-mybatis-plus.yml", factory = GeneralPropertySourceFactory.class)
|
@PropertySource(value = "classpath:default-data-mybatis-plus.yml", factory = GeneralPropertySourceFactory.class)
|
||||||
public class MybatisPlusAutoConfiguration {
|
public class MybatisPlusAutoConfiguration {
|
||||||
|
|
||||||
|
@@ -100,6 +100,7 @@ public class DataPermissionHandlerImpl implements DataPermissionHandler {
|
|||||||
case DEPT -> expression = this.buildDeptExpression(dataPermission, currentUser, expression);
|
case DEPT -> expression = this.buildDeptExpression(dataPermission, currentUser, expression);
|
||||||
case SELF -> expression = this.buildSelfExpression(dataPermission, currentUser, expression);
|
case SELF -> expression = this.buildSelfExpression(dataPermission, currentUser, expression);
|
||||||
case CUSTOM -> expression = this.buildCustomExpression(dataPermission, role, expression);
|
case CUSTOM -> expression = this.buildCustomExpression(dataPermission, role, expression);
|
||||||
|
default -> throw new IllegalArgumentException(String.format("暂不支持 [%s] 数据权限", dataScope));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null != where ? new AndExpression(where, new Parenthesis(expression)) : expression;
|
return null != where ? new AndExpression(where, new Parenthesis(expression)) : expression;
|
||||||
|
Reference in New Issue
Block a user