mirror of
https://github.com/continew-org/continew-starter.git
synced 2025-10-24 18:57:13 +08:00
style: 调整代码风格 null != xx => xx != null(更符合大众风格)
This commit is contained in:
@@ -87,17 +87,17 @@ public class SpringDocAutoConfiguration implements WebMvcConfigurer {
|
|||||||
.version(projectProperties.getVersion())
|
.version(projectProperties.getVersion())
|
||||||
.description(projectProperties.getDescription());
|
.description(projectProperties.getDescription());
|
||||||
ProjectProperties.Contact contact = projectProperties.getContact();
|
ProjectProperties.Contact contact = projectProperties.getContact();
|
||||||
if (null != contact) {
|
if (contact != null) {
|
||||||
info.contact(new Contact().name(contact.getName()).email(contact.getEmail()).url(contact.getUrl()));
|
info.contact(new Contact().name(contact.getName()).email(contact.getEmail()).url(contact.getUrl()));
|
||||||
}
|
}
|
||||||
ProjectProperties.License license = projectProperties.getLicense();
|
ProjectProperties.License license = projectProperties.getLicense();
|
||||||
if (null != license) {
|
if (license != null) {
|
||||||
info.license(new License().name(license.getName()).url(license.getUrl()));
|
info.license(new License().name(license.getName()).url(license.getUrl()));
|
||||||
}
|
}
|
||||||
OpenAPI openApi = new OpenAPI();
|
OpenAPI openApi = new OpenAPI();
|
||||||
openApi.info(info);
|
openApi.info(info);
|
||||||
Components components = properties.getComponents();
|
Components components = properties.getComponents();
|
||||||
if (null != components) {
|
if (components != null) {
|
||||||
openApi.components(components);
|
openApi.components(components);
|
||||||
// 鉴权配置
|
// 鉴权配置
|
||||||
Map<String, SecurityScheme> securitySchemeMap = components.getSecuritySchemes();
|
Map<String, SecurityScheme> securitySchemeMap = components.getSecuritySchemes();
|
||||||
@@ -118,11 +118,11 @@ public class SpringDocAutoConfiguration implements WebMvcConfigurer {
|
|||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public GlobalOpenApiCustomizer globalOpenApiCustomizer(SpringDocExtensionProperties properties) {
|
public GlobalOpenApiCustomizer globalOpenApiCustomizer(SpringDocExtensionProperties properties) {
|
||||||
return openApi -> {
|
return openApi -> {
|
||||||
if (null != openApi.getPaths()) {
|
if (openApi.getPaths() != null) {
|
||||||
openApi.getPaths().forEach((s, pathItem) -> {
|
openApi.getPaths().forEach((s, pathItem) -> {
|
||||||
// 为所有接口添加鉴权
|
// 为所有接口添加鉴权
|
||||||
Components components = properties.getComponents();
|
Components components = properties.getComponents();
|
||||||
if (null != components && MapUtil.isNotEmpty(components.getSecuritySchemes())) {
|
if (components != null && MapUtil.isNotEmpty(components.getSecuritySchemes())) {
|
||||||
Map<String, SecurityScheme> securitySchemeMap = components.getSecuritySchemes();
|
Map<String, SecurityScheme> securitySchemeMap = components.getSecuritySchemes();
|
||||||
pathItem.readOperations().forEach(operation -> {
|
pathItem.readOperations().forEach(operation -> {
|
||||||
SecurityRequirement securityRequirement = new SecurityRequirement();
|
SecurityRequirement securityRequirement = new SecurityRequirement();
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ public class RedissonAutoConfiguration {
|
|||||||
private void buildClusterModeConfig(Config config, String protocolPrefix) {
|
private void buildClusterModeConfig(Config config, String protocolPrefix) {
|
||||||
ClusterServersConfig clusterServersConfig = config.useClusterServers();
|
ClusterServersConfig clusterServersConfig = config.useClusterServers();
|
||||||
ClusterServersConfig customClusterServersConfig = properties.getClusterServersConfig();
|
ClusterServersConfig customClusterServersConfig = properties.getClusterServersConfig();
|
||||||
if (null != customClusterServersConfig) {
|
if (customClusterServersConfig != null) {
|
||||||
BeanUtil.copyProperties(customClusterServersConfig, clusterServersConfig);
|
BeanUtil.copyProperties(customClusterServersConfig, clusterServersConfig);
|
||||||
clusterServersConfig.setNodeAddresses(customClusterServersConfig.getNodeAddresses());
|
clusterServersConfig.setNodeAddresses(customClusterServersConfig.getNodeAddresses());
|
||||||
}
|
}
|
||||||
@@ -122,7 +122,7 @@ public class RedissonAutoConfiguration {
|
|||||||
private void buildSentinelModeConfig(Config config, String protocolPrefix) {
|
private void buildSentinelModeConfig(Config config, String protocolPrefix) {
|
||||||
SentinelServersConfig sentinelServersConfig = config.useSentinelServers();
|
SentinelServersConfig sentinelServersConfig = config.useSentinelServers();
|
||||||
SentinelServersConfig customSentinelServersConfig = properties.getSentinelServersConfig();
|
SentinelServersConfig customSentinelServersConfig = properties.getSentinelServersConfig();
|
||||||
if (null != customSentinelServersConfig) {
|
if (customSentinelServersConfig != null) {
|
||||||
BeanUtil.copyProperties(customSentinelServersConfig, sentinelServersConfig);
|
BeanUtil.copyProperties(customSentinelServersConfig, sentinelServersConfig);
|
||||||
sentinelServersConfig.setSentinelAddresses(customSentinelServersConfig.getSentinelAddresses());
|
sentinelServersConfig.setSentinelAddresses(customSentinelServersConfig.getSentinelAddresses());
|
||||||
}
|
}
|
||||||
@@ -154,7 +154,7 @@ public class RedissonAutoConfiguration {
|
|||||||
private void buildSingleModeConfig(Config config, String protocolPrefix) {
|
private void buildSingleModeConfig(Config config, String protocolPrefix) {
|
||||||
SingleServerConfig singleServerConfig = config.useSingleServer();
|
SingleServerConfig singleServerConfig = config.useSingleServer();
|
||||||
SingleServerConfig customSingleServerConfig = properties.getSingleServerConfig();
|
SingleServerConfig customSingleServerConfig = properties.getSingleServerConfig();
|
||||||
if (null != customSingleServerConfig) {
|
if (customSingleServerConfig != null) {
|
||||||
BeanUtil.copyProperties(properties.getSingleServerConfig(), singleServerConfig);
|
BeanUtil.copyProperties(properties.getSingleServerConfig(), singleServerConfig);
|
||||||
}
|
}
|
||||||
// 下方配置如果为空,则使用 Redis 的配置
|
// 下方配置如果为空,则使用 Redis 的配置
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class SpringCacheAutoConfiguration implements CachingConfigurer {
|
|||||||
.serializeValuesWith(RedisSerializationContext.SerializationPair
|
.serializeValuesWith(RedisSerializationContext.SerializationPair
|
||||||
.fromSerializer(new GenericJackson2JsonRedisSerializer(objectMapperCopy)));
|
.fromSerializer(new GenericJackson2JsonRedisSerializer(objectMapperCopy)));
|
||||||
CacheProperties.Redis redisCacheProperties = cacheProperties.getRedis();
|
CacheProperties.Redis redisCacheProperties = cacheProperties.getRedis();
|
||||||
if (null != redisCacheProperties.getTimeToLive()) {
|
if (redisCacheProperties.getTimeToLive() != null) {
|
||||||
redisCacheConfiguration = redisCacheConfiguration.entryTtl(redisCacheProperties.getTimeToLive());
|
redisCacheConfiguration = redisCacheConfiguration.entryTtl(redisCacheProperties.getTimeToLive());
|
||||||
}
|
}
|
||||||
if (!redisCacheProperties.isCacheNullValues()) {
|
if (!redisCacheProperties.isCacheNullValues()) {
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public class StringConstants {
|
|||||||
public static final String SLASH = "/";
|
public static final String SLASH = "/";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 双斜杠 {@code "//"}
|
* 双斜杠 {@code "//"}
|
||||||
*/
|
*/
|
||||||
public static final String DOUBLE_SLASH = "//";
|
public static final String DOUBLE_SLASH = "//";
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class ExceptionUtils {
|
|||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (null != throwable) {
|
if (throwable != null) {
|
||||||
log.error(throwable.getMessage(), throwable);
|
log.error(throwable.getMessage(), throwable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,7 @@ public class ExceptionUtils {
|
|||||||
try {
|
try {
|
||||||
return exSupplier.get();
|
return exSupplier.get();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (null != exConsumer) {
|
if (exConsumer != null) {
|
||||||
exConsumer.accept(e);
|
exConsumer.accept(e);
|
||||||
}
|
}
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class Validator {
|
|||||||
* @param exceptionType 异常类型
|
* @param exceptionType 异常类型
|
||||||
*/
|
*/
|
||||||
protected static void throwIfNotNull(Object obj, String message, Class<? extends RuntimeException> exceptionType) {
|
protected static void throwIfNotNull(Object obj, String message, Class<? extends RuntimeException> exceptionType) {
|
||||||
throwIf(null != obj, message, exceptionType);
|
throwIf(obj != null, message, exceptionType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -193,7 +193,7 @@ public class Validator {
|
|||||||
protected static void throwIf(BooleanSupplier conditionSupplier,
|
protected static void throwIf(BooleanSupplier conditionSupplier,
|
||||||
String message,
|
String message,
|
||||||
Class<? extends RuntimeException> exceptionType) {
|
Class<? extends RuntimeException> exceptionType) {
|
||||||
if (null != conditionSupplier && conditionSupplier.getAsBoolean()) {
|
if (conditionSupplier != null && conditionSupplier.getAsBoolean()) {
|
||||||
throw ReflectUtil.newInstance(exceptionType, message);
|
throw ReflectUtil.newInstance(exceptionType, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ public class MetaUtils {
|
|||||||
final DatabaseMetaData metaData = conn.getMetaData();
|
final DatabaseMetaData metaData = conn.getMetaData();
|
||||||
try (final ResultSet rs = metaData.getTables(catalog, schema, tableName, Convert
|
try (final ResultSet rs = metaData.getTables(catalog, schema, tableName, Convert
|
||||||
.toStrArray(TableType.TABLE))) {
|
.toStrArray(TableType.TABLE))) {
|
||||||
if (null != rs) {
|
if (rs != null) {
|
||||||
String name;
|
String name;
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
name = rs.getString("TABLE_NAME");
|
name = rs.getString("TABLE_NAME");
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ public class QueryWrapperHelper {
|
|||||||
}
|
}
|
||||||
// 设置了 @QueryIgnore 注解,直接忽略
|
// 设置了 @QueryIgnore 注解,直接忽略
|
||||||
QueryIgnore queryIgnoreAnnotation = AnnotationUtil.getAnnotation(field, QueryIgnore.class);
|
QueryIgnore queryIgnoreAnnotation = AnnotationUtil.getAnnotation(field, QueryIgnore.class);
|
||||||
if (null != queryIgnoreAnnotation) {
|
if (queryIgnoreAnnotation != null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
// 建议:数据库表列建议采用下划线连接法命名,程序变量建议采用驼峰法命名
|
// 建议:数据库表列建议采用下划线连接法命名,程序变量建议采用驼峰法命名
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class MybatisPlusAutoConfiguration {
|
|||||||
}
|
}
|
||||||
// 分页插件
|
// 分页插件
|
||||||
MyBatisPlusExtensionProperties.PaginationProperties paginationProperties = properties.getPagination();
|
MyBatisPlusExtensionProperties.PaginationProperties paginationProperties = properties.getPagination();
|
||||||
if (null != paginationProperties && paginationProperties.isEnabled()) {
|
if (paginationProperties != null && paginationProperties.isEnabled()) {
|
||||||
interceptor.addInnerInterceptor(this.paginationInnerInterceptor(paginationProperties));
|
interceptor.addInnerInterceptor(this.paginationInnerInterceptor(paginationProperties));
|
||||||
}
|
}
|
||||||
// 乐观锁插件
|
// 乐观锁插件
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ public class QueryWrapperHelper {
|
|||||||
}
|
}
|
||||||
// 设置了 @QueryIgnore 注解,直接忽略
|
// 设置了 @QueryIgnore 注解,直接忽略
|
||||||
QueryIgnore queryIgnoreAnnotation = AnnotationUtil.getAnnotation(field, QueryIgnore.class);
|
QueryIgnore queryIgnoreAnnotation = AnnotationUtil.getAnnotation(field, QueryIgnore.class);
|
||||||
if (null != queryIgnoreAnnotation) {
|
if (queryIgnoreAnnotation != null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
// 建议:数据库表列建议采用下划线连接法命名,程序变量建议采用驼峰法命名
|
// 建议:数据库表列建议采用下划线连接法命名,程序变量建议采用驼峰法命名
|
||||||
|
|||||||
@@ -64,13 +64,13 @@ public class CrudRequestMappingHandlerMapping extends RequestMappingHandlerMappi
|
|||||||
@NonNull Class<?> handlerType,
|
@NonNull Class<?> handlerType,
|
||||||
CrudRequestMapping crudRequestMapping) {
|
CrudRequestMapping crudRequestMapping) {
|
||||||
RequestMappingInfo info = this.buildRequestMappingInfo(method);
|
RequestMappingInfo info = this.buildRequestMappingInfo(method);
|
||||||
if (null != info) {
|
if (info != null) {
|
||||||
RequestMappingInfo typeInfo = this.buildRequestMappingInfo(handlerType);
|
RequestMappingInfo typeInfo = this.buildRequestMappingInfo(handlerType);
|
||||||
if (null != typeInfo) {
|
if (typeInfo != null) {
|
||||||
info = typeInfo.combine(info);
|
info = typeInfo.combine(info);
|
||||||
}
|
}
|
||||||
String prefix = crudRequestMapping.value();
|
String prefix = crudRequestMapping.value();
|
||||||
if (null != prefix) {
|
if (prefix != null) {
|
||||||
RequestMappingInfo.BuilderConfiguration options = new RequestMappingInfo.BuilderConfiguration();
|
RequestMappingInfo.BuilderConfiguration options = new RequestMappingInfo.BuilderConfiguration();
|
||||||
options.setPatternParser(PathPatternParser.defaultInstance);
|
options.setPatternParser(PathPatternParser.defaultInstance);
|
||||||
info = RequestMappingInfo.paths(prefix).options(options).build().combine(info);
|
info = RequestMappingInfo.paths(prefix).options(options).build().combine(info);
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ public class DefaultDataPermissionHandler implements DataPermissionHandler {
|
|||||||
default -> throw new IllegalArgumentException("暂不支持 [%s] 数据权限".formatted(dataScope));
|
default -> throw new IllegalArgumentException("暂不支持 [%s] 数据权限".formatted(dataScope));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null != where ? new AndExpression(where, new ParenthesedExpressionList<>(expression)) : expression;
|
return where != null ? new AndExpression(where, new ParenthesedExpressionList<>(expression)) : expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -176,7 +176,7 @@ public class DefaultDataPermissionHandler implements DataPermissionHandler {
|
|||||||
InExpression inExpression = new InExpression();
|
InExpression inExpression = new InExpression();
|
||||||
inExpression.setLeftExpression(this.buildColumn(dataPermission.tableAlias(), dataPermission.deptId()));
|
inExpression.setLeftExpression(this.buildColumn(dataPermission.tableAlias(), dataPermission.deptId()));
|
||||||
inExpression.setRightExpression(subSelect);
|
inExpression.setRightExpression(subSelect);
|
||||||
return null != expression ? new OrExpression(expression, inExpression) : inExpression;
|
return expression != null ? new OrExpression(expression, inExpression) : inExpression;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -197,7 +197,7 @@ public class DefaultDataPermissionHandler implements DataPermissionHandler {
|
|||||||
EqualsTo equalsTo = new EqualsTo();
|
EqualsTo equalsTo = new EqualsTo();
|
||||||
equalsTo.setLeftExpression(this.buildColumn(dataPermission.tableAlias(), dataPermission.deptId()));
|
equalsTo.setLeftExpression(this.buildColumn(dataPermission.tableAlias(), dataPermission.deptId()));
|
||||||
equalsTo.setRightExpression(new LongValue(userContext.getDeptId()));
|
equalsTo.setRightExpression(new LongValue(userContext.getDeptId()));
|
||||||
return null != expression ? new OrExpression(expression, equalsTo) : equalsTo;
|
return expression != null ? new OrExpression(expression, equalsTo) : equalsTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -218,7 +218,7 @@ public class DefaultDataPermissionHandler implements DataPermissionHandler {
|
|||||||
EqualsTo equalsTo = new EqualsTo();
|
EqualsTo equalsTo = new EqualsTo();
|
||||||
equalsTo.setLeftExpression(this.buildColumn(dataPermission.tableAlias(), dataPermission.userId()));
|
equalsTo.setLeftExpression(this.buildColumn(dataPermission.tableAlias(), dataPermission.userId()));
|
||||||
equalsTo.setRightExpression(new LongValue(userContext.getUserId()));
|
equalsTo.setRightExpression(new LongValue(userContext.getUserId()));
|
||||||
return null != expression ? new OrExpression(expression, equalsTo) : equalsTo;
|
return expression != null ? new OrExpression(expression, equalsTo) : equalsTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -250,7 +250,7 @@ public class DefaultDataPermissionHandler implements DataPermissionHandler {
|
|||||||
InExpression inExpression = new InExpression();
|
InExpression inExpression = new InExpression();
|
||||||
inExpression.setLeftExpression(this.buildColumn(dataPermission.tableAlias(), dataPermission.deptId()));
|
inExpression.setLeftExpression(this.buildColumn(dataPermission.tableAlias(), dataPermission.deptId()));
|
||||||
inExpression.setRightExpression(subSelect);
|
inExpression.setRightExpression(subSelect);
|
||||||
return null != expression ? new OrExpression(expression, inExpression) : inExpression;
|
return expression != null ? new OrExpression(expression, inExpression) : inExpression;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class DefaultTenantLineHandler implements TenantLineHandler {
|
|||||||
@Override
|
@Override
|
||||||
public Expression getTenantId() {
|
public Expression getTenantId() {
|
||||||
Long tenantId = TenantContextHolder.getTenantId();
|
Long tenantId = TenantContextHolder.getTenantId();
|
||||||
if (null != tenantId) {
|
if (tenantId != null) {
|
||||||
return new LongValue(tenantId);
|
return new LongValue(tenantId);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -55,7 +55,7 @@ public class DefaultTenantLineHandler implements TenantLineHandler {
|
|||||||
@Override
|
@Override
|
||||||
public boolean ignoreTable(String tableName) {
|
public boolean ignoreTable(String tableName) {
|
||||||
Long tenantId = TenantContextHolder.getTenantId();
|
Long tenantId = TenantContextHolder.getTenantId();
|
||||||
if (null != tenantId && tenantId.equals(tenantProperties.getSuperTenantId())) {
|
if (tenantId != null && tenantId.equals(tenantProperties.getSuperTenantId())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (TenantIsolationLevel.DATASOURCE.equals(TenantContextHolder.getIsolationLevel())) {
|
if (TenantIsolationLevel.DATASOURCE.equals(TenantContextHolder.getIsolationLevel())) {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class ExcelBigNumberConverter implements Converter<Long> {
|
|||||||
public WriteCellData<Object> convertToExcelData(Long value,
|
public WriteCellData<Object> convertToExcelData(Long value,
|
||||||
ExcelContentProperty contentProperty,
|
ExcelContentProperty contentProperty,
|
||||||
GlobalConfiguration globalConfiguration) {
|
GlobalConfiguration globalConfiguration) {
|
||||||
if (null != value) {
|
if (value != null) {
|
||||||
String str = Long.toString(value);
|
String str = Long.toString(value);
|
||||||
if (str.length() > MAX_LENGTH) {
|
if (str.length() > MAX_LENGTH) {
|
||||||
return new WriteCellData<>(str);
|
return new WriteCellData<>(str);
|
||||||
|
|||||||
@@ -50,13 +50,13 @@ public class SimpleDeserializersWrapper extends SimpleDeserializers {
|
|||||||
DeserializationConfig config,
|
DeserializationConfig config,
|
||||||
BeanDescription beanDesc) throws JsonMappingException {
|
BeanDescription beanDesc) throws JsonMappingException {
|
||||||
JsonDeserializer<?> deser = super.findEnumDeserializer(type, config, beanDesc);
|
JsonDeserializer<?> deser = super.findEnumDeserializer(type, config, beanDesc);
|
||||||
if (null != deser) {
|
if (deser != null) {
|
||||||
return deser;
|
return deser;
|
||||||
}
|
}
|
||||||
// 重写增强:开始查找指定枚举类型的接口的反序列化器(例如:GenderEnum 枚举类型,则是找它的接口 BaseEnum 的反序列化器)
|
// 重写增强:开始查找指定枚举类型的接口的反序列化器(例如:GenderEnum 枚举类型,则是找它的接口 BaseEnum 的反序列化器)
|
||||||
for (Class<?> typeInterface : type.getInterfaces()) {
|
for (Class<?> typeInterface : type.getInterfaces()) {
|
||||||
deser = this._classMappings.get(new ClassKey(typeInterface));
|
deser = this._classMappings.get(new ClassKey(typeInterface));
|
||||||
if (null != deser) {
|
if (deser != null) {
|
||||||
return deser;
|
return deser;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,19 +54,19 @@ public abstract class AbstractLogHandler implements LogHandler {
|
|||||||
public boolean isRecord(Method targetMethod, Class<?> targetClass) {
|
public boolean isRecord(Method targetMethod, Class<?> targetClass) {
|
||||||
// 如果接口被隐藏,不记录日志
|
// 如果接口被隐藏,不记录日志
|
||||||
Operation methodOperation = AnnotationUtil.getAnnotation(targetMethod, Operation.class);
|
Operation methodOperation = AnnotationUtil.getAnnotation(targetMethod, Operation.class);
|
||||||
if (null != methodOperation && methodOperation.hidden()) {
|
if (methodOperation != null && methodOperation.hidden()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Hidden methodHidden = AnnotationUtil.getAnnotation(targetMethod, Hidden.class);
|
Hidden methodHidden = AnnotationUtil.getAnnotation(targetMethod, Hidden.class);
|
||||||
if (null != methodHidden) {
|
if (methodHidden != null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (null != targetClass.getDeclaredAnnotation(Hidden.class)) {
|
if (targetClass.getDeclaredAnnotation(Hidden.class) != null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 如果接口方法或类上有 @Log 注解,且要求忽略该接口,则不记录日志
|
// 如果接口方法或类上有 @Log 注解,且要求忽略该接口,则不记录日志
|
||||||
Log methodLog = AnnotationUtil.getAnnotation(targetMethod, Log.class);
|
Log methodLog = AnnotationUtil.getAnnotation(targetMethod, Log.class);
|
||||||
if (null != methodLog && methodLog.ignore()) {
|
if (methodLog != null && methodLog.ignore()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Log classLog = AnnotationUtil.getAnnotation(targetClass, Log.class);
|
Log classLog = AnnotationUtil.getAnnotation(targetClass, Log.class);
|
||||||
@@ -113,13 +113,13 @@ public abstract class AbstractLogHandler implements LogHandler {
|
|||||||
logRecord.setDescription("请在该接口方法上添加 @top.continew.starter.log.annotation.Log(value) 来指定日志描述");
|
logRecord.setDescription("请在该接口方法上添加 @top.continew.starter.log.annotation.Log(value) 来指定日志描述");
|
||||||
Log methodLog = AnnotationUtil.getAnnotation(targetMethod, Log.class);
|
Log methodLog = AnnotationUtil.getAnnotation(targetMethod, Log.class);
|
||||||
// 例如:@Log("新增部门") -> 新增部门
|
// 例如:@Log("新增部门") -> 新增部门
|
||||||
if (null != methodLog && CharSequenceUtil.isNotBlank(methodLog.value())) {
|
if (methodLog != null && CharSequenceUtil.isNotBlank(methodLog.value())) {
|
||||||
logRecord.setDescription(methodLog.value());
|
logRecord.setDescription(methodLog.value());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 例如:@Operation(summary="新增部门") -> 新增部门
|
// 例如:@Operation(summary="新增部门") -> 新增部门
|
||||||
Operation methodOperation = AnnotationUtil.getAnnotation(targetMethod, Operation.class);
|
Operation methodOperation = AnnotationUtil.getAnnotation(targetMethod, Operation.class);
|
||||||
if (null != methodOperation && CharSequenceUtil.isNotBlank(methodOperation.summary())) {
|
if (methodOperation != null && CharSequenceUtil.isNotBlank(methodOperation.summary())) {
|
||||||
logRecord.setDescription(methodOperation.summary());
|
logRecord.setDescription(methodOperation.summary());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,18 +137,18 @@ public abstract class AbstractLogHandler implements LogHandler {
|
|||||||
Log methodLog = AnnotationUtil.getAnnotation(targetMethod, Log.class);
|
Log methodLog = AnnotationUtil.getAnnotation(targetMethod, Log.class);
|
||||||
// 例如:@Log(module = "部门管理") -> 部门管理
|
// 例如:@Log(module = "部门管理") -> 部门管理
|
||||||
// 方法级注解优先级高于类级注解
|
// 方法级注解优先级高于类级注解
|
||||||
if (null != methodLog && CharSequenceUtil.isNotBlank(methodLog.module())) {
|
if (methodLog != null && CharSequenceUtil.isNotBlank(methodLog.module())) {
|
||||||
logRecord.setModule(methodLog.module());
|
logRecord.setModule(methodLog.module());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log classLog = AnnotationUtil.getAnnotation(targetClass, Log.class);
|
Log classLog = AnnotationUtil.getAnnotation(targetClass, Log.class);
|
||||||
if (null != classLog && CharSequenceUtil.isNotBlank(classLog.module())) {
|
if (classLog != null && CharSequenceUtil.isNotBlank(classLog.module())) {
|
||||||
logRecord.setModule(classLog.module());
|
logRecord.setModule(classLog.module());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 例如:@Tag(name = "部门管理") -> 部门管理
|
// 例如:@Tag(name = "部门管理") -> 部门管理
|
||||||
Tag classTag = AnnotationUtil.getAnnotation(targetClass, Tag.class);
|
Tag classTag = AnnotationUtil.getAnnotation(targetClass, Tag.class);
|
||||||
if (null != classTag && CharSequenceUtil.isNotBlank(classTag.name())) {
|
if (classTag != null && CharSequenceUtil.isNotBlank(classTag.name())) {
|
||||||
logRecord.setModule(classTag.name());
|
logRecord.setModule(classTag.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -157,12 +157,12 @@ public abstract class AbstractLogHandler implements LogHandler {
|
|||||||
public Set<Include> getIncludes(Set<Include> includes, Method targetMethod, Class<?> targetClass) {
|
public Set<Include> getIncludes(Set<Include> includes, Method targetMethod, Class<?> targetClass) {
|
||||||
Log classLog = AnnotationUtil.getAnnotation(targetClass, Log.class);
|
Log classLog = AnnotationUtil.getAnnotation(targetClass, Log.class);
|
||||||
Set<Include> includeSet = new HashSet<>(includes);
|
Set<Include> includeSet = new HashSet<>(includes);
|
||||||
if (null != classLog) {
|
if (classLog != null) {
|
||||||
this.processInclude(includeSet, classLog);
|
this.processInclude(includeSet, classLog);
|
||||||
}
|
}
|
||||||
// 方法级注解优先级高于类级注解
|
// 方法级注解优先级高于类级注解
|
||||||
Log methodLog = AnnotationUtil.getAnnotation(targetMethod, Log.class);
|
Log methodLog = AnnotationUtil.getAnnotation(targetMethod, Log.class);
|
||||||
if (null != methodLog) {
|
if (methodLog != null) {
|
||||||
this.processInclude(includeSet, methodLog);
|
this.processInclude(includeSet, methodLog);
|
||||||
}
|
}
|
||||||
return includeSet;
|
return includeSet;
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public abstract class AbstractMyBatisInterceptor {
|
|||||||
protected List<Field> getEncryptFields(Class<?> clazz) {
|
protected List<Field> getEncryptFields(Class<?> clazz) {
|
||||||
return CLASS_FIELD_CACHE.computeIfAbsent(clazz, key -> Arrays.stream(ReflectUtil.getFields(clazz))
|
return CLASS_FIELD_CACHE.computeIfAbsent(clazz, key -> Arrays.stream(ReflectUtil.getFields(clazz))
|
||||||
.filter(field -> String.class.equals(field.getType()))
|
.filter(field -> String.class.equals(field.getType()))
|
||||||
.filter(field -> null != field.getAnnotation(FieldEncrypt.class))
|
.filter(field -> field.getAnnotation(FieldEncrypt.class) != null)
|
||||||
.toList());
|
.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,6 +144,6 @@ public abstract class AbstractMyBatisInterceptor {
|
|||||||
*/
|
*/
|
||||||
public String getParameterName(Parameter parameter) {
|
public String getParameterName(Parameter parameter) {
|
||||||
Param param = parameter.getAnnotation(Param.class);
|
Param param = parameter.getAnnotation(Param.class);
|
||||||
return null != param ? param.value() : parameter.getName();
|
return param != null ? param.value() : parameter.getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,11 +96,11 @@ public class MyBatisEncryptInterceptor extends AbstractMyBatisInterceptor implem
|
|||||||
private void encryptMap(Map<String, Object> parameterMap, MappedStatement mappedStatement) {
|
private void encryptMap(Map<String, Object> parameterMap, MappedStatement mappedStatement) {
|
||||||
Object parameter;
|
Object parameter;
|
||||||
// 别名带有 et(针对 MP 的 updateById、update 等方法)
|
// 别名带有 et(针对 MP 的 updateById、update 等方法)
|
||||||
if (parameterMap.containsKey(Constants.ENTITY) && null != (parameter = parameterMap.get(Constants.ENTITY))) {
|
if (parameterMap.containsKey(Constants.ENTITY) && (parameter = parameterMap.get(Constants.ENTITY)) != null) {
|
||||||
this.encryptEntity(super.getEncryptFields(parameter), parameter);
|
this.encryptEntity(super.getEncryptFields(parameter), parameter);
|
||||||
}
|
}
|
||||||
// 别名带有 ew(针对 MP 的 UpdateWrapper、LambdaUpdateWrapper 等参数)
|
// 别名带有 ew(针对 MP 的 UpdateWrapper、LambdaUpdateWrapper 等参数)
|
||||||
if (parameterMap.containsKey(Constants.WRAPPER) && null != (parameter = parameterMap.get(Constants.WRAPPER))) {
|
if (parameterMap.containsKey(Constants.WRAPPER) && (parameter = parameterMap.get(Constants.WRAPPER)) != null) {
|
||||||
this.encryptUpdateWrapper(parameter, mappedStatement);
|
this.encryptUpdateWrapper(parameter, mappedStatement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,7 +122,7 @@ public class MyBatisEncryptInterceptor extends AbstractMyBatisInterceptor implem
|
|||||||
}
|
}
|
||||||
if (parameterValue instanceof String str) {
|
if (parameterValue instanceof String str) {
|
||||||
FieldEncrypt fieldEncrypt = encryptParameterMap.get(parameterName);
|
FieldEncrypt fieldEncrypt = encryptParameterMap.get(parameterName);
|
||||||
if (null != fieldEncrypt) {
|
if (fieldEncrypt != null) {
|
||||||
parameterMap.put(parameterName, this.doEncrypt(str, fieldEncrypt));
|
parameterMap.put(parameterName, this.doEncrypt(str, fieldEncrypt));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -123,7 +123,8 @@ public class SpringWebUtils {
|
|||||||
final ResourceHandlerRegistry resourceHandlerRegistry = new ResourceHandlerRegistry(applicationContext, servletContext, contentNegotiationManager, urlPathHelper);
|
final ResourceHandlerRegistry resourceHandlerRegistry = new ResourceHandlerRegistry(applicationContext, servletContext, contentNegotiationManager, urlPathHelper);
|
||||||
for (Map.Entry<String, String> entry : handlerMap.entrySet()) {
|
for (Map.Entry<String, String> entry : handlerMap.entrySet()) {
|
||||||
// 移除之前注册的映射
|
// 移除之前注册的映射
|
||||||
String pathPattern = CharSequenceUtil.appendIfMissing(CharSequenceUtil.removeSuffix(entry.getKey(), StringConstants.SLASH), StringConstants.PATH_PATTERN);
|
String pathPattern = CharSequenceUtil.appendIfMissing(CharSequenceUtil.removeSuffix(entry
|
||||||
|
.getKey(), StringConstants.SLASH), StringConstants.PATH_PATTERN);
|
||||||
oldHandlerMap.remove(pathPattern);
|
oldHandlerMap.remove(pathPattern);
|
||||||
// 重新注册映射
|
// 重新注册映射
|
||||||
String resourceLocations = CharSequenceUtil.appendIfMissing(entry.getValue(), StringConstants.SLASH);
|
String resourceLocations = CharSequenceUtil.appendIfMissing(entry.getValue(), StringConstants.SLASH);
|
||||||
|
|||||||
Reference in New Issue
Block a user