diff --git a/blade-core-boot/pom.xml b/blade-core-boot/pom.xml
index cbc6efb..433815d 100644
--- a/blade-core-boot/pom.xml
+++ b/blade-core-boot/pom.xml
@@ -5,7 +5,7 @@
org.springblade
blade-tool
- 3.6.0
+ 3.7.0
4.0.0
@@ -88,7 +88,7 @@
com.alibaba
druid-spring-boot-starter
- 1.2.16
+ 1.2.19
diff --git a/blade-core-boot/src/main/resources/bootstrap.yml b/blade-core-boot/src/main/resources/bootstrap.yml
index d800659..1855c24 100644
--- a/blade-core-boot/src/main/resources/bootstrap.yml
+++ b/blade-core-boot/src/main/resources/bootstrap.yml
@@ -101,7 +101,7 @@ mybatis-plus:
swagger:
title: SpringBlade 接口文档系统
description: SpringBlade 接口文档系统
- version: 3.6.0
+ version: 3.7.0
license: Powered By SpringBlade
licenseUrl: https://bladex.vip
terms-of-service-url: https://bladex.vip
diff --git a/blade-core-cloud/pom.xml b/blade-core-cloud/pom.xml
index d0d7f4e..04aa6c6 100644
--- a/blade-core-cloud/pom.xml
+++ b/blade-core-cloud/pom.xml
@@ -5,7 +5,7 @@
blade-tool
org.springblade
- 3.6.0
+ 3.7.0
4.0.0
diff --git a/blade-core-crypto/pom.xml b/blade-core-crypto/pom.xml
index 3208346..83a43ca 100644
--- a/blade-core-crypto/pom.xml
+++ b/blade-core-crypto/pom.xml
@@ -5,7 +5,7 @@
blade-tool
org.springblade
- 3.6.0
+ 3.7.0
4.0.0
diff --git a/blade-core-datascope/pom.xml b/blade-core-datascope/pom.xml
index 085a990..dfa44ae 100644
--- a/blade-core-datascope/pom.xml
+++ b/blade-core-datascope/pom.xml
@@ -5,7 +5,7 @@
blade-tool
org.springblade
- 3.6.0
+ 3.7.0
4.0.0
diff --git a/blade-core-develop/pom.xml b/blade-core-develop/pom.xml
index 6085921..c6ac878 100644
--- a/blade-core-develop/pom.xml
+++ b/blade-core-develop/pom.xml
@@ -5,7 +5,7 @@
blade-tool
org.springblade
- 3.6.0
+ 3.7.0
4.0.0
diff --git a/blade-core-launch/pom.xml b/blade-core-launch/pom.xml
index 82cd728..52b8fad 100644
--- a/blade-core-launch/pom.xml
+++ b/blade-core-launch/pom.xml
@@ -5,7 +5,7 @@
blade-tool
org.springblade
- 3.6.0
+ 3.7.0
4.0.0
diff --git a/blade-core-launch/src/main/java/org/springblade/core/launch/constant/AppConstant.java b/blade-core-launch/src/main/java/org/springblade/core/launch/constant/AppConstant.java
index 32c770c..ee2d3ee 100644
--- a/blade-core-launch/src/main/java/org/springblade/core/launch/constant/AppConstant.java
+++ b/blade-core-launch/src/main/java/org/springblade/core/launch/constant/AppConstant.java
@@ -25,7 +25,7 @@ public interface AppConstant {
/**
* 应用版本
*/
- String APPLICATION_VERSION = "3.6.0";
+ String APPLICATION_VERSION = "3.7.0";
/**
* 基础包
diff --git a/blade-core-launch/src/main/java/org/springblade/core/launch/constant/TokenConstant.java b/blade-core-launch/src/main/java/org/springblade/core/launch/constant/TokenConstant.java
index f65910f..0374102 100644
--- a/blade-core-launch/src/main/java/org/springblade/core/launch/constant/TokenConstant.java
+++ b/blade-core-launch/src/main/java/org/springblade/core/launch/constant/TokenConstant.java
@@ -25,6 +25,7 @@ public interface TokenConstant {
String AVATAR = "avatar";
String HEADER = "blade-auth";
String BEARER = "bearer";
+ String CRYPTO = "crypto";
String ACCESS_TOKEN = "access_token";
String REFRESH_TOKEN = "refresh_token";
String TOKEN_TYPE = "token_type";
diff --git a/blade-core-launch/src/main/java/org/springblade/core/launch/props/BladeProperties.java b/blade-core-launch/src/main/java/org/springblade/core/launch/props/BladeProperties.java
index 852bf11..3ebc888 100644
--- a/blade-core-launch/src/main/java/org/springblade/core/launch/props/BladeProperties.java
+++ b/blade-core-launch/src/main/java/org/springblade/core/launch/props/BladeProperties.java
@@ -18,10 +18,14 @@ package org.springblade.core.launch.props;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.EnvironmentAware;
+import org.springframework.core.env.Environment;
+import org.springframework.core.env.EnvironmentCapable;
import org.springframework.lang.Nullable;
import java.util.HashMap;
import java.util.Map;
+import java.util.Objects;
/**
* 配置文件
@@ -29,7 +33,9 @@ import java.util.Map;
* @author Chill
*/
@ConfigurationProperties("blade")
-public class BladeProperties {
+public class BladeProperties implements EnvironmentAware, EnvironmentCapable {
+ @Nullable
+ private Environment environment;
/**
* 开发环境
@@ -204,4 +210,14 @@ public class BladeProperties {
return prop.containsKey(key);
}
+ @Override
+ public void setEnvironment(Environment environment) {
+ this.environment = environment;
+ }
+
+ @Override
+ public Environment getEnvironment() {
+ Objects.requireNonNull(environment, "Spring boot 环境下 Environment 不可能为null");
+ return this.environment;
+ }
}
diff --git a/blade-core-loadbalancer/pom.xml b/blade-core-loadbalancer/pom.xml
index 5d469e1..c126d8c 100644
--- a/blade-core-loadbalancer/pom.xml
+++ b/blade-core-loadbalancer/pom.xml
@@ -5,7 +5,7 @@
blade-tool
org.springblade
- 3.6.0
+ 3.7.0
4.0.0
diff --git a/blade-core-log/pom.xml b/blade-core-log/pom.xml
index c47b5c4..9093b21 100644
--- a/blade-core-log/pom.xml
+++ b/blade-core-log/pom.xml
@@ -5,7 +5,7 @@
blade-tool
org.springblade
- 3.6.0
+ 3.7.0
4.0.0
diff --git a/blade-core-mybatis/pom.xml b/blade-core-mybatis/pom.xml
index 1cac151..129be4c 100644
--- a/blade-core-mybatis/pom.xml
+++ b/blade-core-mybatis/pom.xml
@@ -5,7 +5,7 @@
blade-tool
org.springblade
- 3.6.0
+ 3.7.0
4.0.0
diff --git a/blade-core-mybatis/src/main/java/org/springblade/core/mp/support/SqlKeyword.java b/blade-core-mybatis/src/main/java/org/springblade/core/mp/support/SqlKeyword.java
index 2096dca..212fb60 100644
--- a/blade-core-mybatis/src/main/java/org/springblade/core/mp/support/SqlKeyword.java
+++ b/blade-core-mybatis/src/main/java/org/springblade/core/mp/support/SqlKeyword.java
@@ -16,6 +16,7 @@
package org.springblade.core.mp.support;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringPool;
import org.springblade.core.tool.utils.StringUtil;
@@ -28,17 +29,23 @@ import java.util.Map;
* @author Chill
*/
public class SqlKeyword {
- private final static String SQL_REGEX = "'|%|--|insert|delete|select|count|group|union|drop|truncate|alter|grant|execute|exec|xp_cmdshell|call|declare|sql";
+ private final static String SQL_REGEX = "'|%|--|insert|delete|select|sleep|count|group|union|drop|truncate|alter|grant|execute|exec|xp_cmdshell|call|declare|sql";
private static final String EQUAL = "_equal";
private static final String NOT_EQUAL = "_notequal";
private static final String LIKE = "_like";
+ private static final String LIKE_LEFT = "_likeleft";
+ private static final String LIKE_RIGHT = "_likeright";
private static final String NOT_LIKE = "_notlike";
+ private static final String GE = "_ge";
+ private static final String LE = "_le";
private static final String GT = "_gt";
private static final String LT = "_lt";
+ private static final String DATE_GE = "_datege";
private static final String DATE_GT = "_dategt";
private static final String DATE_EQUAL = "_dateequal";
private static final String DATE_LT = "_datelt";
+ private static final String DATE_LE = "_datele";
private static final String IS_NULL = "_null";
private static final String NOT_NULL = "_notnull";
private static final String IGNORE = "_ignore";
@@ -57,22 +64,36 @@ public class SqlKeyword {
if (Func.hasEmpty(k, v) || k.endsWith(IGNORE)) {
return;
}
+ // 过滤sql注入关键词
+ k = filter(k);
if (k.endsWith(EQUAL)) {
qw.eq(getColumn(k, EQUAL), v);
} else if (k.endsWith(NOT_EQUAL)) {
qw.ne(getColumn(k, NOT_EQUAL), v);
+ } else if (k.endsWith(LIKE_LEFT)) {
+ qw.likeLeft(getColumn(k, LIKE_LEFT), v);
+ } else if (k.endsWith(LIKE_RIGHT)) {
+ qw.likeRight(getColumn(k, LIKE_RIGHT), v);
} else if (k.endsWith(NOT_LIKE)) {
qw.notLike(getColumn(k, NOT_LIKE), v);
+ } else if (k.endsWith(GE)) {
+ qw.ge(getColumn(k, GE), v);
+ } else if (k.endsWith(LE)) {
+ qw.le(getColumn(k, LE), v);
} else if (k.endsWith(GT)) {
qw.gt(getColumn(k, GT), v);
} else if (k.endsWith(LT)) {
qw.lt(getColumn(k, LT), v);
+ } else if (k.endsWith(DATE_GE)) {
+ qw.ge(getColumn(k, DATE_GE), DateUtil.parse(String.valueOf(v), DateUtil.PATTERN_DATETIME));
} else if (k.endsWith(DATE_GT)) {
- qw.gt(getColumn(k, DATE_GT), v);
+ qw.gt(getColumn(k, DATE_GT), DateUtil.parse(String.valueOf(v), DateUtil.PATTERN_DATETIME));
} else if (k.endsWith(DATE_EQUAL)) {
- qw.eq(getColumn(k, DATE_EQUAL), v);
+ qw.eq(getColumn(k, DATE_EQUAL), DateUtil.parse(String.valueOf(v), DateUtil.PATTERN_DATETIME));
+ } else if (k.endsWith(DATE_LE)) {
+ qw.le(getColumn(k, DATE_LE), DateUtil.parse(String.valueOf(v), DateUtil.PATTERN_DATETIME));
} else if (k.endsWith(DATE_LT)) {
- qw.lt(getColumn(k, DATE_LT), v);
+ qw.lt(getColumn(k, DATE_LT), DateUtil.parse(String.valueOf(v), DateUtil.PATTERN_DATETIME));
} else if (k.endsWith(IS_NULL)) {
qw.isNull(getColumn(k, IS_NULL));
} else if (k.endsWith(NOT_NULL)) {
@@ -106,5 +127,4 @@ public class SqlKeyword {
}
return param.replaceAll("(?i)" + SQL_REGEX, StringPool.EMPTY);
}
-
}
diff --git a/blade-core-oss/pom.xml b/blade-core-oss/pom.xml
index 256ed05..b06c705 100644
--- a/blade-core-oss/pom.xml
+++ b/blade-core-oss/pom.xml
@@ -5,7 +5,7 @@
blade-tool
org.springblade
- 3.6.0
+ 3.7.0
4.0.0
diff --git a/blade-core-report/pom.xml b/blade-core-report/pom.xml
index 6ab20f6..8003714 100644
--- a/blade-core-report/pom.xml
+++ b/blade-core-report/pom.xml
@@ -5,7 +5,7 @@
blade-tool
org.springblade
- 3.6.0
+ 3.7.0
4.0.0
diff --git a/blade-core-secure/pom.xml b/blade-core-secure/pom.xml
index a8fc5fd..da40a9b 100644
--- a/blade-core-secure/pom.xml
+++ b/blade-core-secure/pom.xml
@@ -5,7 +5,7 @@
blade-tool
org.springblade
- 3.6.0
+ 3.7.0
4.0.0
diff --git a/blade-core-secure/src/main/java/org/springblade/core/secure/auth/AuthFun.java b/blade-core-secure/src/main/java/org/springblade/core/secure/auth/AuthFun.java
index 343b783..eec53d2 100644
--- a/blade-core-secure/src/main/java/org/springblade/core/secure/auth/AuthFun.java
+++ b/blade-core-secure/src/main/java/org/springblade/core/secure/auth/AuthFun.java
@@ -15,11 +15,16 @@
*/
package org.springblade.core.secure.auth;
+import org.springblade.core.launch.constant.TokenConstant;
import org.springblade.core.secure.utils.SecureUtil;
import org.springblade.core.tool.constant.RoleConstant;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
+import org.springblade.core.tool.utils.WebUtil;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Objects;
/**
* 权限判断
@@ -76,4 +81,17 @@ public class AuthFun {
return false;
}
+ /**
+ * 判断请求是否为加密token
+ *
+ * @return {boolean}
+ */
+ public boolean hasCrypto() {
+ HttpServletRequest request = WebUtil.getRequest();
+ String auth = Objects.requireNonNull(request).getHeader(TokenConstant.HEADER);
+ return SecureUtil.isCrypto(
+ StringUtil.isNotBlank(auth) ? auth : request.getParameter(TokenConstant.HEADER)
+ );
+ }
+
}
diff --git a/blade-core-secure/src/main/java/org/springblade/core/secure/props/BladeTokenProperties.java b/blade-core-secure/src/main/java/org/springblade/core/secure/props/BladeTokenProperties.java
index abdf926..dbda950 100644
--- a/blade-core-secure/src/main/java/org/springblade/core/secure/props/BladeTokenProperties.java
+++ b/blade-core-secure/src/main/java/org/springblade/core/secure/props/BladeTokenProperties.java
@@ -37,6 +37,11 @@ public class BladeTokenProperties {
*/
private String signKey = StringPool.EMPTY;
+ /**
+ * token签名
+ */
+ private String aesKey = StringPool.EMPTY;
+
/**
* 获取签名规则
*/
diff --git a/blade-core-secure/src/main/java/org/springblade/core/secure/utils/SecureUtil.java b/blade-core-secure/src/main/java/org/springblade/core/secure/utils/SecureUtil.java
index 053bdc2..d21fdfe 100644
--- a/blade-core-secure/src/main/java/org/springblade/core/secure/utils/SecureUtil.java
+++ b/blade-core-secure/src/main/java/org/springblade/core/secure/utils/SecureUtil.java
@@ -46,6 +46,7 @@ public class SecureUtil {
private final static String HEADER = TokenConstant.HEADER;
private final static String BEARER = TokenConstant.BEARER;
+ private final static String CRYPTO = TokenConstant.CRYPTO;
private final static String ACCOUNT = TokenConstant.ACCOUNT;
private final static String USER_ID = TokenConstant.USER_ID;
private final static String ROLE_ID = TokenConstant.ROLE_ID;
@@ -292,21 +293,56 @@ public class SecureUtil {
*/
public static Claims getClaims(HttpServletRequest request) {
String auth = request.getHeader(SecureUtil.HEADER);
- if (StringUtil.isNotBlank(auth) && auth.length() > AUTH_LENGTH) {
- String headStr = auth.substring(0, 6).toLowerCase();
- if (headStr.compareTo(SecureUtil.BEARER) == 0) {
- auth = auth.substring(7);
- return SecureUtil.parseJWT(auth);
- }
- } else {
- String parameter = request.getParameter(SecureUtil.HEADER);
- if (StringUtil.isNotBlank(parameter)) {
- return SecureUtil.parseJWT(parameter);
- }
+ String token = getToken(
+ StringUtil.isNotBlank(auth) ? auth : request.getParameter(SecureUtil.HEADER)
+ );
+ return SecureUtil.parseJWT(token);
+ }
+
+ /**
+ * 获取请求传递的token串
+ *
+ * @param auth token
+ * @return String
+ */
+ public static String getToken(String auth) {
+ if (isBearer(auth)) {
+ return auth.substring(AUTH_LENGTH);
+ }
+ if (isCrypto(auth)) {
+ return AesUtil.decryptFormBase64ToString(auth.substring(AUTH_LENGTH), getTokenProperties().getAesKey());
}
return null;
}
+ /**
+ * 判断token类型为bearer
+ *
+ * @param auth token
+ * @return String
+ */
+ public static Boolean isBearer(String auth) {
+ if ((auth != null) && (auth.length() > AUTH_LENGTH)) {
+ String headStr = auth.substring(0, 6).toLowerCase();
+ return headStr.compareTo(BEARER) == 0;
+ }
+ return false;
+ }
+
+ /**
+ * 判断token类型为crypto
+ *
+ * @param auth token
+ * @return String
+ */
+ public static Boolean isCrypto(String auth) {
+ if ((auth != null) && (auth.length() > AUTH_LENGTH)) {
+ String headStr = auth.substring(0, 6).toLowerCase();
+ return headStr.compareTo(CRYPTO) == 0;
+ }
+ return false;
+ }
+
/**
* 获取请求头
*
diff --git a/blade-core-social/pom.xml b/blade-core-social/pom.xml
index f7ebb0a..1ae6e15 100644
--- a/blade-core-social/pom.xml
+++ b/blade-core-social/pom.xml
@@ -5,7 +5,7 @@
blade-tool
org.springblade
- 3.6.0
+ 3.7.0
4.0.0
diff --git a/blade-core-swagger/pom.xml b/blade-core-swagger/pom.xml
index 1a4fb10..7a16e20 100644
--- a/blade-core-swagger/pom.xml
+++ b/blade-core-swagger/pom.xml
@@ -5,7 +5,7 @@
blade-tool
org.springblade
- 3.6.0
+ 3.7.0
4.0.0
diff --git a/blade-core-swagger/src/main/java/org/springblade/core/swagger/SwaggerProperties.java b/blade-core-swagger/src/main/java/org/springblade/core/swagger/SwaggerProperties.java
index b481158..c74f8f2 100644
--- a/blade-core-swagger/src/main/java/org/springblade/core/swagger/SwaggerProperties.java
+++ b/blade-core-swagger/src/main/java/org/springblade/core/swagger/SwaggerProperties.java
@@ -55,7 +55,7 @@ public class SwaggerProperties {
/**
* 版本
**/
- private String version = "3.6.0";
+ private String version = "3.7.0";
/**
* 许可证
**/
diff --git a/blade-core-test/pom.xml b/blade-core-test/pom.xml
index 97fb053..b985d9b 100644
--- a/blade-core-test/pom.xml
+++ b/blade-core-test/pom.xml
@@ -5,7 +5,7 @@
org.springblade
blade-tool
- 3.6.0
+ 3.7.0
4.0.0
diff --git a/blade-core-tool/pom.xml b/blade-core-tool/pom.xml
index de4489a..5f50ea5 100644
--- a/blade-core-tool/pom.xml
+++ b/blade-core-tool/pom.xml
@@ -6,7 +6,7 @@
org.springblade
blade-tool
- 3.6.0
+ 3.7.0
4.0.0
diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/api/R.java b/blade-core-tool/src/main/java/org/springblade/core/tool/api/R.java
index 0f7ddf4..0f04315 100644
--- a/blade-core-tool/src/main/java/org/springblade/core/tool/api/R.java
+++ b/blade-core-tool/src/main/java/org/springblade/core/tool/api/R.java
@@ -215,6 +215,7 @@ public class R implements Serializable {
* 返回R
*
* @param flag 成功状态
+ * @param 泛型
* @return R
*/
public static R status(boolean flag) {
diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/config/RequestConfiguration.java b/blade-core-tool/src/main/java/org/springblade/core/tool/config/RequestConfiguration.java
index 1289bf9..553a981 100644
--- a/blade-core-tool/src/main/java/org/springblade/core/tool/config/RequestConfiguration.java
+++ b/blade-core-tool/src/main/java/org/springblade/core/tool/config/RequestConfiguration.java
@@ -42,6 +42,8 @@ public class RequestConfiguration {
/**
* 全局过滤器
+ *
+ * @return 自定义过滤器
*/
@Bean
public FilterRegistrationBean bladeFilterRegistration() {
diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/constant/BladeConstant.java b/blade-core-tool/src/main/java/org/springblade/core/tool/constant/BladeConstant.java
index 4560cb3..32ced67 100644
--- a/blade-core-tool/src/main/java/org/springblade/core/tool/constant/BladeConstant.java
+++ b/blade-core-tool/src/main/java/org/springblade/core/tool/constant/BladeConstant.java
@@ -69,6 +69,10 @@ public interface BladeConstant {
* 顶级父节点id
*/
Long TOP_PARENT_ID = 0L;
+ /**
+ * 顶级父节点名称
+ */
+ String TOP_PARENT_NAME = "顶级";
/**
* 管理员对应的租户ID
diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/constant/RoleConstant.java b/blade-core-tool/src/main/java/org/springblade/core/tool/constant/RoleConstant.java
index 9e5c5e8..b25d197 100644
--- a/blade-core-tool/src/main/java/org/springblade/core/tool/constant/RoleConstant.java
+++ b/blade-core-tool/src/main/java/org/springblade/core/tool/constant/RoleConstant.java
@@ -34,4 +34,6 @@ public class RoleConstant {
public static final String HAS_ROLE_TEST = "hasRole('" + TEST + "')";
+ public static final String HAS_CRYPTO = "hasCrypto()";
+
}
diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/jackson/MappingApiJackson2HttpMessageConverter.java b/blade-core-tool/src/main/java/org/springblade/core/tool/jackson/MappingApiJackson2HttpMessageConverter.java
index 3c19cc9..4b3ab93 100644
--- a/blade-core-tool/src/main/java/org/springblade/core/tool/jackson/MappingApiJackson2HttpMessageConverter.java
+++ b/blade-core-tool/src/main/java/org/springblade/core/tool/jackson/MappingApiJackson2HttpMessageConverter.java
@@ -45,6 +45,7 @@ public class MappingApiJackson2HttpMessageConverter extends AbstractReadWriteJac
* You can use {@link Jackson2ObjectMapperBuilder} to build it easily.
*
* @param objectMapper ObjectMapper
+ * @param properties properties
* @see Jackson2ObjectMapperBuilder#json()
*/
public MappingApiJackson2HttpMessageConverter(ObjectMapper objectMapper, BladeJacksonProperties properties) {
diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/node/BaseNode.java b/blade-core-tool/src/main/java/org/springblade/core/tool/node/BaseNode.java
index 67754d3..1a9105e 100644
--- a/blade-core-tool/src/main/java/org/springblade/core/tool/node/BaseNode.java
+++ b/blade-core-tool/src/main/java/org/springblade/core/tool/node/BaseNode.java
@@ -26,10 +26,10 @@ import java.util.List;
/**
* 节点基类
*
- * @author Chill
+ * @author smallchill
*/
@Data
-public class BaseNode implements INode {
+public class BaseNode implements INode {
private static final long serialVersionUID = 1L;
@@ -49,7 +49,7 @@ public class BaseNode implements INode {
* 子孙节点
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
- protected List children = new ArrayList<>();
+ protected List children = new ArrayList();
/**
* 是否有子孙节点
@@ -59,6 +59,8 @@ public class BaseNode implements INode {
/**
* 是否有子孙节点
+ *
+ * @return Boolean
*/
@Override
public Boolean getHasChildren() {
diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/node/ForestNode.java b/blade-core-tool/src/main/java/org/springblade/core/tool/node/ForestNode.java
index cc23a36..ff5b0dc 100644
--- a/blade-core-tool/src/main/java/org/springblade/core/tool/node/ForestNode.java
+++ b/blade-core-tool/src/main/java/org/springblade/core/tool/node/ForestNode.java
@@ -22,11 +22,11 @@ import lombok.EqualsAndHashCode;
/**
* 森林节点类
*
- * @author Chill
+ * @author smallchill
*/
@Data
@EqualsAndHashCode(callSuper = false)
-public class ForestNode extends BaseNode {
+public class ForestNode extends BaseNode {
private static final long serialVersionUID = 1L;
diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/node/ForestNodeManager.java b/blade-core-tool/src/main/java/org/springblade/core/tool/node/ForestNodeManager.java
index 97319e8..3b13394 100644
--- a/blade-core-tool/src/main/java/org/springblade/core/tool/node/ForestNodeManager.java
+++ b/blade-core-tool/src/main/java/org/springblade/core/tool/node/ForestNodeManager.java
@@ -15,28 +15,33 @@
*/
package org.springblade.core.tool.node;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+import org.springblade.core.tool.utils.StringPool;
+
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
/**
* 森林管理类
*
- * @author Chill
+ * @author smallchill
*/
-public class ForestNodeManager {
+public class ForestNodeManager> {
/**
* 森林的所有节点
*/
- private List list;
+ private final ImmutableMap nodeMap;
/**
* 森林的父节点ID
*/
- private List parentIds = new ArrayList<>();
+ private final Map parentIdMap = Maps.newHashMap();
- public ForestNodeManager(List items) {
- list = items;
+ public ForestNodeManager(List nodes) {
+ nodeMap = Maps.uniqueIndex(nodes, INode::getId);
}
/**
@@ -45,11 +50,9 @@ public class ForestNodeManager {
* @param id 节点ID
* @return 对应的节点对象
*/
- public INode getTreeNodeAT(Long id) {
- for (INode forestNode : list) {
- if (forestNode.getId().longValue() == id) {
- return forestNode;
- }
+ public INode getTreeNodeAt(Long id) {
+ if (nodeMap.containsKey(id)) {
+ return nodeMap.get(id);
}
return null;
}
@@ -60,7 +63,7 @@ public class ForestNodeManager {
* @param parentId 父节点ID
*/
public void addParentId(Long parentId) {
- parentIds.add(parentId);
+ parentIdMap.put(parentId, StringPool.EMPTY);
}
/**
@@ -70,11 +73,11 @@ public class ForestNodeManager {
*/
public List getRoot() {
List roots = new ArrayList<>();
- for (T forestNode : list) {
- if (forestNode.getParentId() == 0 || parentIds.contains(forestNode.getId())) {
- roots.add(forestNode);
+ nodeMap.forEach((key, node) -> {
+ if (node.getParentId() == 0 || parentIdMap.containsKey(node.getId())) {
+ roots.add(node);
}
- }
+ });
return roots;
}
diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/node/ForestNodeMerger.java b/blade-core-tool/src/main/java/org/springblade/core/tool/node/ForestNodeMerger.java
index 2a7179b..e424ece 100644
--- a/blade-core-tool/src/main/java/org/springblade/core/tool/node/ForestNodeMerger.java
+++ b/blade-core-tool/src/main/java/org/springblade/core/tool/node/ForestNodeMerger.java
@@ -20,7 +20,7 @@ import java.util.List;
/**
* 森林节点归并类
*
- * @author Chill
+ * @author smallchill
*/
public class ForestNodeMerger {
@@ -29,14 +29,14 @@ public class ForestNodeMerger {
* 时间复杂度为O(n^2)
*
* @param items 节点域
- * @param T 泛型标记
+ * @param 泛型
* @return 多棵树的根节点集合
*/
- public static List merge(List items) {
+ public static > List merge(List items) {
ForestNodeManager forestNodeManager = new ForestNodeManager<>(items);
items.forEach(forestNode -> {
if (forestNode.getParentId() != 0) {
- INode node = forestNodeManager.getTreeNodeAT(forestNode.getParentId());
+ INode node = forestNodeManager.getTreeNodeAt(forestNode.getParentId());
if (node != null) {
node.getChildren().add(forestNode);
} else {
diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/node/INode.java b/blade-core-tool/src/main/java/org/springblade/core/tool/node/INode.java
index b9db178..7bae55b 100644
--- a/blade-core-tool/src/main/java/org/springblade/core/tool/node/INode.java
+++ b/blade-core-tool/src/main/java/org/springblade/core/tool/node/INode.java
@@ -21,21 +21,21 @@ import java.util.List;
/**
* Created by Blade.
*
- * @author Chill
+ * @author smallchill
*/
-public interface INode extends Serializable {
+public interface INode extends Serializable {
/**
* 主键
*
- * @return Integer
+ * @return Long
*/
Long getId();
/**
* 父主键
*
- * @return Integer
+ * @return Long
*/
Long getParentId();
@@ -44,7 +44,7 @@ public interface INode extends Serializable {
*
* @return List
*/
- List getChildren();
+ List getChildren();
/**
* 是否有子孙节点
diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/node/NodeTest.java b/blade-core-tool/src/main/java/org/springblade/core/tool/node/NodeTest.java
index d8c5532..8c98b5e 100644
--- a/blade-core-tool/src/main/java/org/springblade/core/tool/node/NodeTest.java
+++ b/blade-core-tool/src/main/java/org/springblade/core/tool/node/NodeTest.java
@@ -8,7 +8,7 @@ import java.util.List;
/**
* Created by Blade.
*
- * @author Chill
+ * @author smallchill
*/
public class NodeTest {
diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/node/TreeNode.java b/blade-core-tool/src/main/java/org/springblade/core/tool/node/TreeNode.java
index a26a937..3c82fa2 100644
--- a/blade-core-tool/src/main/java/org/springblade/core/tool/node/TreeNode.java
+++ b/blade-core-tool/src/main/java/org/springblade/core/tool/node/TreeNode.java
@@ -18,16 +18,17 @@ package org.springblade.core.tool.node;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
-import lombok.EqualsAndHashCode;
+import org.springblade.core.tool.utils.Func;
+
+import java.util.Objects;
/**
* 树型节点类
*
- * @author Chill
+ * @author smallchill
*/
@Data
-@EqualsAndHashCode(callSuper = false)
-public class TreeNode extends BaseNode {
+public class TreeNode extends BaseNode {
private static final long serialVersionUID = 1L;
@@ -39,4 +40,21 @@ public class TreeNode extends BaseNode {
@JsonSerialize(using = ToStringSerializer.class)
private Long value;
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ TreeNode other = (TreeNode) obj;
+ return Func.equals(this.getId(), other.getId());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, parentId);
+ }
+
}
diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/utils/DateUtil.java b/blade-core-tool/src/main/java/org/springblade/core/tool/utils/DateUtil.java
index 547d78b..a565096 100644
--- a/blade-core-tool/src/main/java/org/springblade/core/tool/utils/DateUtil.java
+++ b/blade-core-tool/src/main/java/org/springblade/core/tool/utils/DateUtil.java
@@ -406,6 +406,7 @@ public class DateUtil {
* @param dateStr 时间字符串
* @param pattern 表达式
* @param query 移动查询
+ * @param 泛型
* @return 时间
*/
public static T parse(String dateStr, String pattern, TemporalQuery query) {
diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/utils/Func.java b/blade-core-tool/src/main/java/org/springblade/core/tool/utils/Func.java
index 1533129..e4bd0be 100644
--- a/blade-core-tool/src/main/java/org/springblade/core/tool/utils/Func.java
+++ b/blade-core-tool/src/main/java/org/springblade/core/tool/utils/Func.java
@@ -398,6 +398,20 @@ public class Func {
return String.valueOf(str);
}
+ /**
+ * 强转string(包含空字符串),并去掉多余空格
+ *
+ * @param str 字符串
+ * @param defaultValue 默认值
+ * @return {String}
+ */
+ public static String toStrWithEmpty(Object str, String defaultValue) {
+ if (null == str || str.equals(StringPool.NULL) || str.equals(StringPool.EMPTY)) {
+ return defaultValue;
+ }
+ return String.valueOf(str);
+ }
+
/**
* 判断一个字符串是否是数字
*
diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/utils/ImageUtil.java b/blade-core-tool/src/main/java/org/springblade/core/tool/utils/ImageUtil.java
index 9eaff3b..29f7aa0 100644
--- a/blade-core-tool/src/main/java/org/springblade/core/tool/utils/ImageUtil.java
+++ b/blade-core-tool/src/main/java/org/springblade/core/tool/utils/ImageUtil.java
@@ -364,7 +364,7 @@ public final class ImageUtil {
*
* @param src 源图像地址
* @param output 目标图像地址
- * @param type 类型
+ * @param type 类型
*/
public final static void gray(BufferedImage src, OutputStream output, String type) {
try {
@@ -385,7 +385,7 @@ public final class ImageUtil {
*
* @param src 源图像
* @param output 输出流
- * @param type 类型
+ * @param type 类型
* @param text 水印文字
* @param font 水印的字体
* @param color 水印的字体颜色
@@ -424,7 +424,7 @@ public final class ImageUtil {
*
* @param src 源图像
* @param output 输出流
- * @param type 类型
+ * @param type 类型
* @param stamp 水印图片
* @param position 水印位置 {@link ImagePosition}
* @param x 修正值
@@ -477,9 +477,10 @@ public final class ImageUtil {
/**
* 默认字符串
- * @param str 字符串
+ *
+ * @param str 字符串
* @param defaultStr 默认值
- * @return
+ * @return 字符串
*/
public static String defaultString(String str, String defaultStr) {
return ((str == null) ? defaultStr : str);
diff --git a/blade-core-transaction/pom.xml b/blade-core-transaction/pom.xml
index 155e5ef..fce5c6b 100644
--- a/blade-core-transaction/pom.xml
+++ b/blade-core-transaction/pom.xml
@@ -5,7 +5,7 @@
blade-tool
org.springblade
- 3.6.0
+ 3.7.0
4.0.0
diff --git a/pom.xml b/pom.xml
index 889aeaa..b6f4237 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
org.springblade
blade-tool
- 3.6.0
+ 3.7.0
pom
blade-tool
@@ -36,14 +36,14 @@
- 3.6.0
+ 3.7.0
1.8
3.8.1
4.1.0
- 3.5.3.1
- 3.5.3.1
+ 3.5.3.2
+ 3.5.3.2
1.6.0
3.4.2
31.1-jre
@@ -52,10 +52,10 @@
2021.0.5.0
2.1.2
- 5.3.27
- 2.7.10
+ 5.3.29
+ 2.7.15
2.7.10
- 2021.0.6
+ 2021.0.8
UTF-8
UTF-8