From bd733cb193086b1629dd6d8adf88990b1f8d2c8e Mon Sep 17 00:00:00 2001 From: zhouhao Date: Tue, 2 Jan 2024 10:48:18 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=9B=BF=E6=8D=A2=E8=BF=87?= =?UTF-8?q?=E6=97=B6=E7=9A=84api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/authorization/AuthenticationUtils.java | 3 ++- .../basic/define/DefaultBasicAuthorizeDefinition.java | 3 ++- .../hswebframework/web/oauth2/server/OAuth2Client.java | 5 +++-- .../server/auth/ReactiveOAuth2AccessTokenParser.java | 3 ++- .../web/oauth2/server/utils/OAuth2ScopeUtils.java | 3 ++- .../web/crud/service/TreeSortEntityService.java | 9 +++++---- .../main/java/org/hswebframework/web/dict/EnumDict.java | 3 ++- .../org/hswebframework/web/utils/ExpressionUtils.java | 3 ++- .../java/org/hswebframework/web/utils/ModuleUtils.java | 5 +++-- .../org/hswebframework/web/utils/ReactiveWebUtils.java | 3 ++- .../main/java/org/hswebframework/web/utils/WebUtils.java | 3 ++- .../AnnotationDataSourceSwitchStrategyMatcher.java | 3 ++- .../web/logging/aop/Swagger3AccessLoggerParser.java | 3 ++- .../web/logging/aop/SwaggerAccessLoggerParser.java | 3 ++- .../authorization/api/entity/DimensionUserEntity.java | 3 ++- .../service/DefaultAuthorizationSettingService.java | 3 ++- .../DefaultReactiveAuthenticationInitializeService.java | 3 ++- .../defaults/service/DefaultReactiveUserService.java | 3 ++- .../service/CompositeDictDefineRepository.java | 3 ++- 19 files changed, 43 insertions(+), 24 deletions(-) diff --git a/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/AuthenticationUtils.java b/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/AuthenticationUtils.java index 758dc374f..0415c0064 100644 --- a/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/AuthenticationUtils.java +++ b/hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/AuthenticationUtils.java @@ -1,5 +1,6 @@ package org.hswebframework.web.authorization; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; /** @@ -9,7 +10,7 @@ import org.springframework.util.StringUtils; public class AuthenticationUtils { public static AuthenticationPredicate createPredicate(String expression) { - if (StringUtils.isEmpty(expression)) { + if (ObjectUtils.isEmpty(expression)) { return (authentication -> false); } AuthenticationPredicate main = null; diff --git a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/define/DefaultBasicAuthorizeDefinition.java b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/define/DefaultBasicAuthorizeDefinition.java index dd334acf8..2f4e1ff5f 100644 --- a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/define/DefaultBasicAuthorizeDefinition.java +++ b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/define/DefaultBasicAuthorizeDefinition.java @@ -5,6 +5,7 @@ import lombok.*; import org.hswebframework.web.authorization.annotation.*; import org.hswebframework.web.authorization.define.*; import org.springframework.core.annotation.AnnotatedElementUtils; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import java.lang.annotation.Annotation; @@ -131,7 +132,7 @@ public class DefaultBasicAuthorizeDefinition implements AopAuthorizeDefinition { typeDefinition.setConfiguration(dataAccessType.configuration()); typeDefinition.setDescription(String.join("\n", dataAccessType.description())); } - if (StringUtils.isEmpty(typeDefinition.getId())) { + if (ObjectUtils.isEmpty(typeDefinition.getId())) { return; } definition.getDataAccess() diff --git a/hsweb-authorization/hsweb-authorization-oauth2/src/main/java/org/hswebframework/web/oauth2/server/OAuth2Client.java b/hsweb-authorization/hsweb-authorization-oauth2/src/main/java/org/hswebframework/web/oauth2/server/OAuth2Client.java index 29fc207f0..bed446d9e 100644 --- a/hsweb-authorization/hsweb-authorization-oauth2/src/main/java/org/hswebframework/web/oauth2/server/OAuth2Client.java +++ b/hsweb-authorization/hsweb-authorization-oauth2/src/main/java/org/hswebframework/web/oauth2/server/OAuth2Client.java @@ -4,6 +4,7 @@ import lombok.Getter; import lombok.Setter; import org.hswebframework.web.oauth2.ErrorType; import org.hswebframework.web.oauth2.OAuth2Exception; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import jakarta.validation.constraints.NotBlank; @@ -30,13 +31,13 @@ public class OAuth2Client { private String userId; public void validateRedirectUri(String redirectUri) { - if (StringUtils.isEmpty(redirectUri) || (!redirectUri.startsWith(this.redirectUrl))) { + if (ObjectUtils.isEmpty(redirectUri) || (!redirectUri.startsWith(this.redirectUrl))) { throw new OAuth2Exception(ErrorType.ILLEGAL_REDIRECT_URI); } } public void validateSecret(String secret) { - if (StringUtils.isEmpty(secret) || (!secret.equals(this.clientSecret))) { + if (ObjectUtils.isEmpty(secret) || (!secret.equals(this.clientSecret))) { throw new OAuth2Exception(ErrorType.ILLEGAL_CLIENT_SECRET); } } diff --git a/hsweb-authorization/hsweb-authorization-oauth2/src/main/java/org/hswebframework/web/oauth2/server/auth/ReactiveOAuth2AccessTokenParser.java b/hsweb-authorization/hsweb-authorization-oauth2/src/main/java/org/hswebframework/web/oauth2/server/auth/ReactiveOAuth2AccessTokenParser.java index 152d0b525..88fe0257c 100644 --- a/hsweb-authorization/hsweb-authorization-oauth2/src/main/java/org/hswebframework/web/oauth2/server/auth/ReactiveOAuth2AccessTokenParser.java +++ b/hsweb-authorization/hsweb-authorization-oauth2/src/main/java/org/hswebframework/web/oauth2/server/auth/ReactiveOAuth2AccessTokenParser.java @@ -10,6 +10,7 @@ import org.hswebframework.web.context.ContextUtils; import org.hswebframework.web.logger.ReactiveLogger; import org.hswebframework.web.oauth2.server.AccessTokenManager; import org.springframework.http.HttpHeaders; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import org.springframework.web.server.ServerWebExchange; import reactor.core.publisher.Mono; @@ -23,7 +24,7 @@ public class ReactiveOAuth2AccessTokenParser implements ReactiveUserTokenParser, public Mono parseToken(ServerWebExchange exchange) { String token = exchange.getRequest().getQueryParams().getFirst("access_token"); - if (StringUtils.isEmpty(token)) { + if (ObjectUtils.isEmpty(token)) { token = exchange.getRequest().getHeaders().getFirst(HttpHeaders.AUTHORIZATION); if (StringUtils.hasText(token)) { String[] typeAndToken = token.split("[ ]"); diff --git a/hsweb-authorization/hsweb-authorization-oauth2/src/main/java/org/hswebframework/web/oauth2/server/utils/OAuth2ScopeUtils.java b/hsweb-authorization/hsweb-authorization-oauth2/src/main/java/org/hswebframework/web/oauth2/server/utils/OAuth2ScopeUtils.java index 40806f974..939b0dd4c 100644 --- a/hsweb-authorization/hsweb-authorization-oauth2/src/main/java/org/hswebframework/web/oauth2/server/utils/OAuth2ScopeUtils.java +++ b/hsweb-authorization/hsweb-authorization-oauth2/src/main/java/org/hswebframework/web/oauth2/server/utils/OAuth2ScopeUtils.java @@ -1,6 +1,7 @@ package org.hswebframework.web.oauth2.server.utils; import org.hswebframework.web.oauth2.server.ScopePredicate; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import java.util.*; @@ -16,7 +17,7 @@ import java.util.*; public class OAuth2ScopeUtils { public static ScopePredicate createScopePredicate(String scopeStr) { - if (StringUtils.isEmpty(scopeStr)) { + if (ObjectUtils.isEmpty(scopeStr)) { return ((permission, action) -> false); } String[] scopes = scopeStr.split("[ ,\n]"); diff --git a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/TreeSortEntityService.java b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/TreeSortEntityService.java index 4f0507228..c35ffdd5f 100644 --- a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/TreeSortEntityService.java +++ b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/TreeSortEntityService.java @@ -9,6 +9,7 @@ import org.hswebframework.web.api.crud.entity.TreeSupportEntity; import org.hswebframework.web.id.IDGenerator; import org.reactivestreams.Publisher; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -88,7 +89,7 @@ public interface TreeSortEntityService, K> default Stream applyTreeProperty(E ele) { if (StringUtils.hasText(ele.getPath()) || - StringUtils.isEmpty(ele.getParentId())) { + ObjectUtils.isEmpty(ele.getParentId())) { return Stream.of(ele); } @@ -100,7 +101,7 @@ public interface TreeSortEntityService, K> //校验是否有循环依赖,修改父节点为自己的子节点? default void checkCyclicDependency(K id, E ele) { - if (StringUtils.isEmpty(id)) { + if (ObjectUtils.isEmpty(id)) { return; } for (E e : this.queryIncludeChildren(Collections.singletonList(id))) { @@ -158,7 +159,7 @@ public interface TreeSortEntityService, K> return true; } //有父节点,但是父节点不存在 - if (!StringUtils.isEmpty(node.getParentId())) { + if (!ObjectUtils.isEmpty(node.getParentId())) { return helper.getNode(node.getParentId()) == null; } return false; @@ -166,6 +167,6 @@ public interface TreeSortEntityService, K> } default boolean isRootNode(E entity) { - return StringUtils.isEmpty(entity.getParentId()) || "-1".equals(String.valueOf(entity.getParentId())); + return ObjectUtils.isEmpty(entity.getParentId()) || "-1".equals(String.valueOf(entity.getParentId())); } } diff --git a/hsweb-core/src/main/java/org/hswebframework/web/dict/EnumDict.java b/hsweb-core/src/main/java/org/hswebframework/web/dict/EnumDict.java index 77508b67a..512ab516e 100644 --- a/hsweb-core/src/main/java/org/hswebframework/web/dict/EnumDict.java +++ b/hsweb-core/src/main/java/org/hswebframework/web/dict/EnumDict.java @@ -25,6 +25,7 @@ import org.hswebframework.web.dict.defaults.DefaultItemDefine; import org.hswebframework.web.exception.ValidationException; import org.hswebframework.web.i18n.LocaleUtils; import org.springframework.beans.BeanUtils; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import java.io.IOException; @@ -392,7 +393,7 @@ public interface EnumDict extends JSONSerializable { String currentName = jp.currentName(); Object currentValue = jp.getCurrentValue(); Class findPropertyType; - if (StringUtils.isEmpty(currentName) || StringUtils.isEmpty(currentValue)) { + if (ObjectUtils.isEmpty(currentName) || ObjectUtils.isEmpty(currentValue)) { return null; } else { findPropertyType = BeanUtils.findPropertyType(currentName, currentValue.getClass()); diff --git a/hsweb-core/src/main/java/org/hswebframework/web/utils/ExpressionUtils.java b/hsweb-core/src/main/java/org/hswebframework/web/utils/ExpressionUtils.java index 181690cdc..3f5e222f8 100644 --- a/hsweb-core/src/main/java/org/hswebframework/web/utils/ExpressionUtils.java +++ b/hsweb-core/src/main/java/org/hswebframework/web/utils/ExpressionUtils.java @@ -2,6 +2,7 @@ package org.hswebframework.web.utils; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import java.util.HashMap; @@ -80,7 +81,7 @@ public class ExpressionUtils { return TemplateParser.parse(expression, var -> { - if (StringUtils.isEmpty(var)) { + if (ObjectUtils.isEmpty(var)) { return ""; } Object val = vars.get(var); diff --git a/hsweb-core/src/main/java/org/hswebframework/web/utils/ModuleUtils.java b/hsweb-core/src/main/java/org/hswebframework/web/utils/ModuleUtils.java index 46e92c6f2..0705ae9d5 100644 --- a/hsweb-core/src/main/java/org/hswebframework/web/utils/ModuleUtils.java +++ b/hsweb-core/src/main/java/org/hswebframework/web/utils/ModuleUtils.java @@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.core.io.Resource; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.util.ClassUtils; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import java.security.CodeSource; @@ -144,14 +145,14 @@ public abstract class ModuleUtils { } public String getId() { - if (StringUtils.isEmpty(id)) { + if (ObjectUtils.isEmpty(id)) { id = groupId + "/" + artifactId; } return id; } public boolean isNone() { - return StringUtils.isEmpty(classPath); + return ObjectUtils.isEmpty(classPath); } } } diff --git a/hsweb-core/src/main/java/org/hswebframework/web/utils/ReactiveWebUtils.java b/hsweb-core/src/main/java/org/hswebframework/web/utils/ReactiveWebUtils.java index ced5b8630..b38e1d895 100644 --- a/hsweb-core/src/main/java/org/hswebframework/web/utils/ReactiveWebUtils.java +++ b/hsweb-core/src/main/java/org/hswebframework/web/utils/ReactiveWebUtils.java @@ -1,6 +1,7 @@ package org.hswebframework.web.utils; import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import java.net.InetSocketAddress; @@ -25,7 +26,7 @@ public class ReactiveWebUtils { public static String getIpAddr(ServerHttpRequest request) { for (String ipHeader : ipHeaders) { String ip = request.getHeaders().getFirst(ipHeader); - if (!StringUtils.isEmpty(ip) && !ip.contains("unknown")) { + if (!ObjectUtils.isEmpty(ip) && !ip.contains("unknown")) { return ip; } } diff --git a/hsweb-core/src/main/java/org/hswebframework/web/utils/WebUtils.java b/hsweb-core/src/main/java/org/hswebframework/web/utils/WebUtils.java index 707078375..64d96e80e 100644 --- a/hsweb-core/src/main/java/org/hswebframework/web/utils/WebUtils.java +++ b/hsweb-core/src/main/java/org/hswebframework/web/utils/WebUtils.java @@ -19,6 +19,7 @@ package org.hswebframework.web.utils; import jakarta.servlet.http.HttpServletRequest; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; @@ -114,7 +115,7 @@ public class WebUtils { public static String getIpAddr(HttpServletRequest request) { for (String ipHeader : ipHeaders) { String ip = request.getHeader(ipHeader); - if (!StringUtils.isEmpty(ip) && !ip.contains("unknown")) { + if (!ObjectUtils.isEmpty(ip) && !ip.contains("unknown")) { return ip; } } diff --git a/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/strategy/AnnotationDataSourceSwitchStrategyMatcher.java b/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/strategy/AnnotationDataSourceSwitchStrategyMatcher.java index 2afba3c2c..18bb59ed2 100644 --- a/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/strategy/AnnotationDataSourceSwitchStrategyMatcher.java +++ b/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/strategy/AnnotationDataSourceSwitchStrategyMatcher.java @@ -3,6 +3,7 @@ package org.hswebframework.web.datasource.strategy; import org.hswebframework.web.datasource.annotation.UseDataSource; import org.hswebframework.web.datasource.annotation.UseDefaultDataSource; import org.hswebframework.web.utils.AnnotationUtils; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import java.lang.reflect.Method; @@ -50,7 +51,7 @@ public class AnnotationDataSourceSwitchStrategyMatcher extends CachedDataSourceS @Override public String getDatabase() { - return useDataSource == null ? null : StringUtils.isEmpty(useDataSource.database()) ? null : useDataSource.database(); + return useDataSource == null ? null : ObjectUtils.isEmpty(useDataSource.database()) ? null : useDataSource.database(); } }; } diff --git a/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/Swagger3AccessLoggerParser.java b/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/Swagger3AccessLoggerParser.java index 12de9191b..269eaab8b 100644 --- a/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/Swagger3AccessLoggerParser.java +++ b/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/Swagger3AccessLoggerParser.java @@ -6,6 +6,7 @@ import org.hswebframework.web.aop.MethodInterceptorHolder; import org.hswebframework.web.logging.LoggerDefine; import org.springframework.core.annotation.AnnotatedElementUtils; import org.springframework.core.annotation.AnnotationUtils; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import java.lang.reflect.Method; @@ -29,7 +30,7 @@ public class Swagger3AccessLoggerParser implements AccessLoggerParser { action = action.concat(api.name()); } if (null != operation) { - action = StringUtils.isEmpty(action) ? operation.summary() : action + "-" + operation.summary(); + action = ObjectUtils.isEmpty(action) ? operation.summary() : action + "-" + operation.summary(); } return new LoggerDefine(action, ""); } diff --git a/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/SwaggerAccessLoggerParser.java b/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/SwaggerAccessLoggerParser.java index 2ac75180b..0ce5a0054 100644 --- a/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/SwaggerAccessLoggerParser.java +++ b/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/SwaggerAccessLoggerParser.java @@ -5,6 +5,7 @@ import io.swagger.annotations.ApiOperation; import org.hswebframework.web.aop.MethodInterceptorHolder; import org.hswebframework.web.logging.LoggerDefine; import org.springframework.core.annotation.AnnotationUtils; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import java.lang.reflect.Method; @@ -28,7 +29,7 @@ public class SwaggerAccessLoggerParser implements AccessLoggerParser { action = action.concat(api.value()); } if (null != operation) { - action = StringUtils.isEmpty(action) ? operation.value() : action + "-" + operation.value(); + action = ObjectUtils.isEmpty(action) ? operation.value() : action + "-" + operation.value(); } return new LoggerDefine(action, ""); } diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/DimensionUserEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/DimensionUserEntity.java index 77474aa46..a5c6e7b86 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/DimensionUserEntity.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/DimensionUserEntity.java @@ -11,6 +11,7 @@ import org.hswebframework.web.crud.annotation.EnableEntityEvent; import org.hswebframework.web.dict.EnumDict; import org.hswebframework.web.system.authorization.api.enums.DimensionUserFeature; import org.springframework.util.DigestUtils; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import javax.persistence.Column; @@ -75,7 +76,7 @@ public class DimensionUserEntity extends GenericEntity { private DimensionUserFeature[] features; public void generateId() { - if (StringUtils.isEmpty(getId())) { + if (ObjectUtils.isEmpty(getId())) { String id = DigestUtils .md5DigestAsHex(String.format("%s-%s-%s", dimensionTypeId, diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/service/DefaultAuthorizationSettingService.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/service/DefaultAuthorizationSettingService.java index 3f3af051a..b36063ece 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/service/DefaultAuthorizationSettingService.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/service/DefaultAuthorizationSettingService.java @@ -19,6 +19,7 @@ import org.reactivestreams.Publisher; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.event.EventListener; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -37,7 +38,7 @@ public class DefaultAuthorizationSettingService extends GenericReactiveCrudServi private List providers; protected AuthorizationSettingEntity generateId(AuthorizationSettingEntity entity) { - if (StringUtils.isEmpty(entity.getId())) { + if (ObjectUtils.isEmpty(entity.getId())) { entity.setId(DigestUtils.md5Hex(entity.getPermission() + entity.getDimensionType() + entity.getDimensionTarget())); } return entity; diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/service/DefaultReactiveAuthenticationInitializeService.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/service/DefaultReactiveAuthenticationInitializeService.java index be5cf9489..2f7d1e404 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/service/DefaultReactiveAuthenticationInitializeService.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/service/DefaultReactiveAuthenticationInitializeService.java @@ -23,6 +23,7 @@ import org.hswebframework.web.system.authorization.api.entity.UserEntity; import org.hswebframework.web.system.authorization.api.service.reactive.ReactiveUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -172,7 +173,7 @@ public class DefaultReactiveAuthenticationInitializeService continue; } for (ParentPermission parent : permissionEntity.getParents()) { - if (StringUtils.isEmpty(parent.getPermission())) { + if (ObjectUtils.isEmpty(parent.getPermission())) { continue; } Set pre = parent.getPreActions(); diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/service/DefaultReactiveUserService.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/service/DefaultReactiveUserService.java index 81c42b394..d1055043b 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/service/DefaultReactiveUserService.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/service/DefaultReactiveUserService.java @@ -21,6 +21,7 @@ import org.reactivestreams.Publisher; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -60,7 +61,7 @@ public class DefaultReactiveUserService extends GenericReactiveCrudService saveUser(Mono request) { return request .flatMap(userEntity -> { - if (StringUtils.isEmpty(userEntity.getId())) { + if (ObjectUtils.isEmpty(userEntity.getId())) { return doAdd(userEntity); } return findById(userEntity.getId()) diff --git a/hsweb-system/hsweb-system-dictionary/src/main/java/org/hswebframework/web/dictionary/service/CompositeDictDefineRepository.java b/hsweb-system/hsweb-system-dictionary/src/main/java/org/hswebframework/web/dictionary/service/CompositeDictDefineRepository.java index cf71b823e..44cf5d73a 100644 --- a/hsweb-system/hsweb-system-dictionary/src/main/java/org/hswebframework/web/dictionary/service/CompositeDictDefineRepository.java +++ b/hsweb-system/hsweb-system-dictionary/src/main/java/org/hswebframework/web/dictionary/service/CompositeDictDefineRepository.java @@ -9,6 +9,7 @@ import org.hswebframework.web.dictionary.entity.DictionaryEntity; import org.hswebframework.web.dictionary.event.ClearDictionaryCacheEvent; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.event.EventListener; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -24,7 +25,7 @@ public class CompositeDictDefineRepository extends DefaultDictDefineRepository { @EventListener public void handleClearCacheEvent(ClearDictionaryCacheEvent event) { - if (StringUtils.isEmpty(event.getDictionaryId())) { + if (ObjectUtils.isEmpty(event.getDictionaryId())) { cacheManager.getCache("dic-define") .clear() .doOnSuccess(r -> log.info("clear all dic cache success"))