From 457ab4088f564373c309670c6fd8c2803c5b8b45 Mon Sep 17 00:00:00 2001 From: smallchill Date: Thu, 21 Nov 2019 12:59:37 +0800 Subject: [PATCH 01/27] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E7=A7=9F?= =?UTF-8?q?=E6=88=B7bean=E5=8A=A0=E8=BD=BD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/springblade/core/boot/tenant/TenantConfiguration.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blade-core-boot/src/main/java/org/springblade/core/boot/tenant/TenantConfiguration.java b/blade-core-boot/src/main/java/org/springblade/core/boot/tenant/TenantConfiguration.java index 7e5cd82..06a8feb 100644 --- a/blade-core-boot/src/main/java/org/springblade/core/boot/tenant/TenantConfiguration.java +++ b/blade-core-boot/src/main/java/org/springblade/core/boot/tenant/TenantConfiguration.java @@ -15,12 +15,12 @@ */ package org.springblade.core.boot.tenant; -import com.baomidou.mybatisplus.core.MybatisConfiguration; import com.baomidou.mybatisplus.core.parser.ISqlParser; import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; import com.baomidou.mybatisplus.extension.plugins.tenant.TenantHandler; import com.baomidou.mybatisplus.extension.plugins.tenant.TenantSqlParser; import lombok.AllArgsConstructor; +import org.springblade.core.boot.config.MybatisPlusConfiguration; import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -37,7 +37,7 @@ import java.util.List; */ @Configuration @AllArgsConstructor -@AutoConfigureBefore(MybatisConfiguration.class) +@AutoConfigureBefore(MybatisPlusConfiguration.class) @EnableConfigurationProperties(BladeTenantProperties.class) public class TenantConfiguration { From 181063c231bb96c47f3fb6f40dcb0af8ef1ef901 Mon Sep 17 00:00:00 2001 From: smallchill Date: Sun, 22 Dec 2019 23:43:17 +0800 Subject: [PATCH 02/27] =?UTF-8?q?:tada:=202.6.0.RELEASE=20=E5=8D=87?= =?UTF-8?q?=E7=BA=A7Hoxton.SR1=20=E9=80=82=E9=85=8D=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E6=9E=B6=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +- blade-core-boot/pom.xml | 24 +-- .../boot/config/MybatisPlusConfiguration.java | 15 +- .../core/boot/tenant/BladeTenantHandler.java | 2 +- .../src/main/resources/bootstrap.yml | 2 +- blade-core-cloud/pom.xml | 2 +- blade-core-develop/pom.xml | 2 +- .../resources/templates/controller.java.vm | 2 +- blade-core-launch/pom.xml | 2 +- .../core/launch/constant/AppConstant.java | 2 +- blade-core-log/pom.xml | 2 +- blade-core-mybatis/pom.xml | 2 +- .../springblade/core/mp/base/BaseService.java | 2 +- .../core/mp/base/BaseServiceImpl.java | 10 - .../core/mp/base/TenantEntity.java | 2 + .../core/mp/plugins/SqlLogInterceptor.java | 185 ++++++++++++++++++ .../core/mp/support/BaseEntityWrapper.java | 15 +- .../core/mp/support/Condition.java | 18 +- .../core/mp/support/SqlKeyword.java | 2 +- blade-core-oss/pom.xml | 2 +- blade-core-secure/pom.xml | 2 +- blade-core-swagger/pom.xml | 22 +-- .../swagger/SwaggerAutoConfiguration.java | 7 +- .../core/swagger/SwaggerProperties.java | 2 +- blade-core-test/pom.xml | 2 +- blade-core-tool/pom.xml | 2 +- .../tool/config/JacksonConfiguration.java | 7 +- .../tool/config/MessageConfiguration.java | 23 --- .../core/tool/config/ToolConfiguration.java | 3 - .../core/tool/config/XssConfiguration.java | 58 ++++++ .../core/tool/jackson/JsonUtil.java | 15 +- .../core/tool/support/xss/XssFilter.java | 9 +- .../xss/XssHttpServletRequestWrapper.java | 75 +++---- .../core/tool/support/xss/XssProperties.java | 12 +- .../tool/support/xss/XssUrlProperties.java | 35 ++++ .../org/springblade/core/tool/utils/Func.java | 6 +- .../core/tool/utils/StringUtil.java | 4 +- blade-core-transaction/pom.xml | 2 +- pom.xml | 18 +- 39 files changed, 419 insertions(+), 182 deletions(-) create mode 100644 blade-core-mybatis/src/main/java/org/springblade/core/mp/plugins/SqlLogInterceptor.java create mode 100644 blade-core-tool/src/main/java/org/springblade/core/tool/config/XssConfiguration.java create mode 100644 blade-core-tool/src/main/java/org/springblade/core/tool/support/xss/XssUrlProperties.java diff --git a/README.md b/README.md index cdc7779..d5c8289 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

Build Status - Coverage Status - Downloads + Coverage Status + Downloads

## SpringBlade微服务开发平台 diff --git a/blade-core-boot/pom.xml b/blade-core-boot/pom.xml index c15a6cf..7278c75 100644 --- a/blade-core-boot/pom.xml +++ b/blade-core-boot/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.5.4 + 2.6.0 4.0.0 @@ -62,28 +62,6 @@ blade-core-swagger ${blade.tool.version} - - - io.springfox - springfox-swagger2 - ${swagger.version} - - - io.swagger - swagger-models - - - - - io.swagger - swagger-models - ${swagger.models.version} - - - com.github.xiaoymin - swagger-bootstrap-ui - ${swagger.bootstrapui.version} - org.springframework.boot diff --git a/blade-core-boot/src/main/java/org/springblade/core/boot/config/MybatisPlusConfiguration.java b/blade-core-boot/src/main/java/org/springblade/core/boot/config/MybatisPlusConfiguration.java index c1f70c5..cae413c 100644 --- a/blade-core-boot/src/main/java/org/springblade/core/boot/config/MybatisPlusConfiguration.java +++ b/blade-core-boot/src/main/java/org/springblade/core/boot/config/MybatisPlusConfiguration.java @@ -16,13 +16,12 @@ package org.springblade.core.boot.config; import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; -import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor; import org.mybatis.spring.annotation.MapperScan; -import org.springblade.core.launch.constant.AppConstant; +import org.springblade.core.mp.plugins.SqlLogInterceptor; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; /** * mybatisplus 配置 @@ -40,14 +39,12 @@ public class MybatisPlusConfiguration { } /** - * SQL执行效率插件 - * - * @return PerformanceInterceptor + * sql 日志 */ @Bean - @Profile({AppConstant.DEV_CODE, AppConstant.TEST_CODE}) - public PerformanceInterceptor performanceInterceptor() { - return new PerformanceInterceptor(); + @ConditionalOnProperty(value = "blade.mybatis-plus.sql-log.enable", matchIfMissing = true) + public SqlLogInterceptor sqlLogInterceptor() { + return new SqlLogInterceptor(); } } diff --git a/blade-core-boot/src/main/java/org/springblade/core/boot/tenant/BladeTenantHandler.java b/blade-core-boot/src/main/java/org/springblade/core/boot/tenant/BladeTenantHandler.java index dea58f0..13e22e6 100644 --- a/blade-core-boot/src/main/java/org/springblade/core/boot/tenant/BladeTenantHandler.java +++ b/blade-core-boot/src/main/java/org/springblade/core/boot/tenant/BladeTenantHandler.java @@ -41,7 +41,7 @@ public class BladeTenantHandler implements TenantHandler { * @return 租户ID */ @Override - public Expression getTenantId() { + public Expression getTenantId(boolean where) { return new StringValue(Func.toStr(SecureUtil.getTenantId(), TenantConstant.DEFAULT_TENANT_ID)); } diff --git a/blade-core-boot/src/main/resources/bootstrap.yml b/blade-core-boot/src/main/resources/bootstrap.yml index 071731a..ee1c4d6 100644 --- a/blade-core-boot/src/main/resources/bootstrap.yml +++ b/blade-core-boot/src/main/resources/bootstrap.yml @@ -100,7 +100,7 @@ mybatis-plus: swagger: title: SpringBlade 接口文档系统 description: SpringBlade 接口文档系统 - version: 2.5.4 + version: 2.6.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 fc31522..ac4a50f 100644 --- a/blade-core-cloud/pom.xml +++ b/blade-core-cloud/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.5.4 + 2.6.0 4.0.0 diff --git a/blade-core-develop/pom.xml b/blade-core-develop/pom.xml index b35e73a..2eea7ce 100644 --- a/blade-core-develop/pom.xml +++ b/blade-core-develop/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.5.4 + 2.6.0 4.0.0 diff --git a/blade-core-develop/src/main/resources/templates/controller.java.vm b/blade-core-develop/src/main/resources/templates/controller.java.vm index e145040..3f0d5e9 100644 --- a/blade-core-develop/src/main/resources/templates/controller.java.vm +++ b/blade-core-develop/src/main/resources/templates/controller.java.vm @@ -16,9 +16,9 @@ package $!{package.Controller}; import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperationSupport; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import lombok.AllArgsConstructor; import javax.validation.Valid; diff --git a/blade-core-launch/pom.xml b/blade-core-launch/pom.xml index c4c81e9..0d9fb8f 100644 --- a/blade-core-launch/pom.xml +++ b/blade-core-launch/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.5.4 + 2.6.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 c7e124e..6ed79f4 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 = "2.5.4"; + String APPLICATION_VERSION = "2.6.0"; /** * 基础包 diff --git a/blade-core-log/pom.xml b/blade-core-log/pom.xml index 439c964..4297c89 100644 --- a/blade-core-log/pom.xml +++ b/blade-core-log/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.5.4 + 2.6.0 4.0.0 diff --git a/blade-core-mybatis/pom.xml b/blade-core-mybatis/pom.xml index a72b0c9..8a92fc9 100644 --- a/blade-core-mybatis/pom.xml +++ b/blade-core-mybatis/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.5.4 + 2.6.0 4.0.0 diff --git a/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseService.java b/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseService.java index d179c76..cf9dcfb 100644 --- a/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseService.java +++ b/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseService.java @@ -32,7 +32,7 @@ public interface BaseService extends IService { * 逻辑删除 * * @param ids id集合(逗号分隔) - * @return + * @return boolean */ boolean deleteLogic(@NotEmpty List ids); diff --git a/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseServiceImpl.java b/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseServiceImpl.java index 0b18187..b7b592a 100644 --- a/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseServiceImpl.java +++ b/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseServiceImpl.java @@ -24,8 +24,6 @@ import org.springblade.core.tool.utils.DateUtil; import org.springframework.validation.annotation.Validated; import javax.validation.constraints.NotEmpty; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; import java.util.Date; import java.util.List; @@ -39,14 +37,6 @@ import java.util.List; @Validated public class BaseServiceImpl, T extends BaseEntity> extends ServiceImpl implements BaseService { - private Class modelClass; - - @SuppressWarnings("unchecked") - public BaseServiceImpl() { - Type type = this.getClass().getGenericSuperclass(); - this.modelClass = (Class) ((ParameterizedType) type).getActualTypeArguments()[1]; - } - @Override public boolean save(T entity) { BladeUser user = SecureUtil.getUser(); diff --git a/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/TenantEntity.java b/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/TenantEntity.java index 04f5946..a53bf61 100644 --- a/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/TenantEntity.java +++ b/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/TenantEntity.java @@ -18,6 +18,7 @@ package org.springblade.core.mp.base; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.EqualsAndHashCode; /** * 租户基础实体类 @@ -25,6 +26,7 @@ import lombok.Data; * @author Chill */ @Data +@EqualsAndHashCode(callSuper = true) public class TenantEntity extends BaseEntity { /** diff --git a/blade-core-mybatis/src/main/java/org/springblade/core/mp/plugins/SqlLogInterceptor.java b/blade-core-mybatis/src/main/java/org/springblade/core/mp/plugins/SqlLogInterceptor.java new file mode 100644 index 0000000..9fe9f85 --- /dev/null +++ b/blade-core-mybatis/src/main/java/org/springblade/core/mp/plugins/SqlLogInterceptor.java @@ -0,0 +1,185 @@ +package org.springblade.core.mp.plugins; + +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import com.baomidou.mybatisplus.core.toolkit.PluginUtils; +import com.baomidou.mybatisplus.core.toolkit.StringPool; +import com.baomidou.mybatisplus.core.toolkit.SystemClock; +import lombok.extern.slf4j.Slf4j; +import org.apache.ibatis.executor.statement.StatementHandler; +import org.apache.ibatis.mapping.MappedStatement; +import org.apache.ibatis.plugin.*; +import org.apache.ibatis.reflection.MetaObject; +import org.apache.ibatis.reflection.SystemMetaObject; +import org.apache.ibatis.session.ResultHandler; +import org.springblade.core.tool.utils.StringUtil; + +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.sql.Statement; +import java.util.*; + +/** + * 用于输出每条 SQL 语句及其执行时间 + * + * @author hubin nieqiurong TaoYu + * @since 2016-07-07 + */ +@Slf4j +@Intercepts({ + @Signature(type = StatementHandler.class, method = "query", args = {Statement.class, ResultHandler.class}), + @Signature(type = StatementHandler.class, method = "update", args = Statement.class), + @Signature(type = StatementHandler.class, method = "batch", args = Statement.class) +}) +public class SqlLogInterceptor implements Interceptor { + private static final String DRUID_POOLED_PREPARED_STATEMENT = "com.alibaba.druid.pool.DruidPooledPreparedStatement"; + private static final String T4C_PREPARED_STATEMENT = "oracle.jdbc.driver.T4CPreparedStatement"; + private static final String ORACLE_PREPARED_STATEMENT_WRAPPER = "oracle.jdbc.driver.OraclePreparedStatementWrapper"; + + private Method oracleGetOriginalSqlMethod; + private Method druidGetSqlMethod; + + @Override + public Object intercept(Invocation invocation) throws Throwable { + Statement statement; + Object firstArg = invocation.getArgs()[0]; + if (Proxy.isProxyClass(firstArg.getClass())) { + statement = (Statement) SystemMetaObject.forObject(firstArg).getValue("h.statement"); + } else { + statement = (Statement) firstArg; + } + MetaObject stmtMetaObj = SystemMetaObject.forObject(statement); + try { + statement = (Statement) stmtMetaObj.getValue("stmt.statement"); + } catch (Exception e) { + // do nothing + } + if (stmtMetaObj.hasGetter("delegate")) { + //Hikari + try { + statement = (Statement) stmtMetaObj.getValue("delegate"); + } catch (Exception ignored) { + + } + } + + String originalSql = null; + String stmtClassName = statement.getClass().getName(); + if (DRUID_POOLED_PREPARED_STATEMENT.equals(stmtClassName)) { + try { + if (druidGetSqlMethod == null) { + Class clazz = Class.forName(DRUID_POOLED_PREPARED_STATEMENT); + druidGetSqlMethod = clazz.getMethod("getSql"); + } + Object stmtSql = druidGetSqlMethod.invoke(statement); + if (stmtSql instanceof String) { + originalSql = (String) stmtSql; + } + } catch (Exception e) { + e.printStackTrace(); + } + } else if (T4C_PREPARED_STATEMENT.equals(stmtClassName) + || ORACLE_PREPARED_STATEMENT_WRAPPER.equals(stmtClassName)) { + try { + if (oracleGetOriginalSqlMethod != null) { + Object stmtSql = oracleGetOriginalSqlMethod.invoke(statement); + if (stmtSql instanceof String) { + originalSql = (String) stmtSql; + } + } else { + Class clazz = Class.forName(stmtClassName); + oracleGetOriginalSqlMethod = getMethodRegular(clazz, "getOriginalSql"); + if (oracleGetOriginalSqlMethod != null) { + //OraclePreparedStatementWrapper is not a public class, need set this. + oracleGetOriginalSqlMethod.setAccessible(true); + if (null != oracleGetOriginalSqlMethod) { + Object stmtSql = oracleGetOriginalSqlMethod.invoke(statement); + if (stmtSql instanceof String) { + originalSql = (String) stmtSql; + } + } + } + } + } catch (Exception e) { + //ignore + } + } + if (originalSql == null) { + originalSql = statement.toString(); + } + originalSql = originalSql.replaceAll("[\\s]+", StringPool.SPACE); + int index = indexOfSqlStart(originalSql); + if (index > 0) { + originalSql = originalSql.substring(index); + } + + // 计算执行 SQL 耗时 + long start = SystemClock.now(); + Object result = invocation.proceed(); + long timing = SystemClock.now() - start; + + // SQL 打印执行结果 + Object target = PluginUtils.realTarget(invocation.getTarget()); + MetaObject metaObject = SystemMetaObject.forObject(target); + MappedStatement ms = (MappedStatement) metaObject.getValue("delegate.mappedStatement"); + // 打印 sql + System.err.println( + StringUtil.format( + "\n============== Sql Start ==============" + + "\nExecute ID :{}" + + "\nExecute SQL :{}" + + "\nExecute Time:{} ms" + + "\n============== Sql End ==============\n", + ms.getId(), originalSql, timing)); + return result; + } + + @Override + public Object plugin(Object target) { + if (target instanceof StatementHandler) { + return Plugin.wrap(target, this); + } + return target; + } + + /** + * 获取此方法名的具体 Method + * + * @param clazz class 对象 + * @param methodName 方法名 + * @return 方法 + */ + private Method getMethodRegular(Class clazz, String methodName) { + if (Object.class.equals(clazz)) { + return null; + } + for (Method method : clazz.getDeclaredMethods()) { + if (method.getName().equals(methodName)) { + return method; + } + } + return getMethodRegular(clazz.getSuperclass(), methodName); + } + + /** + * 获取sql语句开头部分 + * + * @param sql ignore + * @return ignore + */ + private int indexOfSqlStart(String sql) { + String upperCaseSql = sql.toUpperCase(); + Set set = new HashSet<>(); + set.add(upperCaseSql.indexOf("SELECT ")); + set.add(upperCaseSql.indexOf("UPDATE ")); + set.add(upperCaseSql.indexOf("INSERT ")); + set.add(upperCaseSql.indexOf("DELETE ")); + set.remove(-1); + if (CollectionUtils.isEmpty(set)) { + return -1; + } + List list = new ArrayList<>(set); + list.sort(Comparator.naturalOrder()); + return list.get(0); + } + +} diff --git a/blade-core-mybatis/src/main/java/org/springblade/core/mp/support/BaseEntityWrapper.java b/blade-core-mybatis/src/main/java/org/springblade/core/mp/support/BaseEntityWrapper.java index c6ad5bf..1a62cb4 100644 --- a/blade-core-mybatis/src/main/java/org/springblade/core/mp/support/BaseEntityWrapper.java +++ b/blade-core-mybatis/src/main/java/org/springblade/core/mp/support/BaseEntityWrapper.java @@ -30,15 +30,17 @@ public abstract class BaseEntityWrapper { /** * 单个实体类包装 - * @param entity - * @return + * + * @param entity 实体类 + * @return V */ public abstract V entityVO(E entity); /** * 实体类集合包装 - * @param list - * @return + * + * @param list 猎豹 + * @return List V */ public List listVO(List list) { return list.stream().map(this::entityVO).collect(Collectors.toList()); @@ -46,8 +48,9 @@ public abstract class BaseEntityWrapper { /** * 分页实体类集合包装 - * @param pages - * @return + * + * @param pages 分页 + * @return Page V */ public IPage pageVO(IPage pages) { List records = listVO(pages.getRecords()); diff --git a/blade-core-mybatis/src/main/java/org/springblade/core/mp/support/Condition.java b/blade-core-mybatis/src/main/java/org/springblade/core/mp/support/Condition.java index ce27a3f..d684311 100644 --- a/blade-core-mybatis/src/main/java/org/springblade/core/mp/support/Condition.java +++ b/blade-core-mybatis/src/main/java/org/springblade/core/mp/support/Condition.java @@ -33,8 +33,8 @@ public class Condition { /** * 转化成mybatis plus中的Page * - * @param query - * @return + * @param query 查询包装类 + * @return Page T */ public static IPage getPage(Query query) { Page page = new Page<>(Func.toInt(query.getCurrent(), 1), Func.toInt(query.getSize(), 10)); @@ -46,9 +46,9 @@ public class Condition { /** * 获取mybatis plus中的QueryWrapper * - * @param entity - * @param - * @return + * @param entity 实体类 + * @param 泛型 + * @return QueryWrapper */ public static QueryWrapper getQueryWrapper(T entity) { return new QueryWrapper<>(entity); @@ -57,10 +57,10 @@ public class Condition { /** * 获取mybatis plus中的QueryWrapper * - * @param query - * @param clazz - * @param - * @return + * @param query 查询包装类 + * @param clazz 实体类 + * @param 泛型 + * @return QueryWrapper */ public static QueryWrapper getQueryWrapper(Map query, Class clazz) { query.remove("current"); 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 bd4b269..2096dca 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 @@ -88,7 +88,7 @@ public class SqlKeyword { * * @param column 字段名 * @param keyword 关键字 - * @return + * @return String */ private static String getColumn(String column, String keyword) { return StringUtil.humpToUnderline(StringUtil.removeSuffix(column, keyword)); diff --git a/blade-core-oss/pom.xml b/blade-core-oss/pom.xml index 2aa1868..bbbc13b 100644 --- a/blade-core-oss/pom.xml +++ b/blade-core-oss/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.5.4 + 2.6.0 4.0.0 diff --git a/blade-core-secure/pom.xml b/blade-core-secure/pom.xml index 7299c12..7c3d376 100644 --- a/blade-core-secure/pom.xml +++ b/blade-core-secure/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.5.4 + 2.6.0 4.0.0 diff --git a/blade-core-swagger/pom.xml b/blade-core-swagger/pom.xml index 13bf861..0f88f69 100644 --- a/blade-core-swagger/pom.xml +++ b/blade-core-swagger/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.5.4 + 2.6.0 4.0.0 @@ -23,26 +23,10 @@ ${blade.tool.version} - - io.springfox - springfox-swagger2 - ${swagger.version} - - - io.swagger - swagger-models - - - - - io.swagger - swagger-models - ${swagger.models.version} - com.github.xiaoymin - swagger-bootstrap-ui - ${swagger.bootstrapui.version} + knife4j-micro-spring-boot-starter + ${knife4j.version} diff --git a/blade-core-swagger/src/main/java/org/springblade/core/swagger/SwaggerAutoConfiguration.java b/blade-core-swagger/src/main/java/org/springblade/core/swagger/SwaggerAutoConfiguration.java index e283e06..56fc7ce 100644 --- a/blade-core-swagger/src/main/java/org/springblade/core/swagger/SwaggerAutoConfiguration.java +++ b/blade-core-swagger/src/main/java/org/springblade/core/swagger/SwaggerAutoConfiguration.java @@ -16,14 +16,16 @@ package org.springblade.core.swagger; -import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI; +import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Profile; +import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration; import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.PathSelectors; import springfox.documentation.service.*; @@ -42,10 +44,11 @@ import java.util.List; * @author Chill */ @Configuration +@EnableKnife4j @EnableSwagger2 -@EnableSwaggerBootstrapUI @Profile({"dev", "test"}) @EnableConfigurationProperties(SwaggerProperties.class) +@Import(BeanValidatorPluginsConfiguration.class) public class SwaggerAutoConfiguration { private static final String DEFAULT_EXCLUDE_PATH = "/error"; 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 09822f1..3299cbd 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 = "2.5.4"; + private String version = "2.6.0"; /** * 许可证 **/ diff --git a/blade-core-test/pom.xml b/blade-core-test/pom.xml index 2b9c195..976f54c 100644 --- a/blade-core-test/pom.xml +++ b/blade-core-test/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.5.4 + 2.6.0 4.0.0 diff --git a/blade-core-tool/pom.xml b/blade-core-tool/pom.xml index 2f8bb48..0016aee 100644 --- a/blade-core-tool/pom.xml +++ b/blade-core-tool/pom.xml @@ -6,7 +6,7 @@ org.springblade blade-tool - 2.5.4 + 2.6.0 4.0.0 diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/config/JacksonConfiguration.java b/blade-core-tool/src/main/java/org/springblade/core/tool/config/JacksonConfiguration.java index ae14f38..f1216eb 100644 --- a/blade-core-tool/src/main/java/org/springblade/core/tool/config/JacksonConfiguration.java +++ b/blade-core-tool/src/main/java/org/springblade/core/tool/config/JacksonConfiguration.java @@ -16,9 +16,11 @@ package org.springblade.core.tool.config; import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.json.JsonReadFeature; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; +import lombok.AllArgsConstructor; import org.springblade.core.tool.jackson.BladeJavaTimeModule; import org.springblade.core.tool.utils.DateUtil; import org.springframework.boot.autoconfigure.AutoConfigureBefore; @@ -40,6 +42,7 @@ import java.util.TimeZone; * @author Chill */ @Configuration +@AllArgsConstructor @ConditionalOnClass(ObjectMapper.class) @AutoConfigureBefore(JacksonAutoConfiguration.class) public class JacksonConfiguration { @@ -59,8 +62,8 @@ public class JacksonConfiguration { //序列化时,日期的统一格式 objectMapper.setDateFormat(new SimpleDateFormat(DateUtil.PATTERN_DATETIME, Locale.CHINA)); //序列化处理 - objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true); - objectMapper.configure(JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER, true); + objectMapper.configure(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS.mappedFeature(), true); + objectMapper.configure(JsonReadFeature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER.mappedFeature(), true); objectMapper.findAndRegisterModules(); //失败处理 objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/config/MessageConfiguration.java b/blade-core-tool/src/main/java/org/springblade/core/tool/config/MessageConfiguration.java index acb4fdb..c3f3344 100644 --- a/blade-core-tool/src/main/java/org/springblade/core/tool/config/MessageConfiguration.java +++ b/blade-core-tool/src/main/java/org/springblade/core/tool/config/MessageConfiguration.java @@ -19,11 +19,7 @@ package org.springblade.core.tool.config; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.AllArgsConstructor; import org.springblade.core.tool.jackson.MappingApiJackson2HttpMessageConverter; -import org.springblade.core.tool.support.xss.XssFilter; -import org.springblade.core.tool.support.xss.XssProperties; import org.springblade.core.tool.utils.Charsets; -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; @@ -31,7 +27,6 @@ import org.springframework.http.converter.*; import org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import javax.servlet.DispatcherType; import java.util.List; /** @@ -46,8 +41,6 @@ public class MessageConfiguration implements WebMvcConfigurer { private final ObjectMapper objectMapper; - private final XssProperties xssProperties; - /** * 使用 JACKSON 作为JSON MessageConverter */ @@ -61,20 +54,4 @@ public class MessageConfiguration implements WebMvcConfigurer { converters.add(new MappingApiJackson2HttpMessageConverter(objectMapper)); } - /** - * 防XSS注入 - * - * @return FilterRegistrationBean - */ - @Bean - public FilterRegistrationBean xssFilterRegistration() { - FilterRegistrationBean registration = new FilterRegistrationBean(); - registration.setDispatcherTypes(DispatcherType.REQUEST); - registration.setFilter(new XssFilter(xssProperties)); - registration.addUrlPatterns("/*"); - registration.setName("xssFilter"); - registration.setOrder(Ordered.LOWEST_PRECEDENCE); - return registration; - } - } diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/config/ToolConfiguration.java b/blade-core-tool/src/main/java/org/springblade/core/tool/config/ToolConfiguration.java index 7994b4f..0f5b62b 100644 --- a/blade-core-tool/src/main/java/org/springblade/core/tool/config/ToolConfiguration.java +++ b/blade-core-tool/src/main/java/org/springblade/core/tool/config/ToolConfiguration.java @@ -16,9 +16,7 @@ package org.springblade.core.tool.config; -import org.springblade.core.tool.support.xss.XssProperties; import org.springblade.core.tool.utils.SpringUtil; -import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.Ordered; @@ -32,7 +30,6 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; */ @Configuration @Order(Ordered.HIGHEST_PRECEDENCE) -@EnableConfigurationProperties(XssProperties.class) public class ToolConfiguration implements WebMvcConfigurer { /** diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/config/XssConfiguration.java b/blade-core-tool/src/main/java/org/springblade/core/tool/config/XssConfiguration.java new file mode 100644 index 0000000..d14adac --- /dev/null +++ b/blade-core-tool/src/main/java/org/springblade/core/tool/config/XssConfiguration.java @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.core.tool.config; + +import lombok.AllArgsConstructor; +import org.springblade.core.tool.support.xss.XssFilter; +import org.springblade.core.tool.support.xss.XssProperties; +import org.springblade.core.tool.support.xss.XssUrlProperties; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.Ordered; + +import javax.servlet.DispatcherType; + +/** + * Xss配置类 + * + * @author Chill + */ +@Configuration +@AllArgsConstructor +@ConditionalOnProperty(value = "blade.xss.enable", havingValue = "true") +@EnableConfigurationProperties({XssProperties.class, XssUrlProperties.class}) +public class XssConfiguration { + + private final XssProperties xssProperties; + private final XssUrlProperties xssUrlProperties; + + /** + * 防XSS注入 + */ + @Bean + public FilterRegistrationBean xssFilterRegistration() { + FilterRegistrationBean registration = new FilterRegistrationBean<>(); + registration.setDispatcherTypes(DispatcherType.REQUEST); + registration.setFilter(new XssFilter(xssProperties, xssUrlProperties)); + registration.addUrlPatterns("/*"); + registration.setName("xssFilter"); + registration.setOrder(Ordered.LOWEST_PRECEDENCE); + return registration; + } +} diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/jackson/JsonUtil.java b/blade-core-tool/src/main/java/org/springblade/core/tool/jackson/JsonUtil.java index 72c036e..8bdac8d 100644 --- a/blade-core-tool/src/main/java/org/springblade/core/tool/jackson/JsonUtil.java +++ b/blade-core-tool/src/main/java/org/springblade/core/tool/jackson/JsonUtil.java @@ -17,6 +17,7 @@ package org.springblade.core.tool.jackson; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.json.JsonReadFeature; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonNode; @@ -97,7 +98,7 @@ public class JsonUtil { * @param T 泛型标记 * @return Bean */ - public static T parse(String content, TypeReference typeReference) { + public static T parse(String content, TypeReference typeReference) { try { return getInstance().readValue(content, typeReference); } catch (IOException e) { @@ -130,7 +131,7 @@ public class JsonUtil { * @param T 泛型标记 * @return Bean */ - public static T parse(byte[] bytes, TypeReference typeReference) { + public static T parse(byte[] bytes, TypeReference typeReference) { try { return getInstance().readValue(bytes, typeReference); } catch (IOException e) { @@ -162,7 +163,7 @@ public class JsonUtil { * @param T 泛型标记 * @return Bean */ - public static T parse(InputStream in, TypeReference typeReference) { + public static T parse(InputStream in, TypeReference typeReference) { try { return getInstance().readValue(in, typeReference); } catch (IOException e) { @@ -184,7 +185,7 @@ public class JsonUtil { content = StringPool.LEFT_SQ_BRACKET + content + StringPool.RIGHT_SQ_BRACKET; } - List> list = getInstance().readValue(content, new TypeReference>() { + List> list = getInstance().readValue(content, new TypeReference>>() { }); List result = new ArrayList<>(); for (Map map : list) { @@ -208,7 +209,7 @@ public class JsonUtil { public static Map toMap(String content, Class valueTypeRef) { try { - Map> map = getInstance().readValue(content, new TypeReference>() { + Map> map = getInstance().readValue(content, new TypeReference>>() { }); Map result = new HashMap<>(16); for (Map.Entry> entry : map.entrySet()) { @@ -305,8 +306,8 @@ public class JsonUtil { //序列化时,日期的统一格式 super.setDateFormat(new SimpleDateFormat(DateUtil.PATTERN_DATETIME, Locale.CHINA)); //序列化处理 - super.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true); - super.configure(JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER, true); + super.configure(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS.mappedFeature(), true); + super.configure(JsonReadFeature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER.mappedFeature(), true); super.findAndRegisterModules(); //失败处理 super.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/support/xss/XssFilter.java b/blade-core-tool/src/main/java/org/springblade/core/tool/support/xss/XssFilter.java index e94fa3e..cab3e79 100644 --- a/blade-core-tool/src/main/java/org/springblade/core/tool/support/xss/XssFilter.java +++ b/blade-core-tool/src/main/java/org/springblade/core/tool/support/xss/XssFilter.java @@ -16,6 +16,7 @@ package org.springblade.core.tool.support.xss; import lombok.AllArgsConstructor; +import org.springblade.core.tool.utils.StringPool; import javax.servlet.*; import javax.servlet.http.HttpServletRequest; @@ -30,6 +31,7 @@ import java.io.IOException; public class XssFilter implements Filter { private XssProperties xssProperties; + private XssUrlProperties xssUrlProperties; @Override public void init(FilterConfig config) { @@ -39,7 +41,7 @@ public class XssFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { String path = ((HttpServletRequest) request).getServletPath(); - if (xssProperties.getExcludePatterns().stream().anyMatch(path::contains)) { + if (isSkip(path)) { chain.doFilter(request, response); } else { XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper((HttpServletRequest) request); @@ -47,6 +49,11 @@ public class XssFilter implements Filter { } } + private boolean isSkip(String path) { + return (xssUrlProperties.getExcludePatterns().stream().anyMatch(path::startsWith)) + || (xssProperties.getSkipUrl().stream().map(url -> url.replace("/**", StringPool.EMPTY)).anyMatch(path::startsWith)); + } + @Override public void destroy() { diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/support/xss/XssHttpServletRequestWrapper.java b/blade-core-tool/src/main/java/org/springblade/core/tool/support/xss/XssHttpServletRequestWrapper.java index 6c0fdd1..cfc8620 100644 --- a/blade-core-tool/src/main/java/org/springblade/core/tool/support/xss/XssHttpServletRequestWrapper.java +++ b/blade-core-tool/src/main/java/org/springblade/core/tool/support/xss/XssHttpServletRequestWrapper.java @@ -15,9 +15,7 @@ */ package org.springblade.core.tool.support.xss; -import org.springblade.core.tool.utils.Charsets; import org.springblade.core.tool.utils.StringUtil; -import org.springblade.core.tool.utils.WebUtil; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; @@ -29,6 +27,7 @@ import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.util.LinkedHashMap; import java.util.Map; @@ -49,15 +48,9 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { */ private final static HtmlFilter HTML_FILTER = new HtmlFilter(); - /** - * 缓存报文,支持多次读取流 - */ - private final byte[] body; - - public XssHttpServletRequestWrapper(HttpServletRequest request) throws IOException { + public XssHttpServletRequestWrapper(HttpServletRequest request) { super(request); orgRequest = request; - body = WebUtil.getRequestBytes(request); } @Override @@ -67,51 +60,67 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { @Override public ServletInputStream getInputStream() throws IOException { - - //为空,直接返回 if (null == super.getHeader(HttpHeaders.CONTENT_TYPE)) { return super.getInputStream(); } - //非json类型,直接返回 - if (!super.getHeader(HttpHeaders.CONTENT_TYPE).equalsIgnoreCase(MediaType.APPLICATION_JSON_VALUE) - && !super.getHeader(HttpHeaders.CONTENT_TYPE).equalsIgnoreCase(MediaType.APPLICATION_JSON_UTF8_VALUE)) { + if (super.getHeader(HttpHeaders.CONTENT_TYPE).startsWith(MediaType.MULTIPART_FORM_DATA_VALUE)) { return super.getInputStream(); } - //为空,直接返回 - String requestStr = WebUtil.getRequestStr(orgRequest, body); - if (StringUtil.isBlank(requestStr)) { - return super.getInputStream(); - } - - requestStr = xssEncode(requestStr); - - final ByteArrayInputStream bis = new ByteArrayInputStream(requestStr.getBytes(Charsets.UTF_8)); + final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(inputHandlers(super.getInputStream()).getBytes()); return new ServletInputStream() { + @Override + public int read() { + return byteArrayInputStream.read(); + } + @Override public boolean isFinished() { - return true; + return false; } @Override public boolean isReady() { - return true; + return false; } @Override public void setReadListener(ReadListener readListener) { - - } - - @Override - public int read() throws IOException { - return bis.read(); } }; + } + private String inputHandlers(ServletInputStream servletInputStream) { + StringBuilder sb = new StringBuilder(); + BufferedReader reader = null; + try { + reader = new BufferedReader(new InputStreamReader(servletInputStream, StandardCharsets.UTF_8)); + String line; + while ((line = reader.readLine()) != null) { + sb.append(line); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (servletInputStream != null) { + try { + servletInputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (reader != null) { + try { + reader.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return xssEncode(sb.toString()); } @Override @@ -129,7 +138,6 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { if (parameters == null || parameters.length == 0) { return null; } - for (int i = 0; i < parameters.length; i++) { parameters[i] = xssEncode(parameters[i]); } @@ -165,6 +173,7 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { /** * 获取最原始的request + * * @return HttpServletRequest */ public HttpServletRequest getOrgRequest() { @@ -173,6 +182,7 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { /** * 获取最原始的request + * * @param request request * @return HttpServletRequest */ @@ -180,7 +190,6 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { if (request instanceof XssHttpServletRequestWrapper) { return ((XssHttpServletRequestWrapper) request).getOrgRequest(); } - return request; } diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/support/xss/XssProperties.java b/blade-core-tool/src/main/java/org/springblade/core/tool/support/xss/XssProperties.java index 3535e8e..2b4e3d5 100644 --- a/blade-core-tool/src/main/java/org/springblade/core/tool/support/xss/XssProperties.java +++ b/blade-core-tool/src/main/java/org/springblade/core/tool/support/xss/XssProperties.java @@ -27,9 +27,17 @@ import java.util.List; * @author Chill */ @Data -@ConfigurationProperties("blade.xss.url") +@ConfigurationProperties("blade.xss") public class XssProperties { - private final List excludePatterns = new ArrayList<>(); + /** + * 开启xss + */ + private Boolean enable = true; + + /** + * 放行url + */ + private List skipUrl = new ArrayList<>(); } diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/support/xss/XssUrlProperties.java b/blade-core-tool/src/main/java/org/springblade/core/tool/support/xss/XssUrlProperties.java new file mode 100644 index 0000000..89f45f9 --- /dev/null +++ b/blade-core-tool/src/main/java/org/springblade/core/tool/support/xss/XssUrlProperties.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.core.tool.support.xss; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +import java.util.ArrayList; +import java.util.List; + +/** + * Xss配置类 + * + * @author Chill + */ +@Data +@ConfigurationProperties("blade.xss.url") +public class XssUrlProperties { + + private final List excludePatterns = new ArrayList<>(); + +} 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 bf310f1..1533129 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 @@ -1124,7 +1124,7 @@ public class Func { * @param T 泛型标记 * @return Bean */ - public static T parse(byte[] bytes, TypeReference typeReference) { + public static T parse(byte[] bytes, TypeReference typeReference) { return JsonUtil.parse(bytes, typeReference); } @@ -1136,7 +1136,7 @@ public class Func { * @param T 泛型标记 * @return Bean */ - public static T parse(String jsonString, TypeReference typeReference) { + public static T parse(String jsonString, TypeReference typeReference) { return JsonUtil.parse(jsonString, typeReference); } @@ -1148,7 +1148,7 @@ public class Func { * @param T 泛型标记 * @return Bean */ - public static T parse(InputStream in, TypeReference typeReference) { + public static T parse(InputStream in, TypeReference typeReference) { return JsonUtil.parse(in, typeReference); } diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/utils/StringUtil.java b/blade-core-tool/src/main/java/org/springblade/core/tool/utils/StringUtil.java index 7d0c02d..2cdaf7b 100644 --- a/blade-core-tool/src/main/java/org/springblade/core/tool/utils/StringUtil.java +++ b/blade-core-tool/src/main/java/org/springblade/core/tool/utils/StringUtil.java @@ -186,7 +186,7 @@ public class StringUtil extends org.springframework.util.StringUtils { * @return {String} */ public static String escapeHtml(String html) { - return HtmlUtils.htmlEscape(html); + return StringUtil.isBlank(html) ? StringPool.EMPTY : HtmlUtils.htmlEscape(html); } /** @@ -1250,7 +1250,7 @@ public class StringUtil extends org.springframework.util.StringUtils { /** * 创建StringBuilder对象 * - * @param sb 初始StringBuilder + * @param sb 初始StringBuilder * @param strs 初始字符串列表 * @return StringBuilder对象 */ diff --git a/blade-core-transaction/pom.xml b/blade-core-transaction/pom.xml index a3da188..e7fc256 100644 --- a/blade-core-transaction/pom.xml +++ b/blade-core-transaction/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.5.4 + 2.6.0 4.0.0 diff --git a/pom.xml b/pom.xml index 5256045..5560df8 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.5.4 + 2.6.0 pom blade-tool @@ -36,24 +36,24 @@ - 2.5.4 + 2.6.0 1.8 3.8.0 2.9.2 1.5.21 - 1.9.6 - 3.1.2 + 2.0.1 + 3.2.0 4.0.1 1.6.0 3.4.2 - 2.1.5 + 2.2.0 1.1.0 - 2.1.0.RELEASE - 0.9.0 + 2.1.1.RELEASE + 1.0.0 - 2.1.9.RELEASE - Greenwich.SR3 + 2.2.2.RELEASE + Hoxton.SR1 Cairo-SR8 UTF-8 From 1da4fb72d1ad29d465e9077d402d4d3f74553200 Mon Sep 17 00:00:00 2001 From: smallchill Date: Mon, 20 Jan 2020 12:48:43 +0800 Subject: [PATCH 03/27] =?UTF-8?q?:tada:=20getQueryWrapper=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=87=AA=E5=AE=9A=E4=B9=89=E6=8E=92=E9=99=A4=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/mp/support/Condition.java | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/blade-core-mybatis/src/main/java/org/springblade/core/mp/support/Condition.java b/blade-core-mybatis/src/main/java/org/springblade/core/mp/support/Condition.java index d684311..198a199 100644 --- a/blade-core-mybatis/src/main/java/org/springblade/core/mp/support/Condition.java +++ b/blade-core-mybatis/src/main/java/org/springblade/core/mp/support/Condition.java @@ -18,6 +18,8 @@ package org.springblade.core.mp.support; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springblade.core.launch.constant.TokenConstant; +import org.springblade.core.tool.support.Kv; import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.Func; @@ -33,8 +35,8 @@ public class Condition { /** * 转化成mybatis plus中的Page * - * @param query 查询包装类 - * @return Page T + * @param query 查询条件 + * @return IPage */ public static IPage getPage(Query query) { Page page = new Page<>(Func.toInt(query.getCurrent(), 1), Func.toInt(query.getSize(), 10)); @@ -46,8 +48,8 @@ public class Condition { /** * 获取mybatis plus中的QueryWrapper * - * @param entity 实体类 - * @param 泛型 + * @param entity 实体 + * @param 类型 * @return QueryWrapper */ public static QueryWrapper getQueryWrapper(T entity) { @@ -57,16 +59,28 @@ public class Condition { /** * 获取mybatis plus中的QueryWrapper * - * @param query 查询包装类 + * @param query 查询条件 * @param clazz 实体类 - * @param 泛型 + * @param 类型 * @return QueryWrapper */ public static QueryWrapper getQueryWrapper(Map query, Class clazz) { - query.remove("current"); - query.remove("size"); - query.remove("ascs"); - query.remove("descs"); + Kv exclude = Kv.init().set(TokenConstant.HEADER, TokenConstant.HEADER) + .set("current", "current").set("size", "size").set("ascs", "ascs").set("descs", "descs"); + return getQueryWrapper(query, exclude, clazz); + } + + /** + * 获取mybatis plus中的QueryWrapper + * + * @param query 查询条件 + * @param exclude 排除的查询条件 + * @param clazz 实体类 + * @param 类型 + * @return QueryWrapper + */ + public static QueryWrapper getQueryWrapper(Map query, Map exclude, Class clazz) { + exclude.forEach((k, v) -> query.remove(k)); QueryWrapper qw = new QueryWrapper<>(); qw.setEntity(BeanUtil.newInstance(clazz)); SqlKeyword.buildCondition(query, qw); From 8dc730d8cfb14f6ef523043b6e843aa3b92a18d9 Mon Sep 17 00:00:00 2001 From: smallchill Date: Tue, 11 Feb 2020 15:58:29 +0800 Subject: [PATCH 04/27] =?UTF-8?q?:tada:=202.6.1.RELEASE,=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=99=BB=E9=99=86=E9=AA=8C=E8=AF=81=E7=A0=81,=E6=94=AF?= =?UTF-8?q?=E6=8C=81Seata1.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- blade-core-boot/pom.xml | 5 - .../config/BladeBootAutoConfiguration.java | 3 + .../boot/config/MybatisPlusConfiguration.java | 2 + .../core/boot/file/BladeFileUtil.java | 5 +- .../core/boot/file/IFileProxy.java | 4 +- blade-core-tool/pom.xml | 5 + .../config/RedisTemplateConfiguration.java | 12 +- .../core/tool}/redis/RedisKeySerializer.java | 2 +- .../core/tool/utils/RedisUtil.java | 595 ++++++++++++++++++ blade-core-transaction/pom.xml | 7 - .../config/DataSourceConfiguration.java | 11 +- .../src/main/resources/file.conf | 3 + .../src/main/resources/registry.conf | 20 - pom.xml | 13 +- 15 files changed, 640 insertions(+), 49 deletions(-) rename {blade-core-boot/src/main/java/org/springblade/core/boot => blade-core-tool/src/main/java/org/springblade/core/tool}/config/RedisTemplateConfiguration.java (88%) rename {blade-core-boot/src/main/java/org/springblade/core/boot => blade-core-tool/src/main/java/org/springblade/core/tool}/redis/RedisKeySerializer.java (98%) create mode 100644 blade-core-tool/src/main/java/org/springblade/core/tool/utils/RedisUtil.java create mode 100644 blade-core-transaction/src/main/resources/file.conf delete mode 100644 blade-core-transaction/src/main/resources/registry.conf diff --git a/README.md b/README.md index d5c8289..97be2ac 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

Build Status Coverage Status - Downloads + Downloads

## SpringBlade微服务开发平台 diff --git a/blade-core-boot/pom.xml b/blade-core-boot/pom.xml index 7278c75..a00e343 100644 --- a/blade-core-boot/pom.xml +++ b/blade-core-boot/pom.xml @@ -62,11 +62,6 @@ blade-core-swagger ${blade.tool.version} - - - org.springframework.boot - spring-boot-starter-data-redis - org.springblade diff --git a/blade-core-boot/src/main/java/org/springblade/core/boot/config/BladeBootAutoConfiguration.java b/blade-core-boot/src/main/java/org/springblade/core/boot/config/BladeBootAutoConfiguration.java index 1cf86b3..7cd56b3 100644 --- a/blade-core-boot/src/main/java/org/springblade/core/boot/config/BladeBootAutoConfiguration.java +++ b/blade-core-boot/src/main/java/org/springblade/core/boot/config/BladeBootAutoConfiguration.java @@ -26,6 +26,7 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy; /** * 配置类 + * * @author Chill */ @Slf4j @@ -41,6 +42,8 @@ public class BladeBootAutoConfiguration { /** * 全局变量定义 + * + * @return SystemConstant */ @Bean public SystemConstant fileConst() { diff --git a/blade-core-boot/src/main/java/org/springblade/core/boot/config/MybatisPlusConfiguration.java b/blade-core-boot/src/main/java/org/springblade/core/boot/config/MybatisPlusConfiguration.java index cae413c..784d414 100644 --- a/blade-core-boot/src/main/java/org/springblade/core/boot/config/MybatisPlusConfiguration.java +++ b/blade-core-boot/src/main/java/org/springblade/core/boot/config/MybatisPlusConfiguration.java @@ -40,6 +40,8 @@ public class MybatisPlusConfiguration { /** * sql 日志 + * + * @return SqlLogInterceptor */ @Bean @ConditionalOnProperty(value = "blade.mybatis-plus.sql-log.enable", matchIfMissing = true) diff --git a/blade-core-boot/src/main/java/org/springblade/core/boot/file/BladeFileUtil.java b/blade-core-boot/src/main/java/org/springblade/core/boot/file/BladeFileUtil.java index fc7a922..20fa539 100644 --- a/blade-core-boot/src/main/java/org/springblade/core/boot/file/BladeFileUtil.java +++ b/blade-core-boot/src/main/java/org/springblade/core/boot/file/BladeFileUtil.java @@ -99,8 +99,8 @@ public class BladeFileUtil { /** * 文本排序转换成枚举 * - * @param sort - * @return + * @param sort 排序 + * @return FileSort */ public static FileSort of(String sort) { try { @@ -228,6 +228,7 @@ public class BladeFileUtil { * 获取BladeFile封装类 * * @param files 文件集合 + * @param dir 路径 * @param path 路径 * @param virtualPath 虚拟路径 * @return BladeFile diff --git a/blade-core-boot/src/main/java/org/springblade/core/boot/file/IFileProxy.java b/blade-core-boot/src/main/java/org/springblade/core/boot/file/IFileProxy.java index 6da15fd..769546a 100644 --- a/blade-core-boot/src/main/java/org/springblade/core/boot/file/IFileProxy.java +++ b/blade-core-boot/src/main/java/org/springblade/core/boot/file/IFileProxy.java @@ -29,7 +29,7 @@ public interface IFileProxy { * * @param file 文件 * @param dir 目录 - * @return + * @return String */ String[] path(File file, String dir); @@ -38,7 +38,7 @@ public interface IFileProxy { * * @param file 文件 * @param path 路径 - * @return + * @return File */ File rename(File file, String path); diff --git a/blade-core-tool/pom.xml b/blade-core-tool/pom.xml index 0016aee..43743a9 100644 --- a/blade-core-tool/pom.xml +++ b/blade-core-tool/pom.xml @@ -67,6 +67,11 @@ protostuff-runtime ${protostuff.version} + + + org.springframework.boot + spring-boot-starter-data-redis + diff --git a/blade-core-boot/src/main/java/org/springblade/core/boot/config/RedisTemplateConfiguration.java b/blade-core-tool/src/main/java/org/springblade/core/tool/config/RedisTemplateConfiguration.java similarity index 88% rename from blade-core-boot/src/main/java/org/springblade/core/boot/config/RedisTemplateConfiguration.java rename to blade-core-tool/src/main/java/org/springblade/core/tool/config/RedisTemplateConfiguration.java index 48fb910..0647573 100644 --- a/blade-core-boot/src/main/java/org/springblade/core/boot/config/RedisTemplateConfiguration.java +++ b/blade-core-tool/src/main/java/org/springblade/core/tool/config/RedisTemplateConfiguration.java @@ -13,10 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springblade.core.boot.config; +package org.springblade.core.tool.config; -import org.springblade.core.boot.redis.RedisKeySerializer; +import org.springblade.core.tool.redis.RedisKeySerializer; +import org.springblade.core.tool.utils.RedisUtil; import org.springframework.boot.autoconfigure.AutoConfigureBefore; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; import org.springframework.cache.CacheManager; @@ -78,4 +80,10 @@ public class RedisTemplateConfiguration { .cacheDefaults(redisCacheConfiguration).build(); } + @Bean(name = "redisUtil") + @ConditionalOnBean(RedisTemplate.class) + public RedisUtil redisUtils(RedisTemplate redisTemplate) { + return new RedisUtil(redisTemplate); + } + } diff --git a/blade-core-boot/src/main/java/org/springblade/core/boot/redis/RedisKeySerializer.java b/blade-core-tool/src/main/java/org/springblade/core/tool/redis/RedisKeySerializer.java similarity index 98% rename from blade-core-boot/src/main/java/org/springblade/core/boot/redis/RedisKeySerializer.java rename to blade-core-tool/src/main/java/org/springblade/core/tool/redis/RedisKeySerializer.java index cee1747..a45b027 100644 --- a/blade-core-boot/src/main/java/org/springblade/core/boot/redis/RedisKeySerializer.java +++ b/blade-core-tool/src/main/java/org/springblade/core/tool/redis/RedisKeySerializer.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springblade.core.boot.redis; +package org.springblade.core.tool.redis; import org.springframework.cache.interceptor.SimpleKey; import org.springframework.core.convert.ConversionService; diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/utils/RedisUtil.java b/blade-core-tool/src/main/java/org/springblade/core/tool/utils/RedisUtil.java new file mode 100644 index 0000000..8f67226 --- /dev/null +++ b/blade-core-tool/src/main/java/org/springblade/core/tool/utils/RedisUtil.java @@ -0,0 +1,595 @@ +package org.springblade.core.tool.utils; + +import lombok.AllArgsConstructor; +import org.springframework.data.redis.core.RedisTemplate; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +/** + * Redis工具类 + * + * @author Chill + */ +@AllArgsConstructor +public class RedisUtil { + + private RedisTemplate redisTemplate; + + //=============================common============================ + + /** + * 指定缓存失效时间 + * + * @param key 键 + * @param time 时间(秒) + * @return boolean + */ + public boolean expire(String key, long time) { + try { + if (time > 0) { + redisTemplate.expire(key, time, TimeUnit.SECONDS); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 根据key 获取过期时间 + * + * @param key 键 不能为null + * @return 时间(秒) 返回0代表为永久有效 + */ + public long getExpire(String key) { + return redisTemplate.getExpire(key, TimeUnit.SECONDS); + } + + /** + * 判断key是否存在 + * + * @param key 键 + * @return true 存在 false不存在 + */ + public boolean hasKey(String key) { + try { + return redisTemplate.hasKey(key); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 删除缓存 + * + * @param key 可以传一个值 或多个 + */ + @SuppressWarnings("unchecked") + public void del(String... key) { + if (key != null && key.length > 0) { + if (key.length == 1) { + redisTemplate.delete(key[0]); + } else { + redisTemplate.delete(CollectionUtil.arrayToList(key)); + } + } + } + + //============================String============================= + + /** + * 普通缓存获取 + * + * @param key 键 + * @return 值 + */ + public Object get(String key) { + return key == null ? null : redisTemplate.opsForValue().get(key); + } + + /** + * 普通缓存放入 + * + * @param key 键 + * @param value 值 + * @return true成功 false失败 + */ + public boolean set(String key, Object value) { + try { + redisTemplate.opsForValue().set(key, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + + } + + /** + * 普通缓存放入并设置时间 + * + * @param key 键 + * @param value 值 + * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期 + * @return true成功 false 失败 + */ + public boolean set(String key, Object value, long time) { + try { + if (time > 0) { + redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS); + } else { + set(key, value); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 普通缓存放入并设置时间 + * + * @param key 键 + * @param value 值 + * @param time 时间 + * @param timeUnit 时间单位 + * @return true成功 false 失败 + */ + public boolean set(String key, Object value, long time, TimeUnit timeUnit) { + try { + if (time > 0) { + redisTemplate.opsForValue().set(key, value, time, timeUnit); + } else { + set(key, value); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 递增 + * + * @param key 键 + * @param delta 要增加几(大于0) + * @return long + */ + public long incr(String key, long delta) { + if (delta < 0) { + throw new RuntimeException("递增因子必须大于0"); + } + return redisTemplate.opsForValue().increment(key, delta); + } + + /** + * 递减 + * + * @param key 键 + * @param delta 要减少几(小于0) + * @return long + */ + public long decr(String key, long delta) { + if (delta < 0) { + throw new RuntimeException("递减因子必须大于0"); + } + return redisTemplate.opsForValue().increment(key, -delta); + } + + //================================Map================================= + + /** + * HashGet + * + * @param key 键 不能为null + * @param item 项 不能为null + * @return 值 + */ + public Object hget(String key, String item) { + return redisTemplate.opsForHash().get(key, item); + } + + /** + * 获取hashKey对应的所有键值 + * + * @param key 键 + * @return 对应的多个键值 + */ + public Map hmget(String key) { + return redisTemplate.opsForHash().entries(key); + } + + /** + * HashSet + * + * @param key 键 + * @param map 对应多个键值 + * @return true 成功 false 失败 + */ + public boolean hmset(String key, Map map) { + try { + redisTemplate.opsForHash().putAll(key, map); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * HashSet 并设置时间 + * + * @param key 键 + * @param map 对应多个键值 + * @param time 时间(秒) + * @return true成功 false失败 + */ + public boolean hmset(String key, Map map, long time) { + try { + redisTemplate.opsForHash().putAll(key, map); + if (time > 0) { + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 向一张hash表中放入数据,如果不存在将创建 + * + * @param key 键 + * @param item 项 + * @param value 值 + * @return true 成功 false失败 + */ + public boolean hset(String key, String item, Object value) { + try { + redisTemplate.opsForHash().put(key, item, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 向一张hash表中放入数据,如果不存在将创建 + * + * @param key 键 + * @param item 项 + * @param value 值 + * @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间 + * @return true 成功 false失败 + */ + public boolean hset(String key, String item, Object value, long time) { + try { + redisTemplate.opsForHash().put(key, item, value); + if (time > 0) { + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 删除hash表中的值 + * + * @param key 键 不能为null + * @param item 项 可以使多个 不能为null + */ + public void hdel(String key, Object... item) { + redisTemplate.opsForHash().delete(key, item); + } + + /** + * 判断hash表中是否有该项的值 + * + * @param key 键 不能为null + * @param item 项 不能为null + * @return true 存在 false不存在 + */ + public boolean hHasKey(String key, String item) { + return redisTemplate.opsForHash().hasKey(key, item); + } + + /** + * hash递增 如果不存在,就会创建一个 并把新增后的值返回 + * + * @param key 键 + * @param item 项 + * @param by 要增加几(大于0) + * @return double + */ + public double hincr(String key, String item, double by) { + return redisTemplate.opsForHash().increment(key, item, by); + } + + /** + * hash递减 + * + * @param key 键 + * @param item 项 + * @param by 要减少记(小于0) + * @return double + */ + public double hdecr(String key, String item, double by) { + return redisTemplate.opsForHash().increment(key, item, -by); + } + + //============================set============================= + + /** + * 根据key获取Set中的所有值 + * + * @param key 键 + * @return Set + */ + public Set sGet(String key) { + try { + return redisTemplate.opsForSet().members(key); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 根据value从一个set中查询,是否存在 + * + * @param key 键 + * @param value 值 + * @return true 存在 false不存在 + */ + public boolean sHasKey(String key, Object value) { + try { + return redisTemplate.opsForSet().isMember(key, value); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将数据放入set缓存 + * + * @param key 键 + * @param values 值 可以是多个 + * @return 成功个数 + */ + public long sSet(String key, Object... values) { + try { + return redisTemplate.opsForSet().add(key, values); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 将set数据放入缓存 + * + * @param key 键 + * @param time 时间(秒) + * @param values 值 可以是多个 + * @return 成功个数 + */ + public long sSetAndTime(String key, long time, Object... values) { + try { + Long count = redisTemplate.opsForSet().add(key, values); + if (time > 0) { + expire(key, time); + } + return count; + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 获取set缓存的长度 + * + * @param key 键 + * @return long + */ + public long sGetSetSize(String key) { + try { + return redisTemplate.opsForSet().size(key); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 移除值为value的 + * + * @param key 键 + * @param values 值 可以是多个 + * @return 移除的个数 + */ + public long setRemove(String key, Object... values) { + try { + Long count = redisTemplate.opsForSet().remove(key, values); + return count; + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + //===============================list================================= + + /** + * 获取list缓存的内容 + * + * @param key 键 + * @param start 开始 + * @param end 结束 0 到 -1代表所有值 + * @return List + */ + public List lGet(String key, long start, long end) { + try { + return redisTemplate.opsForList().range(key, start, end); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 获取list缓存的长度 + * + * @param key 键 + * @return long + */ + public long lGetListSize(String key) { + try { + return redisTemplate.opsForList().size(key); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 通过索引 获取list中的值 + * + * @param key 键 + * @param index 索引 + * @return Object + */ + public Object lGetIndex(String key, long index) { + try { + return redisTemplate.opsForList().index(key, index); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 将list放入缓存 + * + * @param key 键 + * @param value 值 + * @return boolean + */ + public boolean lSet(String key, Object value) { + try { + redisTemplate.opsForList().rightPush(key, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将list放入缓存 + * + * @param key 键 + * @param value 值 + * @param time 时间(秒) + * @return boolean + */ + public boolean lSet(String key, Object value, long time) { + try { + redisTemplate.opsForList().rightPush(key, value); + if (time > 0) { + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将list放入缓存 + * + * @param key 键 + * @param value 值 + * @return boolean + */ + public boolean lSet(String key, List value) { + try { + redisTemplate.opsForList().rightPushAll(key, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将list放入缓存 + * + * @param key 键 + * @param value 值 + * @param time 时间(秒) + * @return boolean + */ + public boolean lSet(String key, List value, long time) { + try { + redisTemplate.opsForList().rightPushAll(key, value); + if (time > 0) { + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 根据索引修改list中的某条数据 + * + * @param key 键 + * @param index 索引 + * @param value 值 + * @return boolean + */ + public boolean lUpdateIndex(String key, long index, Object value) { + try { + redisTemplate.opsForList().set(key, index, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 移除N个值为value + * + * @param key 键 + * @param count 移除多少个 + * @param value 值 + * @return 移除的个数 + */ + public long lRemove(String key, long count, Object value) { + try { + Long remove = redisTemplate.opsForList().remove(key, count, value); + return remove; + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + +} diff --git a/blade-core-transaction/pom.xml b/blade-core-transaction/pom.xml index e7fc256..cf62624 100644 --- a/blade-core-transaction/pom.xml +++ b/blade-core-transaction/pom.xml @@ -31,13 +31,6 @@ spring-cloud-alibaba-seata ${alibaba.cloud.version} - - io.seata - seata-all - ${alibaba.seata.version} - - - diff --git a/blade-core-transaction/src/main/java/org/springblade/core/transaction/config/DataSourceConfiguration.java b/blade-core-transaction/src/main/java/org/springblade/core/transaction/config/DataSourceConfiguration.java index 194c03c..a979a3c 100644 --- a/blade-core-transaction/src/main/java/org/springblade/core/transaction/config/DataSourceConfiguration.java +++ b/blade-core-transaction/src/main/java/org/springblade/core/transaction/config/DataSourceConfiguration.java @@ -18,8 +18,10 @@ package org.springblade.core.transaction.config; import com.alibaba.druid.pool.DruidDataSource; import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean; import io.seata.rm.datasource.DataSourceProxy; +import io.seata.spring.boot.autoconfigure.util.SpringUtils; import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.spring.SqlSessionTemplate; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -43,8 +45,7 @@ public class DataSourceConfiguration { bean.setDataSource(dataSourceProxy); ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); bean.setMapperLocations(resolver.getResources("classpath:org/springblade/**/mapper/*Mapper.xml")); - - SqlSessionFactory factory = null; + SqlSessionFactory factory; try { factory = bean.getObject(); } catch (Exception e) { @@ -76,4 +77,10 @@ public class DataSourceConfiguration { return new DataSourceProxy(druidDataSource); } + @Bean + @ConditionalOnMissingBean(SpringUtils.class) + public SpringUtils springUtils() { + return new SpringUtils(); + } + } diff --git a/blade-core-transaction/src/main/resources/file.conf b/blade-core-transaction/src/main/resources/file.conf new file mode 100644 index 0000000..2e9d0b7 --- /dev/null +++ b/blade-core-transaction/src/main/resources/file.conf @@ -0,0 +1,3 @@ +service { + disableGlobalTransaction = false +} diff --git a/blade-core-transaction/src/main/resources/registry.conf b/blade-core-transaction/src/main/resources/registry.conf deleted file mode 100644 index da0dda8..0000000 --- a/blade-core-transaction/src/main/resources/registry.conf +++ /dev/null @@ -1,20 +0,0 @@ -registry { - # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa - type = "nacos" - - nacos { - serverAddr = "localhost" - namespace = "" - cluster = "default" - } -} - -config { - # file、nacos 、apollo、zk、consul、etcd3 - type = "nacos" - - nacos { - serverAddr = "localhost" - namespace = "" - } -} diff --git a/pom.xml b/pom.xml index 5560df8..6209e01 100644 --- a/pom.xml +++ b/pom.xml @@ -43,16 +43,15 @@ 2.9.2 1.5.21 2.0.1 - 3.2.0 - 4.0.1 + 3.3.1 1.6.0 3.4.2 - 2.2.0 + 2.2.2 1.1.0 - 2.1.1.RELEASE + 2.2.0.RELEASE 1.0.0 - 2.2.2.RELEASE + 2.2.4.RELEASE Hoxton.SR1 Cairo-SR8 @@ -183,7 +182,7 @@ aliyun-repos - http://maven.aliyun.com/nexus/content/groups/public/ + https://maven.aliyun.com/nexus/content/groups/public/ false @@ -193,7 +192,7 @@ aliyun-plugin - http://maven.aliyun.com/nexus/content/groups/public/ + https://maven.aliyun.com/nexus/content/groups/public/ false From 83bdf4d74284bc2261d17ceea658177c55857cc3 Mon Sep 17 00:00:00 2001 From: smallchill Date: Tue, 11 Feb 2020 15:59:22 +0800 Subject: [PATCH 05/27] =?UTF-8?q?:tada:=202.6.1.RELEASE,=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=99=BB=E9=99=86=E9=AA=8C=E8=AF=81=E7=A0=81,=E6=94=AF?= =?UTF-8?q?=E6=8C=81Seata1.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blade-core-boot/pom.xml | 2 +- blade-core-boot/src/main/resources/bootstrap.yml | 2 +- blade-core-cloud/pom.xml | 2 +- blade-core-develop/pom.xml | 2 +- blade-core-launch/pom.xml | 2 +- .../org/springblade/core/launch/constant/AppConstant.java | 2 +- blade-core-log/pom.xml | 2 +- blade-core-mybatis/pom.xml | 2 +- blade-core-oss/pom.xml | 2 +- blade-core-secure/pom.xml | 2 +- blade-core-swagger/pom.xml | 2 +- .../java/org/springblade/core/swagger/SwaggerProperties.java | 2 +- blade-core-test/pom.xml | 2 +- blade-core-tool/pom.xml | 2 +- blade-core-transaction/pom.xml | 2 +- pom.xml | 4 ++-- 16 files changed, 17 insertions(+), 17 deletions(-) diff --git a/blade-core-boot/pom.xml b/blade-core-boot/pom.xml index a00e343..07092ad 100644 --- a/blade-core-boot/pom.xml +++ b/blade-core-boot/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.6.0 + 2.6.1 4.0.0 diff --git a/blade-core-boot/src/main/resources/bootstrap.yml b/blade-core-boot/src/main/resources/bootstrap.yml index ee1c4d6..e47d27f 100644 --- a/blade-core-boot/src/main/resources/bootstrap.yml +++ b/blade-core-boot/src/main/resources/bootstrap.yml @@ -100,7 +100,7 @@ mybatis-plus: swagger: title: SpringBlade 接口文档系统 description: SpringBlade 接口文档系统 - version: 2.6.0 + version: 2.6.1 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 ac4a50f..1caf66a 100644 --- a/blade-core-cloud/pom.xml +++ b/blade-core-cloud/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.0 + 2.6.1 4.0.0 diff --git a/blade-core-develop/pom.xml b/blade-core-develop/pom.xml index 2eea7ce..4fcb08e 100644 --- a/blade-core-develop/pom.xml +++ b/blade-core-develop/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.0 + 2.6.1 4.0.0 diff --git a/blade-core-launch/pom.xml b/blade-core-launch/pom.xml index 0d9fb8f..4d87979 100644 --- a/blade-core-launch/pom.xml +++ b/blade-core-launch/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.0 + 2.6.1 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 6ed79f4..a9b63ae 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 = "2.6.0"; + String APPLICATION_VERSION = "2.6.1"; /** * 基础包 diff --git a/blade-core-log/pom.xml b/blade-core-log/pom.xml index 4297c89..a725c21 100644 --- a/blade-core-log/pom.xml +++ b/blade-core-log/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.0 + 2.6.1 4.0.0 diff --git a/blade-core-mybatis/pom.xml b/blade-core-mybatis/pom.xml index 8a92fc9..c25bf52 100644 --- a/blade-core-mybatis/pom.xml +++ b/blade-core-mybatis/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.0 + 2.6.1 4.0.0 diff --git a/blade-core-oss/pom.xml b/blade-core-oss/pom.xml index bbbc13b..445c866 100644 --- a/blade-core-oss/pom.xml +++ b/blade-core-oss/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.0 + 2.6.1 4.0.0 diff --git a/blade-core-secure/pom.xml b/blade-core-secure/pom.xml index 7c3d376..0e18457 100644 --- a/blade-core-secure/pom.xml +++ b/blade-core-secure/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.0 + 2.6.1 4.0.0 diff --git a/blade-core-swagger/pom.xml b/blade-core-swagger/pom.xml index 0f88f69..3e4e62e 100644 --- a/blade-core-swagger/pom.xml +++ b/blade-core-swagger/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.0 + 2.6.1 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 3299cbd..88b245d 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 = "2.6.0"; + private String version = "2.6.1"; /** * 许可证 **/ diff --git a/blade-core-test/pom.xml b/blade-core-test/pom.xml index 976f54c..738064e 100644 --- a/blade-core-test/pom.xml +++ b/blade-core-test/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.6.0 + 2.6.1 4.0.0 diff --git a/blade-core-tool/pom.xml b/blade-core-tool/pom.xml index 43743a9..f8e0491 100644 --- a/blade-core-tool/pom.xml +++ b/blade-core-tool/pom.xml @@ -6,7 +6,7 @@ org.springblade blade-tool - 2.6.0 + 2.6.1 4.0.0 diff --git a/blade-core-transaction/pom.xml b/blade-core-transaction/pom.xml index cf62624..e94897e 100644 --- a/blade-core-transaction/pom.xml +++ b/blade-core-transaction/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.0 + 2.6.1 4.0.0 diff --git a/pom.xml b/pom.xml index 6209e01..7b05a43 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.6.0 + 2.6.1 pom blade-tool @@ -36,7 +36,7 @@ - 2.6.0 + 2.6.1 1.8 3.8.0 From fc14d74a44eeee7cb7dea04950e98e1751dfdd62 Mon Sep 17 00:00:00 2001 From: smallchill Date: Fri, 28 Feb 2020 16:24:02 +0800 Subject: [PATCH 06/27] =?UTF-8?q?:tada:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/springblade/develop/support/BladeCodeGenerator.java | 1 + 1 file changed, 1 insertion(+) diff --git a/blade-core-develop/src/main/java/org/springblade/develop/support/BladeCodeGenerator.java b/blade-core-develop/src/main/java/org/springblade/develop/support/BladeCodeGenerator.java index 395fb63..ee861b0 100644 --- a/blade-core-develop/src/main/java/org/springblade/develop/support/BladeCodeGenerator.java +++ b/blade-core-develop/src/main/java/org/springblade/develop/support/BladeCodeGenerator.java @@ -210,6 +210,7 @@ public class BladeCodeGenerator { map.put("codeName", codeName); map.put("serviceName", serviceName); map.put("servicePackage", servicePackage); + map.put("servicePackageLowerCase", servicePackage.toLowerCase()); map.put("tenantColumn", tenantColumn); map.put("hasWrapper", hasWrapper); this.setMap(map); From a53a3d57e6df4288d0e537448db2f060a9191271 Mon Sep 17 00:00:00 2001 From: smallchill Date: Sun, 1 Mar 2020 17:50:05 +0800 Subject: [PATCH 07/27] =?UTF-8?q?:tada:=202.6.2.RELEASE=20=E5=8D=87?= =?UTF-8?q?=E7=BA=A7=E6=94=AF=E6=8C=81seata1.1=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E9=98=BF=E9=87=8C=E4=BA=91oss?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +- blade-core-boot/pom.xml | 2 +- .../src/main/resources/bootstrap.yml | 5 +- blade-core-cloud/pom.xml | 2 +- .../feign/BladeFeignAutoConfiguration.java | 2 +- blade-core-develop/pom.xml | 2 +- blade-core-launch/pom.xml | 2 +- .../core/launch/constant/AppConstant.java | 2 +- blade-core-log/pom.xml | 2 +- blade-core-mybatis/pom.xml | 2 +- blade-core-oss/pom.xml | 8 +- .../springblade/core/oss/AliossTemplate.java | 283 ++++++++++++++++++ .../core/oss/config/AliossConfiguration.java | 83 +++++ ...iguration.java => QiniuConfiguration.java} | 4 +- .../springblade/core/oss/model/BladeFile.java | 4 + .../core/oss/props/OssProperties.java | 6 + blade-core-secure/pom.xml | 2 +- blade-core-swagger/pom.xml | 2 +- .../core/swagger/SwaggerProperties.java | 2 +- blade-core-test/pom.xml | 2 +- blade-core-tool/pom.xml | 2 +- blade-core-transaction/pom.xml | 7 +- .../config/DataSourceConfiguration.java | 58 ---- pom.xml | 10 +- 24 files changed, 412 insertions(+), 86 deletions(-) create mode 100644 blade-core-oss/src/main/java/org/springblade/core/oss/AliossTemplate.java create mode 100644 blade-core-oss/src/main/java/org/springblade/core/oss/config/AliossConfiguration.java rename blade-core-oss/src/main/java/org/springblade/core/oss/config/{OssConfiguration.java => QiniuConfiguration.java} (96%) diff --git a/README.md b/README.md index 97be2ac..6bd464a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

Build Status - Coverage Status - Downloads + Coverage Status + Downloads

## SpringBlade微服务开发平台 diff --git a/blade-core-boot/pom.xml b/blade-core-boot/pom.xml index 07092ad..d64f807 100644 --- a/blade-core-boot/pom.xml +++ b/blade-core-boot/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.6.1 + 2.6.2 4.0.0 diff --git a/blade-core-boot/src/main/resources/bootstrap.yml b/blade-core-boot/src/main/resources/bootstrap.yml index e47d27f..395dcad 100644 --- a/blade-core-boot/src/main/resources/bootstrap.yml +++ b/blade-core-boot/src/main/resources/bootstrap.yml @@ -60,9 +60,6 @@ spring: #maximum-pool-size: 5 #max-lifetime: 1800000 #minimum-idle: 1 - devtools: - restart: - log-condition-evaluation-delta: false #配置日志地址 @@ -100,7 +97,7 @@ mybatis-plus: swagger: title: SpringBlade 接口文档系统 description: SpringBlade 接口文档系统 - version: 2.6.1 + version: 2.6.2 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 1caf66a..e2a94e1 100644 --- a/blade-core-cloud/pom.xml +++ b/blade-core-cloud/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.1 + 2.6.2 4.0.0 diff --git a/blade-core-cloud/src/main/java/org/springblade/core/cloud/feign/BladeFeignAutoConfiguration.java b/blade-core-cloud/src/main/java/org/springblade/core/cloud/feign/BladeFeignAutoConfiguration.java index 64e6710..9f0315d 100644 --- a/blade-core-cloud/src/main/java/org/springblade/core/cloud/feign/BladeFeignAutoConfiguration.java +++ b/blade-core-cloud/src/main/java/org/springblade/core/cloud/feign/BladeFeignAutoConfiguration.java @@ -55,7 +55,7 @@ import java.util.ArrayList; public class BladeFeignAutoConfiguration { @Bean - @ConditionalOnMissingBean + @ConditionalOnMissingBean(Targeter.class) public Targeter bladeFeignTargeter() { return new BladeHystrixTargeter(); } diff --git a/blade-core-develop/pom.xml b/blade-core-develop/pom.xml index 4fcb08e..83b559f 100644 --- a/blade-core-develop/pom.xml +++ b/blade-core-develop/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.1 + 2.6.2 4.0.0 diff --git a/blade-core-launch/pom.xml b/blade-core-launch/pom.xml index 4d87979..fda2a37 100644 --- a/blade-core-launch/pom.xml +++ b/blade-core-launch/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.1 + 2.6.2 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 a9b63ae..b88f433 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 = "2.6.1"; + String APPLICATION_VERSION = "2.6.2"; /** * 基础包 diff --git a/blade-core-log/pom.xml b/blade-core-log/pom.xml index a725c21..6d3e857 100644 --- a/blade-core-log/pom.xml +++ b/blade-core-log/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.1 + 2.6.2 4.0.0 diff --git a/blade-core-mybatis/pom.xml b/blade-core-mybatis/pom.xml index c25bf52..6be7a34 100644 --- a/blade-core-mybatis/pom.xml +++ b/blade-core-mybatis/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.1 + 2.6.2 4.0.0 diff --git a/blade-core-oss/pom.xml b/blade-core-oss/pom.xml index 445c866..d7690ed 100644 --- a/blade-core-oss/pom.xml +++ b/blade-core-oss/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.1 + 2.6.2 4.0.0 @@ -27,6 +27,12 @@ qiniu-java-sdk 7.2.18 + + + com.aliyun.oss + aliyun-sdk-oss + 3.1.0 + diff --git a/blade-core-oss/src/main/java/org/springblade/core/oss/AliossTemplate.java b/blade-core-oss/src/main/java/org/springblade/core/oss/AliossTemplate.java new file mode 100644 index 0000000..a063c16 --- /dev/null +++ b/blade-core-oss/src/main/java/org/springblade/core/oss/AliossTemplate.java @@ -0,0 +1,283 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.core.oss; + +import com.aliyun.oss.OSSClient; +import com.aliyun.oss.common.utils.BinaryUtil; +import com.aliyun.oss.model.MatchMode; +import com.aliyun.oss.model.ObjectMetadata; +import com.aliyun.oss.model.PolicyConditions; +import com.aliyun.oss.model.PutObjectResult; +import lombok.AllArgsConstructor; +import lombok.SneakyThrows; +import org.springblade.core.oss.model.BladeFile; +import org.springblade.core.oss.model.OssFile; +import org.springblade.core.oss.props.OssProperties; +import org.springblade.core.oss.rule.OssRule; +import org.springblade.core.tool.jackson.JsonUtil; +import org.springblade.core.tool.utils.StringPool; +import org.springframework.util.StringUtils; +import org.springframework.web.multipart.MultipartFile; + +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * AliossTemplate + * + * @author Chill + */ +@AllArgsConstructor +public class AliossTemplate { + private OSSClient ossClient; + private OssProperties ossProperties; + private OssRule ossRule; + + @SneakyThrows + public void makeBucket(String bucketName) { + if (!bucketExists(bucketName)) { + ossClient.createBucket(getBucketName(bucketName)); + } + } + + @SneakyThrows + public void removeBucket(String bucketName) { + ossClient.deleteBucket(getBucketName(bucketName)); + } + + @SneakyThrows + public boolean bucketExists(String bucketName) { + return ossClient.doesBucketExist(getBucketName(bucketName)); + } + + @SneakyThrows + public void copyFile(String bucketName, String fileName, String destBucketName) { + ossClient.copyObject(getBucketName(bucketName), fileName, getBucketName(destBucketName), fileName); + } + + @SneakyThrows + public void copyFile(String bucketName, String fileName, String destBucketName, String destFileName) { + ossClient.copyObject(getBucketName(bucketName), fileName, getBucketName(destBucketName), destFileName); + } + + @SneakyThrows + public OssFile statFile(String fileName) { + return statFile(ossProperties.getBucketName(), fileName); + } + + @SneakyThrows + public OssFile statFile(String bucketName, String fileName) { + ObjectMetadata stat = ossClient.getObjectMetadata(getBucketName(bucketName), fileName); + OssFile ossFile = new OssFile(); + ossFile.setName(fileName); + ossFile.setLink(fileLink(ossFile.getName())); + ossFile.setHash(stat.getContentMD5()); + ossFile.setLength(stat.getContentLength()); + ossFile.setPutTime(stat.getLastModified()); + ossFile.setContentType(stat.getContentType()); + return ossFile; + } + + @SneakyThrows + public String filePath(String fileName) { + return getOssHost().concat(StringPool.SLASH).concat(fileName); + } + + @SneakyThrows + public String filePath(String bucketName, String fileName) { + return getOssHost(bucketName).concat(StringPool.SLASH).concat(fileName); + } + + @SneakyThrows + public String fileLink(String fileName) { + return getOssHost().concat(StringPool.SLASH).concat(fileName); + } + + @SneakyThrows + public String fileLink(String bucketName, String fileName) { + return getOssHost(bucketName).concat(StringPool.SLASH).concat(fileName); + } + + /** + * 文件对象 + * + * @param file 上传文件类 + * @return + */ + + @SneakyThrows + public BladeFile putFile(MultipartFile file) { + return putFile(ossProperties.getBucketName(), file.getOriginalFilename(), file); + } + + /** + * @param fileName 上传文件名 + * @param file 上传文件类 + * @return + */ + + @SneakyThrows + public BladeFile putFile(String fileName, MultipartFile file) { + return putFile(ossProperties.getBucketName(), fileName, file); + } + + @SneakyThrows + public BladeFile putFile(String bucketName, String fileName, MultipartFile file) { + return putFile(bucketName, fileName, file.getInputStream()); + } + + @SneakyThrows + public BladeFile putFile(String fileName, InputStream stream) { + return putFile(ossProperties.getBucketName(), fileName, stream); + } + + @SneakyThrows + public BladeFile putFile(String bucketName, String fileName, InputStream stream) { + return put(bucketName, stream, fileName, false); + } + + @SneakyThrows + public BladeFile put(String bucketName, InputStream stream, String key, boolean cover) { + makeBucket(bucketName); + String originalName = key; + key = getFileName(key); + // 覆盖上传 + if (cover) { + ossClient.putObject(getBucketName(bucketName), key, stream); + } else { + PutObjectResult response = ossClient.putObject(getBucketName(bucketName), key, stream); + int retry = 0; + int retryCount = 5; + while (StringUtils.isEmpty(response.getETag()) && retry < retryCount) { + response = ossClient.putObject(getBucketName(bucketName), key, stream); + retry++; + } + } + BladeFile file = new BladeFile(); + file.setOriginalName(originalName); + file.setName(key); + file.setLink(fileLink(bucketName, key)); + return file; + } + + @SneakyThrows + public void removeFile(String fileName) { + ossClient.deleteObject(getBucketName(), fileName); + } + + @SneakyThrows + public void removeFile(String bucketName, String fileName) { + ossClient.deleteObject(getBucketName(bucketName), fileName); + } + + @SneakyThrows + public void removeFiles(List fileNames) { + fileNames.forEach(this::removeFile); + } + + @SneakyThrows + public void removeFiles(String bucketName, List fileNames) { + fileNames.forEach(fileName -> removeFile(getBucketName(bucketName), fileName)); + } + + /** + * 根据规则生成存储桶名称规则 + * + * @return String + */ + private String getBucketName() { + return getBucketName(ossProperties.getBucketName()); + } + + /** + * 根据规则生成存储桶名称规则 + * + * @param bucketName 存储桶名称 + * @return String + */ + private String getBucketName(String bucketName) { + return ossRule.bucketName(bucketName); + } + + /** + * 根据规则生成文件名称规则 + * + * @param originalFilename 原始文件名 + * @return string + */ + private String getFileName(String originalFilename) { + return ossRule.fileName(originalFilename); + } + + public String getUploadToken() { + return getUploadToken(ossProperties.getBucketName()); + } + + /** + * TODO 过期时间 + *

+ * 获取上传凭证,普通上传 + */ + public String getUploadToken(String bucketName) { + // 默认过期时间2小时 + return getUploadToken(bucketName, ossProperties.getArgs().get("expireTime", 3600L)); + } + + /** + * TODO 上传大小限制、基础路径 + *

+ * 获取上传凭证,普通上传 + */ + public String getUploadToken(String bucketName, long expireTime) { + String baseDir = "upload"; + + long expireEndTime = System.currentTimeMillis() + expireTime * 1000; + Date expiration = new Date(expireEndTime); + + PolicyConditions policyConds = new PolicyConditions(); + // 默认大小限制10M + policyConds.addConditionItem(PolicyConditions.COND_CONTENT_LENGTH_RANGE, 0, ossProperties.getArgs().get("contentLengthRange", 10485760)); + policyConds.addConditionItem(MatchMode.StartWith, PolicyConditions.COND_KEY, baseDir); + + String postPolicy = ossClient.generatePostPolicy(expiration, policyConds); + byte[] binaryData = postPolicy.getBytes(StandardCharsets.UTF_8); + String encodedPolicy = BinaryUtil.toBase64String(binaryData); + String postSignature = ossClient.calculatePostSignature(postPolicy); + + Map respMap = new LinkedHashMap<>(16); + respMap.put("accessid", ossProperties.getAccessKey()); + respMap.put("policy", encodedPolicy); + respMap.put("signature", postSignature); + respMap.put("dir", baseDir); + respMap.put("host", getOssHost(bucketName)); + respMap.put("expire", String.valueOf(expireEndTime / 1000)); + return JsonUtil.toJson(respMap); + } + + public String getOssHost(String bucketName) { + String prefix = ossProperties.getEndpoint().contains("https://") ? "https://" : "http://"; + return prefix + getBucketName(bucketName) + StringPool.DOT + ossProperties.getEndpoint().replaceFirst(prefix, StringPool.EMPTY); + } + + public String getOssHost() { + return getOssHost(ossProperties.getBucketName()); + } + +} diff --git a/blade-core-oss/src/main/java/org/springblade/core/oss/config/AliossConfiguration.java b/blade-core-oss/src/main/java/org/springblade/core/oss/config/AliossConfiguration.java new file mode 100644 index 0000000..29d3152 --- /dev/null +++ b/blade-core-oss/src/main/java/org/springblade/core/oss/config/AliossConfiguration.java @@ -0,0 +1,83 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.core.oss.config; + +import com.aliyun.oss.ClientConfiguration; +import com.aliyun.oss.OSSClient; +import com.aliyun.oss.common.auth.CredentialsProvider; +import com.aliyun.oss.common.auth.DefaultCredentialProvider; +import lombok.AllArgsConstructor; +import org.springblade.core.oss.AliossTemplate; +import org.springblade.core.oss.props.OssProperties; +import org.springblade.core.oss.rule.BladeOssRule; +import org.springblade.core.oss.rule.OssRule; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * Alioss配置类 + * + * @author Chill + */ +@Configuration +@AllArgsConstructor +@AutoConfigureAfter(QiniuConfiguration.class) +@EnableConfigurationProperties(OssProperties.class) +@ConditionalOnProperty(value = "oss.name", havingValue = "alioss") +public class AliossConfiguration { + + private OssProperties ossProperties; + + @Bean + @ConditionalOnMissingBean(OssRule.class) + public OssRule ossRule() { + return new BladeOssRule(); + } + + @Bean + @ConditionalOnMissingBean(OSSClient.class) + public OSSClient ossClient() { + // 创建ClientConfiguration。ClientConfiguration是OSSClient的配置类,可配置代理、连接超时、最大连接数等参数。 + ClientConfiguration conf = new ClientConfiguration(); + // 设置OSSClient允许打开的最大HTTP连接数,默认为1024个。 + conf.setMaxConnections(1024); + // 设置Socket层传输数据的超时时间,默认为50000毫秒。 + conf.setSocketTimeout(50000); + // 设置建立连接的超时时间,默认为50000毫秒。 + conf.setConnectionTimeout(50000); + // 设置从连接池中获取连接的超时时间(单位:毫秒),默认不超时。 + conf.setConnectionRequestTimeout(1000); + // 设置连接空闲超时时间。超时则关闭连接,默认为60000毫秒。 + conf.setIdleConnectionTime(60000); + // 设置失败请求重试次数,默认为3次。 + conf.setMaxErrorRetry(5); + CredentialsProvider credentialsProvider = new DefaultCredentialProvider(ossProperties.getAccessKey(), ossProperties.getSecretKey()); + return new OSSClient(ossProperties.getEndpoint(), credentialsProvider, conf); + } + + @Bean + @ConditionalOnMissingBean(AliossTemplate.class) + @ConditionalOnBean({OSSClient.class, OssRule.class}) + public AliossTemplate aliossTemplate(OSSClient ossClient, OssRule ossRule) { + return new AliossTemplate(ossClient, ossProperties, ossRule); + } + +} diff --git a/blade-core-oss/src/main/java/org/springblade/core/oss/config/OssConfiguration.java b/blade-core-oss/src/main/java/org/springblade/core/oss/config/QiniuConfiguration.java similarity index 96% rename from blade-core-oss/src/main/java/org/springblade/core/oss/config/OssConfiguration.java rename to blade-core-oss/src/main/java/org/springblade/core/oss/config/QiniuConfiguration.java index c69b614..52ab32a 100644 --- a/blade-core-oss/src/main/java/org/springblade/core/oss/config/OssConfiguration.java +++ b/blade-core-oss/src/main/java/org/springblade/core/oss/config/QiniuConfiguration.java @@ -39,8 +39,8 @@ import org.springframework.context.annotation.Configuration; @Configuration @AllArgsConstructor @EnableConfigurationProperties(OssProperties.class) -@ConditionalOnProperty(value = "oss.enable", havingValue = "true") -public class OssConfiguration { +@ConditionalOnProperty(value = "oss.name", havingValue = "qiniu") +public class QiniuConfiguration { private OssProperties ossProperties; diff --git a/blade-core-oss/src/main/java/org/springblade/core/oss/model/BladeFile.java b/blade-core-oss/src/main/java/org/springblade/core/oss/model/BladeFile.java index bc02327..3b746c7 100644 --- a/blade-core-oss/src/main/java/org/springblade/core/oss/model/BladeFile.java +++ b/blade-core-oss/src/main/java/org/springblade/core/oss/model/BladeFile.java @@ -32,4 +32,8 @@ public class BladeFile { * 文件名 */ private String name; + /** + * 原始文件名 + */ + private String originalName; } diff --git a/blade-core-oss/src/main/java/org/springblade/core/oss/props/OssProperties.java b/blade-core-oss/src/main/java/org/springblade/core/oss/props/OssProperties.java index 1a46887..7b29384 100644 --- a/blade-core-oss/src/main/java/org/springblade/core/oss/props/OssProperties.java +++ b/blade-core-oss/src/main/java/org/springblade/core/oss/props/OssProperties.java @@ -16,6 +16,7 @@ package org.springblade.core.oss.props; import lombok.Data; +import org.springblade.core.tool.support.Kv; import org.springframework.boot.context.properties.ConfigurationProperties; /** @@ -62,4 +63,9 @@ public class OssProperties { */ private String bucketName = "bladex"; + /** + * 自定义属性 + */ + private Kv args; + } diff --git a/blade-core-secure/pom.xml b/blade-core-secure/pom.xml index 0e18457..2367341 100644 --- a/blade-core-secure/pom.xml +++ b/blade-core-secure/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.1 + 2.6.2 4.0.0 diff --git a/blade-core-swagger/pom.xml b/blade-core-swagger/pom.xml index 3e4e62e..4f8da10 100644 --- a/blade-core-swagger/pom.xml +++ b/blade-core-swagger/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.1 + 2.6.2 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 88b245d..b51f6b6 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 = "2.6.1"; + private String version = "2.6.2"; /** * 许可证 **/ diff --git a/blade-core-test/pom.xml b/blade-core-test/pom.xml index 738064e..8a67b41 100644 --- a/blade-core-test/pom.xml +++ b/blade-core-test/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.6.1 + 2.6.2 4.0.0 diff --git a/blade-core-tool/pom.xml b/blade-core-tool/pom.xml index f8e0491..9f433eb 100644 --- a/blade-core-tool/pom.xml +++ b/blade-core-tool/pom.xml @@ -6,7 +6,7 @@ org.springblade blade-tool - 2.6.1 + 2.6.2 4.0.0 diff --git a/blade-core-transaction/pom.xml b/blade-core-transaction/pom.xml index e94897e..058f335 100644 --- a/blade-core-transaction/pom.xml +++ b/blade-core-transaction/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.1 + 2.6.2 4.0.0 @@ -31,6 +31,11 @@ spring-cloud-alibaba-seata ${alibaba.cloud.version} + + io.seata + seata-spring-boot-starter + ${alibaba.seata.version} + diff --git a/blade-core-transaction/src/main/java/org/springblade/core/transaction/config/DataSourceConfiguration.java b/blade-core-transaction/src/main/java/org/springblade/core/transaction/config/DataSourceConfiguration.java index a979a3c..2d6424e 100644 --- a/blade-core-transaction/src/main/java/org/springblade/core/transaction/config/DataSourceConfiguration.java +++ b/blade-core-transaction/src/main/java/org/springblade/core/transaction/config/DataSourceConfiguration.java @@ -15,21 +15,7 @@ */ package org.springblade.core.transaction.config; -import com.alibaba.druid.pool.DruidDataSource; -import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean; -import io.seata.rm.datasource.DataSourceProxy; -import io.seata.spring.boot.autoconfigure.util.SpringUtils; -import org.apache.ibatis.session.SqlSessionFactory; -import org.mybatis.spring.SqlSessionTemplate; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import org.springframework.core.io.support.PathMatchingResourcePatternResolver; -import org.springframework.core.io.support.ResourcePatternResolver; - -import javax.sql.DataSource; /** * 分布式事务数据源配置 @@ -39,48 +25,4 @@ import javax.sql.DataSource; @Configuration public class DataSourceConfiguration { - @Bean(name = "sqlSessionFactory") - public SqlSessionFactory sqlSessionFactoryBean(DataSourceProxy dataSourceProxy) throws Exception { - MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean(); - bean.setDataSource(dataSourceProxy); - ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); - bean.setMapperLocations(resolver.getResources("classpath:org/springblade/**/mapper/*Mapper.xml")); - SqlSessionFactory factory; - try { - factory = bean.getObject(); - } catch (Exception e) { - throw new RuntimeException(e); - } - return factory; - } - - @Bean - public SqlSessionTemplate sqlSessionTemplate(SqlSessionFactory sqlSessionFactory) { - return new SqlSessionTemplate(sqlSessionFactory); - } - - /** - * 从配置文件获取属性构造datasource - */ - @Bean - @ConfigurationProperties(prefix = "spring.datasource") - public DruidDataSource druidDataSource() { - return new DruidDataSource(); - } - - /** - * 构造datasource代理对象 - */ - @Primary - @Bean("dataSource") - public DataSourceProxy dataSourceProxy(DataSource druidDataSource) { - return new DataSourceProxy(druidDataSource); - } - - @Bean - @ConditionalOnMissingBean(SpringUtils.class) - public SpringUtils springUtils() { - return new SpringUtils(); - } - } diff --git a/pom.xml b/pom.xml index 7b05a43..8632643 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.6.1 + 2.6.2 pom blade-tool @@ -36,7 +36,7 @@ - 2.6.1 + 2.6.2 1.8 3.8.0 @@ -49,10 +49,10 @@ 2.2.2 1.1.0 2.2.0.RELEASE - 1.0.0 + 1.1.0 - 2.2.4.RELEASE - Hoxton.SR1 + 2.2.5.RELEASE + Hoxton.SR2 Cairo-SR8 UTF-8 From f6cbfb304067f848bc3f747f2ba647230c882d5a Mon Sep 17 00:00:00 2001 From: smallchill Date: Mon, 9 Mar 2020 15:03:33 +0800 Subject: [PATCH 08/27] =?UTF-8?q?:arrow=5Fup:=20knife4j=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E8=87=B32.0.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8632643..5f521d2 100644 --- a/pom.xml +++ b/pom.xml @@ -42,7 +42,7 @@ 3.8.0 2.9.2 1.5.21 - 2.0.1 + 2.0.2 3.3.1 1.6.0 3.4.2 From 90c8b73c7e9d438b5902691a46d42e6adb01b1c5 Mon Sep 17 00:00:00 2001 From: smallchill Date: Sun, 22 Mar 2020 12:29:47 +0800 Subject: [PATCH 09/27] =?UTF-8?q?:zap:=20=E4=BF=AE=E5=A4=8D=E4=B8=8Eseata?= =?UTF-8?q?=E7=9A=84springUtils=E9=87=8D=E5=A4=8D=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/springblade/core/tool/config/ToolConfiguration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/config/ToolConfiguration.java b/blade-core-tool/src/main/java/org/springblade/core/tool/config/ToolConfiguration.java index 0f5b62b..b0346dc 100644 --- a/blade-core-tool/src/main/java/org/springblade/core/tool/config/ToolConfiguration.java +++ b/blade-core-tool/src/main/java/org/springblade/core/tool/config/ToolConfiguration.java @@ -38,7 +38,7 @@ public class ToolConfiguration implements WebMvcConfigurer { * @return SpringUtil */ @Bean - public SpringUtil springUtils() { + public SpringUtil springUtil() { return new SpringUtil(); } From 3943a9f618b372b50e094dc23ce2744211e9d7b8 Mon Sep 17 00:00:00 2001 From: smallchill Date: Fri, 17 Apr 2020 20:52:36 +0800 Subject: [PATCH 10/27] =?UTF-8?q?:arrow=5Fup:=20=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BE=9D=E8=B5=96=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blade-core-boot/pom.xml | 2 +- .../resources/templates/saber/crud.vue.vm | 20 +++++++++++-------- blade-core-transaction/pom.xml | 7 +------ pom.xml | 6 +++--- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/blade-core-boot/pom.xml b/blade-core-boot/pom.xml index d64f807..0c33a36 100644 --- a/blade-core-boot/pom.xml +++ b/blade-core-boot/pom.xml @@ -88,7 +88,7 @@ com.alibaba druid-spring-boot-starter - 1.1.18 + 1.1.22 diff --git a/blade-core-develop/src/main/resources/templates/saber/crud.vue.vm b/blade-core-develop/src/main/resources/templates/saber/crud.vue.vm index 319a467..693fa02 100644 --- a/blade-core-develop/src/main/resources/templates/saber/crud.vue.vm +++ b/blade-core-develop/src/main/resources/templates/saber/crud.vue.vm @@ -47,6 +47,10 @@ }, selectionList: [], option: { + height: 'auto', + calcHeight: 80, + searchShow: true, + searchMenuSpan: 6, tip: false, border: true, index: true, @@ -90,30 +94,30 @@ } }, methods: { - rowSave(row, loading, done) { + rowSave(row, done, loading) { add(row).then(() => { - loading(); + done(); this.onLoad(this.page); this.$message({ type: "success", message: "操作成功!" }); }, error => { - done(); - console.log(error); + window.console.log(error); + loading(); }); }, - rowUpdate(row, index, loading, done) { + rowUpdate(row, index, done, loading) { update(row).then(() => { - loading(); + done(); this.onLoad(this.page); this.$message({ type: "success", message: "操作成功!" }); }, error => { - done(); - console.log(error); + window.console.log(error); + loading(); }); }, rowDel(row) { diff --git a/blade-core-transaction/pom.xml b/blade-core-transaction/pom.xml index 058f335..7324d01 100644 --- a/blade-core-transaction/pom.xml +++ b/blade-core-transaction/pom.xml @@ -28,14 +28,9 @@ com.alibaba.cloud - spring-cloud-alibaba-seata + spring-cloud-starter-alibaba-seata ${alibaba.cloud.version} - - io.seata - seata-spring-boot-starter - ${alibaba.seata.version} - diff --git a/pom.xml b/pom.xml index 5f521d2..7b0b300 100644 --- a/pom.xml +++ b/pom.xml @@ -48,11 +48,11 @@ 3.4.2 2.2.2 1.1.0 - 2.2.0.RELEASE + 2.2.1.RELEASE 1.1.0 - 2.2.5.RELEASE - Hoxton.SR2 + 2.2.6.RELEASE + Hoxton.SR3 Cairo-SR8 UTF-8 From b560c9d09756664916f3f0716301a8073ff4c0af Mon Sep 17 00:00:00 2001 From: smallchill Date: Fri, 17 Apr 2020 20:53:00 +0800 Subject: [PATCH 11/27] =?UTF-8?q?:zap:=20=E4=BC=98=E5=8C=96mybatis-plus?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blade-core-boot/src/main/resources/bootstrap.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blade-core-boot/src/main/resources/bootstrap.yml b/blade-core-boot/src/main/resources/bootstrap.yml index 395dcad..fbd909f 100644 --- a/blade-core-boot/src/main/resources/bootstrap.yml +++ b/blade-core-boot/src/main/resources/bootstrap.yml @@ -77,7 +77,7 @@ mybatis-plus: banner: false db-config: #主键类型 0:"数据库ID自增", 1:"不操作", 2:"用户输入ID",3:"数字型snowflake", 4:"全局唯一ID UUID", 5:"字符串型snowflake"; - id-type: id_worker + id-type: auto #字段策略 insert-strategy: not_null update-strategy: not_null From c9f1774fc7406eb20d7c4a178ee65ccdea9b72e8 Mon Sep 17 00:00:00 2001 From: smallchill Date: Fri, 17 Apr 2020 21:09:31 +0800 Subject: [PATCH 12/27] =?UTF-8?q?:zap:=20enable=E9=85=8D=E7=BD=AE=E5=85=B3?= =?UTF-8?q?=E9=94=AE=E5=AD=97=E7=BB=9F=E4=B8=80=E6=94=B9=E4=B8=BAenabled?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springblade/core/boot/config/MybatisPlusConfiguration.java | 2 +- .../main/java/org/springblade/core/oss/props/OssProperties.java | 2 +- .../org/springblade/core/secure/config/SecureConfiguration.java | 2 +- .../org/springblade/core/secure/registry/SecureRegistry.java | 2 +- .../java/org/springblade/core/tool/config/XssConfiguration.java | 2 +- .../org/springblade/core/tool/support/xss/XssProperties.java | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/blade-core-boot/src/main/java/org/springblade/core/boot/config/MybatisPlusConfiguration.java b/blade-core-boot/src/main/java/org/springblade/core/boot/config/MybatisPlusConfiguration.java index 784d414..336336b 100644 --- a/blade-core-boot/src/main/java/org/springblade/core/boot/config/MybatisPlusConfiguration.java +++ b/blade-core-boot/src/main/java/org/springblade/core/boot/config/MybatisPlusConfiguration.java @@ -44,7 +44,7 @@ public class MybatisPlusConfiguration { * @return SqlLogInterceptor */ @Bean - @ConditionalOnProperty(value = "blade.mybatis-plus.sql-log.enable", matchIfMissing = true) + @ConditionalOnProperty(value = "blade.mybatis-plus.sql-log", matchIfMissing = true) public SqlLogInterceptor sqlLogInterceptor() { return new SqlLogInterceptor(); } diff --git a/blade-core-oss/src/main/java/org/springblade/core/oss/props/OssProperties.java b/blade-core-oss/src/main/java/org/springblade/core/oss/props/OssProperties.java index 7b29384..41a64f8 100644 --- a/blade-core-oss/src/main/java/org/springblade/core/oss/props/OssProperties.java +++ b/blade-core-oss/src/main/java/org/springblade/core/oss/props/OssProperties.java @@ -31,7 +31,7 @@ public class OssProperties { /** * 是否启用 */ - private Boolean enable; + private Boolean enabled; /** * 对象存储名称 diff --git a/blade-core-secure/src/main/java/org/springblade/core/secure/config/SecureConfiguration.java b/blade-core-secure/src/main/java/org/springblade/core/secure/config/SecureConfiguration.java index 9f6df94..f9e4ab6 100644 --- a/blade-core-secure/src/main/java/org/springblade/core/secure/config/SecureConfiguration.java +++ b/blade-core-secure/src/main/java/org/springblade/core/secure/config/SecureConfiguration.java @@ -57,7 +57,7 @@ public class SecureConfiguration implements WebMvcConfigurer { public void addInterceptors(InterceptorRegistry registry) { clientProperties.getClient().forEach(cs -> registry.addInterceptor(new ClientInterceptor(cs.getClientId())).addPathPatterns(cs.getPathPatterns())); - if (secureRegistry.isEnable()) { + if (secureRegistry.isEnabled()) { registry.addInterceptor(new SecureInterceptor()) .excludePathPatterns(secureRegistry.getExcludePatterns()) .excludePathPatterns(secureRegistry.getDefaultExcludePatterns()) diff --git a/blade-core-secure/src/main/java/org/springblade/core/secure/registry/SecureRegistry.java b/blade-core-secure/src/main/java/org/springblade/core/secure/registry/SecureRegistry.java index f1f2851..80d06c0 100644 --- a/blade-core-secure/src/main/java/org/springblade/core/secure/registry/SecureRegistry.java +++ b/blade-core-secure/src/main/java/org/springblade/core/secure/registry/SecureRegistry.java @@ -29,7 +29,7 @@ import java.util.List; @Data public class SecureRegistry { - private boolean enable = false; + private boolean enabled = false; private final List defaultExcludePatterns = new ArrayList<>(); diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/config/XssConfiguration.java b/blade-core-tool/src/main/java/org/springblade/core/tool/config/XssConfiguration.java index d14adac..84c6eca 100644 --- a/blade-core-tool/src/main/java/org/springblade/core/tool/config/XssConfiguration.java +++ b/blade-core-tool/src/main/java/org/springblade/core/tool/config/XssConfiguration.java @@ -35,7 +35,7 @@ import javax.servlet.DispatcherType; */ @Configuration @AllArgsConstructor -@ConditionalOnProperty(value = "blade.xss.enable", havingValue = "true") +@ConditionalOnProperty(value = "blade.xss.enabled", havingValue = "true") @EnableConfigurationProperties({XssProperties.class, XssUrlProperties.class}) public class XssConfiguration { diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/support/xss/XssProperties.java b/blade-core-tool/src/main/java/org/springblade/core/tool/support/xss/XssProperties.java index 2b4e3d5..959439e 100644 --- a/blade-core-tool/src/main/java/org/springblade/core/tool/support/xss/XssProperties.java +++ b/blade-core-tool/src/main/java/org/springblade/core/tool/support/xss/XssProperties.java @@ -33,7 +33,7 @@ public class XssProperties { /** * 开启xss */ - private Boolean enable = true; + private Boolean enabled = true; /** * 放行url From 1e30d8b839768587bac1a70e4011b8c6999b0295 Mon Sep 17 00:00:00 2001 From: smallchill Date: Fri, 17 Apr 2020 21:46:45 +0800 Subject: [PATCH 13/27] =?UTF-8?q?:zap:=20=E4=BC=98=E5=8C=96secure=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0skip-url=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../secure/config/SecureConfiguration.java | 9 ++--- .../secure/interceptor/ClientInterceptor.java | 2 +- .../secure/interceptor/SecureInterceptor.java | 2 +- .../secure/props/BladeClientProperties.java | 35 ------------------- .../secure/props/BladeSecureProperties.java | 6 ++-- 5 files changed, 9 insertions(+), 45 deletions(-) delete mode 100644 blade-core-secure/src/main/java/org/springblade/core/secure/props/BladeClientProperties.java diff --git a/blade-core-secure/src/main/java/org/springblade/core/secure/config/SecureConfiguration.java b/blade-core-secure/src/main/java/org/springblade/core/secure/config/SecureConfiguration.java index f9e4ab6..a77de31 100644 --- a/blade-core-secure/src/main/java/org/springblade/core/secure/config/SecureConfiguration.java +++ b/blade-core-secure/src/main/java/org/springblade/core/secure/config/SecureConfiguration.java @@ -20,7 +20,6 @@ import lombok.AllArgsConstructor; import org.springblade.core.secure.aspect.AuthAspect; import org.springblade.core.secure.interceptor.ClientInterceptor; import org.springblade.core.secure.interceptor.SecureInterceptor; -import org.springblade.core.secure.props.BladeClientProperties; import org.springblade.core.secure.props.BladeSecureProperties; import org.springblade.core.secure.provider.ClientDetailsServiceImpl; import org.springblade.core.secure.provider.IClientDetailsService; @@ -42,26 +41,24 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Order @Configuration @AllArgsConstructor -@EnableConfigurationProperties({BladeSecureProperties.class, BladeClientProperties.class}) +@EnableConfigurationProperties({BladeSecureProperties.class}) public class SecureConfiguration implements WebMvcConfigurer { private final SecureRegistry secureRegistry; private final BladeSecureProperties secureProperties; - private final BladeClientProperties clientProperties; - private final JdbcTemplate jdbcTemplate; @Override public void addInterceptors(InterceptorRegistry registry) { - clientProperties.getClient().forEach(cs -> registry.addInterceptor(new ClientInterceptor(cs.getClientId())).addPathPatterns(cs.getPathPatterns())); + secureProperties.getClient().forEach(cs -> registry.addInterceptor(new ClientInterceptor(cs.getClientId())).addPathPatterns(cs.getPathPatterns())); if (secureRegistry.isEnabled()) { registry.addInterceptor(new SecureInterceptor()) .excludePathPatterns(secureRegistry.getExcludePatterns()) .excludePathPatterns(secureRegistry.getDefaultExcludePatterns()) - .excludePathPatterns(secureProperties.getExcludePatterns()); + .excludePathPatterns(secureProperties.getSkipUrl()); } } diff --git a/blade-core-secure/src/main/java/org/springblade/core/secure/interceptor/ClientInterceptor.java b/blade-core-secure/src/main/java/org/springblade/core/secure/interceptor/ClientInterceptor.java index a39c925..5626bf1 100644 --- a/blade-core-secure/src/main/java/org/springblade/core/secure/interceptor/ClientInterceptor.java +++ b/blade-core-secure/src/main/java/org/springblade/core/secure/interceptor/ClientInterceptor.java @@ -52,7 +52,7 @@ public class ClientInterceptor extends HandlerInterceptorAdapter { } else { log.warn("客户端认证失败,请求接口:{},请求IP:{},请求参数:{}", request.getRequestURI(), WebUtil.getIP(request), JsonUtil.toJson(request.getParameterMap())); R result = R.fail(ResultCode.UN_AUTHORIZED); - response.setHeader(BladeConstant.CONTENT_TYPE_NAME, MediaType.APPLICATION_JSON_UTF8_VALUE); + response.setHeader(BladeConstant.CONTENT_TYPE_NAME, MediaType.APPLICATION_JSON_VALUE); response.setCharacterEncoding(BladeConstant.UTF_8); response.setStatus(HttpServletResponse.SC_OK); try { diff --git a/blade-core-secure/src/main/java/org/springblade/core/secure/interceptor/SecureInterceptor.java b/blade-core-secure/src/main/java/org/springblade/core/secure/interceptor/SecureInterceptor.java index 37f0d9c..8588a13 100644 --- a/blade-core-secure/src/main/java/org/springblade/core/secure/interceptor/SecureInterceptor.java +++ b/blade-core-secure/src/main/java/org/springblade/core/secure/interceptor/SecureInterceptor.java @@ -48,7 +48,7 @@ public class SecureInterceptor extends HandlerInterceptorAdapter { log.warn("签名认证失败,请求接口:{},请求IP:{},请求参数:{}", request.getRequestURI(), WebUtil.getIP(request), JsonUtil.toJson(request.getParameterMap())); R result = R.fail(ResultCode.UN_AUTHORIZED); response.setCharacterEncoding(BladeConstant.UTF_8); - response.setHeader(BladeConstant.CONTENT_TYPE_NAME, MediaType.APPLICATION_JSON_UTF8_VALUE); + response.setHeader(BladeConstant.CONTENT_TYPE_NAME, MediaType.APPLICATION_JSON_VALUE); response.setStatus(HttpServletResponse.SC_OK); try { response.getWriter().write(Objects.requireNonNull(JsonUtil.toJson(result))); diff --git a/blade-core-secure/src/main/java/org/springblade/core/secure/props/BladeClientProperties.java b/blade-core-secure/src/main/java/org/springblade/core/secure/props/BladeClientProperties.java deleted file mode 100644 index 668f92a..0000000 --- a/blade-core-secure/src/main/java/org/springblade/core/secure/props/BladeClientProperties.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). - *

- * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.gnu.org/licenses/lgpl.html - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springblade.core.secure.props; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; - -import java.util.ArrayList; -import java.util.List; - -/** - * 客户端校验配置 - * - * @author Chill - */ -@Data -@ConfigurationProperties("blade.secure") -public class BladeClientProperties { - - private final List client = new ArrayList<>(); - -} diff --git a/blade-core-secure/src/main/java/org/springblade/core/secure/props/BladeSecureProperties.java b/blade-core-secure/src/main/java/org/springblade/core/secure/props/BladeSecureProperties.java index 7ee3766..f76b994 100644 --- a/blade-core-secure/src/main/java/org/springblade/core/secure/props/BladeSecureProperties.java +++ b/blade-core-secure/src/main/java/org/springblade/core/secure/props/BladeSecureProperties.java @@ -27,9 +27,11 @@ import java.util.List; * @author Chill */ @Data -@ConfigurationProperties("blade.secure.url") +@ConfigurationProperties("blade.secure") public class BladeSecureProperties { - private final List excludePatterns = new ArrayList<>(); + private final List client = new ArrayList<>(); + + private final List skipUrl = new ArrayList<>(); } From f7fa46462d5195b080f3bc4102920adf090d551d Mon Sep 17 00:00:00 2001 From: smallchill Date: Wed, 22 Apr 2020 18:35:13 +0800 Subject: [PATCH 14/27] =?UTF-8?q?:tada:=202.7.0.RELEASE,=E5=86=85=E6=A0=B8?= =?UTF-8?q?=E5=85=A8=E9=9D=A2=E5=8D=87=E7=BA=A7,=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=B2=97=E4=BD=8D=E7=AE=A1=E7=90=86,=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blade-core-boot/pom.xml | 2 +- .../src/main/resources/bootstrap.yml | 4 ++-- blade-core-cloud/pom.xml | 2 +- blade-core-develop/pom.xml | 2 +- .../resources/templates/controller.java.vm | 4 ++-- blade-core-launch/pom.xml | 2 +- .../core/launch/constant/AppConstant.java | 2 +- blade-core-log/pom.xml | 2 +- blade-core-mybatis/pom.xml | 2 +- .../springblade/core/mp/base/BaseEntity.java | 8 +++++-- .../springblade/core/mp/base/BaseService.java | 2 +- .../core/mp/base/BaseServiceImpl.java | 2 +- blade-core-oss/pom.xml | 2 +- blade-core-secure/pom.xml | 2 +- .../springblade/core/secure/BladeUser.java | 2 +- .../core/secure/utils/SecureUtil.java | 22 +++++++++++++++---- blade-core-swagger/pom.xml | 2 +- .../core/swagger/SwaggerProperties.java | 2 +- blade-core-test/pom.xml | 2 +- blade-core-tool/pom.xml | 2 +- .../springblade/core/tool/node/BaseNode.java | 10 +++++++-- .../core/tool/node/ForestNode.java | 4 +++- .../core/tool/node/ForestNodeManager.java | 8 +++---- .../org/springblade/core/tool/node/INode.java | 7 +++--- .../springblade/core/tool/node/NodeTest.java | 20 ++++++++--------- .../springblade/core/tool/node/TreeNode.java | 10 +++++++-- blade-core-transaction/pom.xml | 2 +- pom.xml | 4 ++-- 28 files changed, 84 insertions(+), 51 deletions(-) diff --git a/blade-core-boot/pom.xml b/blade-core-boot/pom.xml index 0c33a36..4efe168 100644 --- a/blade-core-boot/pom.xml +++ b/blade-core-boot/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.6.2 + 2.7.0 4.0.0 diff --git a/blade-core-boot/src/main/resources/bootstrap.yml b/blade-core-boot/src/main/resources/bootstrap.yml index fbd909f..be1e653 100644 --- a/blade-core-boot/src/main/resources/bootstrap.yml +++ b/blade-core-boot/src/main/resources/bootstrap.yml @@ -77,7 +77,7 @@ mybatis-plus: banner: false db-config: #主键类型 0:"数据库ID自增", 1:"不操作", 2:"用户输入ID",3:"数字型snowflake", 4:"全局唯一ID UUID", 5:"字符串型snowflake"; - id-type: auto + id-type: assign_id #字段策略 insert-strategy: not_null update-strategy: not_null @@ -97,7 +97,7 @@ mybatis-plus: swagger: title: SpringBlade 接口文档系统 description: SpringBlade 接口文档系统 - version: 2.6.2 + version: 2.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 e2a94e1..6c468ce 100644 --- a/blade-core-cloud/pom.xml +++ b/blade-core-cloud/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.2 + 2.7.0 4.0.0 diff --git a/blade-core-develop/pom.xml b/blade-core-develop/pom.xml index 83b559f..605f7db 100644 --- a/blade-core-develop/pom.xml +++ b/blade-core-develop/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.2 + 2.7.0 4.0.0 diff --git a/blade-core-develop/src/main/resources/templates/controller.java.vm b/blade-core-develop/src/main/resources/templates/controller.java.vm index 3f0d5e9..00f9721 100644 --- a/blade-core-develop/src/main/resources/templates/controller.java.vm +++ b/blade-core-develop/src/main/resources/templates/controller.java.vm @@ -160,7 +160,7 @@ public class $!{table.controllerName} { @ApiOperationSupport(order = 7) @ApiOperation(value = "逻辑删除", notes = "传入ids") public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { - return R.status($!{table.entityPath}Service.deleteLogic(Func.toIntList(ids))); + return R.status($!{table.entityPath}Service.deleteLogic(Func.toLongList(ids))); } #else @@ -172,7 +172,7 @@ public class $!{table.controllerName} { @ApiOperationSupport(order = 8) @ApiOperation(value = "删除", notes = "传入ids") public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { - return R.status($!{table.entityPath}Service.removeByIds(Func.toIntList(ids))); + return R.status($!{table.entityPath}Service.removeByIds(Func.toLongList(ids))); } #end diff --git a/blade-core-launch/pom.xml b/blade-core-launch/pom.xml index fda2a37..cc99a40 100644 --- a/blade-core-launch/pom.xml +++ b/blade-core-launch/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.2 + 2.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 b88f433..b7faea7 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 = "2.6.2"; + String APPLICATION_VERSION = "2.7.0"; /** * 基础包 diff --git a/blade-core-log/pom.xml b/blade-core-log/pom.xml index 6d3e857..93fd88c 100644 --- a/blade-core-log/pom.xml +++ b/blade-core-log/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.2 + 2.7.0 4.0.0 diff --git a/blade-core-mybatis/pom.xml b/blade-core-mybatis/pom.xml index 6be7a34..1c7f7f0 100644 --- a/blade-core-mybatis/pom.xml +++ b/blade-core-mybatis/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.2 + 2.7.0 4.0.0 diff --git a/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseEntity.java b/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseEntity.java index ed7c5ac..bf31156 100644 --- a/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseEntity.java +++ b/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseEntity.java @@ -18,6 +18,8 @@ package org.springblade.core.mp.base; import com.baomidou.mybatisplus.annotation.TableLogic; import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.springblade.core.tool.utils.DateUtil; @@ -37,8 +39,9 @@ public class BaseEntity implements Serializable { /** * 创建人 */ + @JsonSerialize(using = ToStringSerializer.class) @ApiModelProperty(value = "创建人") - private Integer createUser; + private Long createUser; /** * 创建时间 @@ -51,8 +54,9 @@ public class BaseEntity implements Serializable { /** * 更新人 */ + @JsonSerialize(using = ToStringSerializer.class) @ApiModelProperty(value = "更新人") - private Integer updateUser; + private Long updateUser; /** * 更新时间 diff --git a/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseService.java b/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseService.java index cf9dcfb..c1f356f 100644 --- a/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseService.java +++ b/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseService.java @@ -34,6 +34,6 @@ public interface BaseService extends IService { * @param ids id集合(逗号分隔) * @return boolean */ - boolean deleteLogic(@NotEmpty List ids); + boolean deleteLogic(@NotEmpty List ids); } diff --git a/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseServiceImpl.java b/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseServiceImpl.java index b7b592a..2ce62ab 100644 --- a/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseServiceImpl.java +++ b/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseServiceImpl.java @@ -65,7 +65,7 @@ public class BaseServiceImpl, T extends BaseEntity> exte } @Override - public boolean deleteLogic(@NotEmpty List ids) { + public boolean deleteLogic(@NotEmpty List ids) { return super.removeByIds(ids); } diff --git a/blade-core-oss/pom.xml b/blade-core-oss/pom.xml index d7690ed..7f39b9a 100644 --- a/blade-core-oss/pom.xml +++ b/blade-core-oss/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.2 + 2.7.0 4.0.0 diff --git a/blade-core-secure/pom.xml b/blade-core-secure/pom.xml index 2367341..69e2973 100644 --- a/blade-core-secure/pom.xml +++ b/blade-core-secure/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.2 + 2.7.0 4.0.0 diff --git a/blade-core-secure/src/main/java/org/springblade/core/secure/BladeUser.java b/blade-core-secure/src/main/java/org/springblade/core/secure/BladeUser.java index 43d94b6..37647dd 100644 --- a/blade-core-secure/src/main/java/org/springblade/core/secure/BladeUser.java +++ b/blade-core-secure/src/main/java/org/springblade/core/secure/BladeUser.java @@ -39,7 +39,7 @@ public class BladeUser implements Serializable { * 用户id */ @ApiModelProperty(hidden = true) - private Integer userId; + private Long userId; /** * 租户ID */ 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 4c72de5..eadae24 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 @@ -27,6 +27,7 @@ import org.springblade.core.secure.constant.SecureConstant; import org.springblade.core.secure.exception.SecureException; import org.springblade.core.secure.provider.IClientDetails; import org.springblade.core.secure.provider.IClientDetailsService; +import org.springblade.core.tool.constant.RoleConstant; import org.springblade.core.tool.utils.*; import javax.crypto.spec.SecretKeySpec; @@ -94,7 +95,7 @@ public class SecureUtil { return null; } String clientId = Func.toStr(claims.get(SecureUtil.CLIENT_ID)); - Integer userId = Func.toInt(claims.get(SecureUtil.USER_ID)); + Long userId = Func.toLong(claims.get(SecureUtil.USER_ID)); String tenantId = Func.toStr(claims.get(SecureUtil.TENANT_ID)); String roleId = Func.toStr(claims.get(SecureUtil.ROLE_ID)); String account = Func.toStr(claims.get(SecureUtil.ACCOUNT)); @@ -111,13 +112,21 @@ public class SecureUtil { return bladeUser; } + /** + * 是否为超管 + * + * @return boolean + */ + public static boolean isAdministrator() { + return StringUtil.containsAny(getUserRole(), RoleConstant.ADMIN); + } /** * 获取用户id * * @return userId */ - public static Integer getUserId() { + public static Long getUserId() { BladeUser user = getUser(); return (null == user) ? -1 : user.getUserId(); } @@ -128,7 +137,7 @@ public class SecureUtil { * @param request request * @return userId */ - public static Integer getUserId(HttpServletRequest request) { + public static Long getUserId(HttpServletRequest request) { BladeUser user = getUser(request); return (null == user) ? -1 : user.getUserId(); } @@ -246,12 +255,17 @@ public class SecureUtil { */ public static Claims getClaims(HttpServletRequest request) { String auth = request.getHeader(SecureUtil.HEADER); - if ((auth != null) && (auth.length() > AUTH_LENGTH)) { + 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); + } } return null; } diff --git a/blade-core-swagger/pom.xml b/blade-core-swagger/pom.xml index 4f8da10..9884200 100644 --- a/blade-core-swagger/pom.xml +++ b/blade-core-swagger/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.2 + 2.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 b51f6b6..660ef89 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 = "2.6.2"; + private String version = "2.7.0"; /** * 许可证 **/ diff --git a/blade-core-test/pom.xml b/blade-core-test/pom.xml index 8a67b41..1af4380 100644 --- a/blade-core-test/pom.xml +++ b/blade-core-test/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.6.2 + 2.7.0 4.0.0 diff --git a/blade-core-tool/pom.xml b/blade-core-tool/pom.xml index 9f433eb..4fc7f23 100644 --- a/blade-core-tool/pom.xml +++ b/blade-core-tool/pom.xml @@ -6,7 +6,7 @@ org.springblade blade-tool - 2.6.2 + 2.7.0 4.0.0 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 95ab993..aebbfbc 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 @@ -16,6 +16,8 @@ package org.springblade.core.tool.node; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import lombok.Data; import java.util.ArrayList; @@ -29,15 +31,19 @@ import java.util.List; @Data public class BaseNode implements INode { + private static final long serialVersionUID = 1L; + /** * 主键ID */ - protected Integer id; + @JsonSerialize(using = ToStringSerializer.class) + protected Long id; /** * 父节点ID */ - protected Integer parentId; + @JsonSerialize(using = ToStringSerializer.class) + protected Long parentId; /** * 子孙节点 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 8e28b41..cc23a36 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 @@ -28,12 +28,14 @@ import lombok.EqualsAndHashCode; @EqualsAndHashCode(callSuper = false) public class ForestNode extends BaseNode { + private static final long serialVersionUID = 1L; + /** * 节点内容 */ private Object content; - public ForestNode(Integer id, Integer parentId, Object content) { + public ForestNode(Long id, Long parentId, Object content) { this.id = id; this.parentId = parentId; this.content = content; 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 98a552a..97319e8 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 @@ -33,7 +33,7 @@ public class ForestNodeManager { /** * 森林的父节点ID */ - private List parentIds = new ArrayList<>(); + private List parentIds = new ArrayList<>(); public ForestNodeManager(List items) { list = items; @@ -45,9 +45,9 @@ public class ForestNodeManager { * @param id 节点ID * @return 对应的节点对象 */ - public INode getTreeNodeAT(int id) { + public INode getTreeNodeAT(Long id) { for (INode forestNode : list) { - if (forestNode.getId() == id) { + if (forestNode.getId().longValue() == id) { return forestNode; } } @@ -59,7 +59,7 @@ public class ForestNodeManager { * * @param parentId 父节点ID */ - public void addParentId(Integer parentId) { + public void addParentId(Long parentId) { parentIds.add(parentId); } 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 0fa909c..92659bf 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 @@ -15,6 +15,7 @@ */ package org.springblade.core.tool.node; +import java.io.Serializable; import java.util.List; /** @@ -22,21 +23,21 @@ import java.util.List; * * @author Chill */ -public interface INode { +public interface INode extends Serializable { /** * 主键 * * @return Integer */ - Integer getId(); + Long getId(); /** * 父主键 * * @return Integer */ - Integer getParentId(); + Long getParentId(); /** * 子孙节点 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 b13964b..d8c5532 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 @@ -14,16 +14,16 @@ public class NodeTest { public static void main(String[] args) { List list = new ArrayList<>(); - list.add(new ForestNode(1, 0, "1")); - list.add(new ForestNode(2, 0, "2")); - list.add(new ForestNode(3, 1, "3")); - list.add(new ForestNode(4, 2, "4")); - list.add(new ForestNode(5, 3, "5")); - list.add(new ForestNode(6, 4, "6")); - list.add(new ForestNode(7, 3, "7")); - list.add(new ForestNode(8, 5, "8")); - list.add(new ForestNode(9, 6, "9")); - list.add(new ForestNode(10, 9, "10")); + list.add(new ForestNode(1L, 0L, "1")); + list.add(new ForestNode(2L, 0L, "2")); + list.add(new ForestNode(3L, 1L, "3")); + list.add(new ForestNode(4L, 2L, "4")); + list.add(new ForestNode(5L, 3L, "5")); + list.add(new ForestNode(6L, 4L, "6")); + list.add(new ForestNode(7L, 3L, "7")); + list.add(new ForestNode(8L, 5L, "8")); + list.add(new ForestNode(9L, 6L, "9")); + list.add(new ForestNode(10L, 9L, "10")); List tns = ForestNodeMerger.merge(list); tns.forEach(node -> System.out.println(JsonUtil.toJson(node)) 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 fafaca0..a26a937 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 @@ -15,6 +15,8 @@ */ 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; @@ -27,10 +29,14 @@ import lombok.EqualsAndHashCode; @EqualsAndHashCode(callSuper = false) public class TreeNode extends BaseNode { + private static final long serialVersionUID = 1L; + private String title; - private Integer key; + @JsonSerialize(using = ToStringSerializer.class) + private Long key; - private Integer value; + @JsonSerialize(using = ToStringSerializer.class) + private Long value; } diff --git a/blade-core-transaction/pom.xml b/blade-core-transaction/pom.xml index 7324d01..38027e1 100644 --- a/blade-core-transaction/pom.xml +++ b/blade-core-transaction/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.6.2 + 2.7.0 4.0.0 diff --git a/pom.xml b/pom.xml index 7b0b300..efefeb7 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.6.2 + 2.7.0 pom blade-tool @@ -36,7 +36,7 @@ - 2.6.2 + 2.7.0 1.8 3.8.0 From eaed07f86f7616f894f8e66065106b278d4b2acf Mon Sep 17 00:00:00 2001 From: smallchill Date: Wed, 22 Apr 2020 18:41:29 +0800 Subject: [PATCH 15/27] =?UTF-8?q?:tada:=202.7.0.RELEASE,=E5=86=85=E6=A0=B8?= =?UTF-8?q?=E5=85=A8=E9=9D=A2=E5=8D=87=E7=BA=A7,=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=B2=97=E4=BD=8D=E7=AE=A1=E7=90=86,=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6bd464a..dc2fc6f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

Build Status - Coverage Status - Downloads + Coverage Status + Downloads

## SpringBlade微服务开发平台 From 3e974afe30412ea794852d0a9f6f622d7bae9d9f Mon Sep 17 00:00:00 2001 From: smallchill Date: Wed, 22 Apr 2020 18:44:04 +0800 Subject: [PATCH 16/27] =?UTF-8?q?:tada:=202.7.0.RELEASE,=E5=86=85=E6=A0=B8?= =?UTF-8?q?=E5=85=A8=E9=9D=A2=E5=8D=87=E7=BA=A7,=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=B2=97=E4=BD=8D=E7=AE=A1=E7=90=86,=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dc2fc6f..f3cf595 100644 --- a/README.md +++ b/README.md @@ -41,11 +41,14 @@ blade-tool * 官网地址:[https://bladex.vip](https://bladex.vip) * 问答社区:[https://sns.bladex.vip](https://sns.bladex.vip) * 会员计划:[SpringBlade会员计划](https://gitee.com/smallc/SpringBlade/wikis/SpringBlade会员计划) -* 交流群:`477853168` +* 交流一群:`477853168`(满) +* 交流二群:`751253339`(满) +* 交流三群:`784729540` ## 在线演示 * Sword演示地址:[https://sword.bladex.vip](https://sword.bladex.vip) * Saber演示地址:[https://saber.bladex.vip](https://saber.bladex.vip) +* 数据大屏演示地址:[https://data.avuejs.com](https://data.avuejs.com) ## 项目地址 * 后端Gitee地址:[https://gitee.com/smallc/SpringBlade](https://gitee.com/smallc/SpringBlade) From ce8939334244bfd942c7873ee231f6c0dd6454c5 Mon Sep 17 00:00:00 2001 From: smallchill Date: Fri, 24 Apr 2020 17:52:15 +0800 Subject: [PATCH 17/27] =?UTF-8?q?:tada:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=94=9F=E6=88=90=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/templates/saber/crud.vue.vm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/blade-core-develop/src/main/resources/templates/saber/crud.vue.vm b/blade-core-develop/src/main/resources/templates/saber/crud.vue.vm index 693fa02..77c78a7 100644 --- a/blade-core-develop/src/main/resources/templates/saber/crud.vue.vm +++ b/blade-core-develop/src/main/resources/templates/saber/crud.vue.vm @@ -171,9 +171,11 @@ this.query = {}; this.onLoad(this.page); }, - searchChange(params) { + searchChange(params, done) { this.query = params; + this.page.currentPage = 1; this.onLoad(this.page, params); + done(); }, selectionChange(list) { this.selectionList = list; From 8c3f34d6148a80112b3b5356d472b6213a75646d Mon Sep 17 00:00:00 2001 From: smallchill Date: Fri, 8 May 2020 14:22:32 +0800 Subject: [PATCH 18/27] =?UTF-8?q?:tada:=20=E6=96=B0=E5=A2=9E=E4=BA=A4?= =?UTF-8?q?=E6=B5=81=E5=9B=9B=E7=BE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f3cf595..a31a2b3 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,8 @@ blade-tool ├── blade-core-secure -- 安全模块 ├── blade-core-swagger -- swagger拓展封装模块 ├── blade-core-test -- 单元测试封装模块 -└── blade-core-tool -- 工具包模块 +├── blade-core-tool -- 单元测试封装模块 +└── blade-core-transaction -- 分布式事物封装模块 ``` @@ -43,7 +44,8 @@ blade-tool * 会员计划:[SpringBlade会员计划](https://gitee.com/smallc/SpringBlade/wikis/SpringBlade会员计划) * 交流一群:`477853168`(满) * 交流二群:`751253339`(满) -* 交流三群:`784729540` +* 交流三群:`784729540`(满) +* 交流四群:`1034621754` ## 在线演示 * Sword演示地址:[https://sword.bladex.vip](https://sword.bladex.vip) From f6c17900617f67b4ac5cbf0d391ec22cbe4dbd38 Mon Sep 17 00:00:00 2001 From: smallchill Date: Fri, 12 Jun 2020 10:12:26 +0800 Subject: [PATCH 19/27] =?UTF-8?q?:tada:=202.7.1.RELEASE,=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=A1=8C=E6=94=BF=E5=8C=BA=E5=88=92=E7=AE=A1=E7=90=86,?= =?UTF-8?q?=E6=94=AF=E6=8C=81Seata1.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +-- blade-core-boot/pom.xml | 2 +- .../src/main/resources/bootstrap.yml | 2 +- blade-core-cloud/pom.xml | 13 ++++---- .../cloud/stream/ServiceErrorStreams.java | 32 ------------------- blade-core-develop/pom.xml | 2 +- .../resources/templates/saber/crud.vue.vm | 2 +- blade-core-launch/pom.xml | 2 +- .../core/launch/constant/AppConstant.java | 2 +- blade-core-log/pom.xml | 2 +- .../core/log/utils/LogAbstractUtil.java | 19 ++++++----- blade-core-mybatis/pom.xml | 2 +- blade-core-oss/pom.xml | 2 +- blade-core-secure/pom.xml | 2 +- blade-core-swagger/pom.xml | 2 +- .../core/swagger/SwaggerProperties.java | 2 +- blade-core-test/pom.xml | 2 +- blade-core-tool/pom.xml | 2 +- .../springblade/core/tool/node/BaseNode.java | 18 +++++++++++ .../org/springblade/core/tool/node/INode.java | 9 ++++++ blade-core-transaction/pom.xml | 2 +- pom.xml | 16 +++++----- 22 files changed, 68 insertions(+), 73 deletions(-) delete mode 100644 blade-core-cloud/src/main/java/org/springblade/core/cloud/stream/ServiceErrorStreams.java diff --git a/README.md b/README.md index a31a2b3..30a4a59 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

Build Status - Coverage Status - Downloads + Coverage Status + Downloads

## SpringBlade微服务开发平台 diff --git a/blade-core-boot/pom.xml b/blade-core-boot/pom.xml index 4efe168..1777a56 100644 --- a/blade-core-boot/pom.xml +++ b/blade-core-boot/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.7.0 + 2.7.1 4.0.0 diff --git a/blade-core-boot/src/main/resources/bootstrap.yml b/blade-core-boot/src/main/resources/bootstrap.yml index be1e653..4804c3b 100644 --- a/blade-core-boot/src/main/resources/bootstrap.yml +++ b/blade-core-boot/src/main/resources/bootstrap.yml @@ -97,7 +97,7 @@ mybatis-plus: swagger: title: SpringBlade 接口文档系统 description: SpringBlade 接口文档系统 - version: 2.7.0 + version: 2.7.1 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 6c468ce..fc66d57 100644 --- a/blade-core-cloud/pom.xml +++ b/blade-core-cloud/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.0 + 2.7.1 4.0.0 @@ -27,11 +27,6 @@ org.springframework.retry spring-retry - - org.springframework.cloud - spring-cloud-stream - 2.2.1.RELEASE - io.github.openfeign @@ -87,6 +82,12 @@ spring-cloud-starter-alibaba-sentinel ${alibaba.cloud.version} + + + com.alibaba + fastjson + 1.2.70 + diff --git a/blade-core-cloud/src/main/java/org/springblade/core/cloud/stream/ServiceErrorStreams.java b/blade-core-cloud/src/main/java/org/springblade/core/cloud/stream/ServiceErrorStreams.java deleted file mode 100644 index 5398109..0000000 --- a/blade-core-cloud/src/main/java/org/springblade/core/cloud/stream/ServiceErrorStreams.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.springblade.core.cloud.stream; - -import org.springframework.cloud.stream.annotation.Input; -import org.springframework.cloud.stream.annotation.Output; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.SubscribableChannel; - -/** - * 服务异常 Streams - * - * @author L.cm - */ -public interface ServiceErrorStreams { - String INPUT = "service-error-in"; - String OUTPUT = "service-error-out"; - - /** - * input - * - * @return SubscribableChannel - */ - @Input(INPUT) - SubscribableChannel subscribablebChannel(); - - /** - * output - * - * @return MessageChannel - */ - @Output(OUTPUT) - MessageChannel messageChannel(); -} diff --git a/blade-core-develop/pom.xml b/blade-core-develop/pom.xml index 605f7db..e9e91f6 100644 --- a/blade-core-develop/pom.xml +++ b/blade-core-develop/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.0 + 2.7.1 4.0.0 diff --git a/blade-core-develop/src/main/resources/templates/saber/crud.vue.vm b/blade-core-develop/src/main/resources/templates/saber/crud.vue.vm index 77c78a7..6a24667 100644 --- a/blade-core-develop/src/main/resources/templates/saber/crud.vue.vm +++ b/blade-core-develop/src/main/resources/templates/saber/crud.vue.vm @@ -48,7 +48,7 @@ selectionList: [], option: { height: 'auto', - calcHeight: 80, + calcHeight: 210, searchShow: true, searchMenuSpan: 6, tip: false, diff --git a/blade-core-launch/pom.xml b/blade-core-launch/pom.xml index cc99a40..79fcb40 100644 --- a/blade-core-launch/pom.xml +++ b/blade-core-launch/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.0 + 2.7.1 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 b7faea7..69e9ab7 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 = "2.7.0"; + String APPLICATION_VERSION = "2.7.1"; /** * 基础包 diff --git a/blade-core-log/pom.xml b/blade-core-log/pom.xml index 93fd88c..71da98e 100644 --- a/blade-core-log/pom.xml +++ b/blade-core-log/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.0 + 2.7.1 4.0.0 diff --git a/blade-core-log/src/main/java/org/springblade/core/log/utils/LogAbstractUtil.java b/blade-core-log/src/main/java/org/springblade/core/log/utils/LogAbstractUtil.java index 176f956..de6192b 100644 --- a/blade-core-log/src/main/java/org/springblade/core/log/utils/LogAbstractUtil.java +++ b/blade-core-log/src/main/java/org/springblade/core/log/utils/LogAbstractUtil.java @@ -20,10 +20,7 @@ import org.springblade.core.launch.props.BladeProperties; import org.springblade.core.launch.server.ServerInfo; import org.springblade.core.log.model.LogAbstract; import org.springblade.core.secure.utils.SecureUtil; -import org.springblade.core.tool.utils.DateUtil; -import org.springblade.core.tool.utils.StringPool; -import org.springblade.core.tool.utils.UrlUtil; -import org.springblade.core.tool.utils.WebUtil; +import org.springblade.core.tool.utils.*; import javax.servlet.http.HttpServletRequest; @@ -41,12 +38,14 @@ public class LogAbstractUtil { * @param logAbstract 日志基础类 */ public static void addRequestInfoToLog(HttpServletRequest request, LogAbstract logAbstract) { - logAbstract.setRemoteIp(WebUtil.getIP(request)); - logAbstract.setUserAgent(request.getHeader(WebUtil.USER_AGENT_HEADER)); - logAbstract.setRequestUri(UrlUtil.getPath(request.getRequestURI())); - logAbstract.setMethod(request.getMethod()); - logAbstract.setParams(WebUtil.getRequestParamString(request)); - logAbstract.setCreateBy(SecureUtil.getUserAccount(request)); + if (ObjectUtil.isNotEmpty(request)) { + logAbstract.setRemoteIp(WebUtil.getIP(request)); + logAbstract.setUserAgent(request.getHeader(WebUtil.USER_AGENT_HEADER)); + logAbstract.setRequestUri(UrlUtil.getPath(request.getRequestURI())); + logAbstract.setMethod(request.getMethod()); + logAbstract.setParams(WebUtil.getRequestParamString(request)); + logAbstract.setCreateBy(SecureUtil.getUserAccount(request)); + } } /** diff --git a/blade-core-mybatis/pom.xml b/blade-core-mybatis/pom.xml index 1c7f7f0..d6e485a 100644 --- a/blade-core-mybatis/pom.xml +++ b/blade-core-mybatis/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.0 + 2.7.1 4.0.0 diff --git a/blade-core-oss/pom.xml b/blade-core-oss/pom.xml index 7f39b9a..96a3195 100644 --- a/blade-core-oss/pom.xml +++ b/blade-core-oss/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.0 + 2.7.1 4.0.0 diff --git a/blade-core-secure/pom.xml b/blade-core-secure/pom.xml index 69e2973..5f4073d 100644 --- a/blade-core-secure/pom.xml +++ b/blade-core-secure/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.0 + 2.7.1 4.0.0 diff --git a/blade-core-swagger/pom.xml b/blade-core-swagger/pom.xml index 9884200..6b9a346 100644 --- a/blade-core-swagger/pom.xml +++ b/blade-core-swagger/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.0 + 2.7.1 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 660ef89..0ea633d 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 = "2.7.0"; + private String version = "2.7.1"; /** * 许可证 **/ diff --git a/blade-core-test/pom.xml b/blade-core-test/pom.xml index 1af4380..dbeb991 100644 --- a/blade-core-test/pom.xml +++ b/blade-core-test/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.7.0 + 2.7.1 4.0.0 diff --git a/blade-core-tool/pom.xml b/blade-core-tool/pom.xml index 4fc7f23..8858fc3 100644 --- a/blade-core-tool/pom.xml +++ b/blade-core-tool/pom.xml @@ -6,7 +6,7 @@ org.springblade blade-tool - 2.7.0 + 2.7.1 4.0.0 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 aebbfbc..67754d3 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 @@ -51,4 +51,22 @@ public class BaseNode implements INode { @JsonInclude(JsonInclude.Include.NON_EMPTY) protected List children = new ArrayList<>(); + /** + * 是否有子孙节点 + */ + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private Boolean hasChildren; + + /** + * 是否有子孙节点 + */ + @Override + public Boolean getHasChildren() { + if (children.size() > 0) { + return true; + } else { + return this.hasChildren; + } + } + } 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 92659bf..b9db178 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 @@ -46,4 +46,13 @@ public interface INode extends Serializable { */ List getChildren(); + /** + * 是否有子孙节点 + * + * @return Boolean + */ + default Boolean getHasChildren() { + return false; + } + } diff --git a/blade-core-transaction/pom.xml b/blade-core-transaction/pom.xml index 38027e1..9b82cb8 100644 --- a/blade-core-transaction/pom.xml +++ b/blade-core-transaction/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.0 + 2.7.1 4.0.0 diff --git a/pom.xml b/pom.xml index efefeb7..afff777 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.7.0 + 2.7.1 pom blade-tool @@ -36,23 +36,23 @@ - 2.7.0 + 2.7.1 1.8 3.8.0 2.9.2 1.5.21 - 2.0.2 - 3.3.1 + 2.0.3 + 3.3.2 1.6.0 3.4.2 - 2.2.2 + 2.2.3 1.1.0 2.2.1.RELEASE - 1.1.0 + 1.2.0 - 2.2.6.RELEASE - Hoxton.SR3 + 2.2.7.RELEASE + Hoxton.SR5 Cairo-SR8 UTF-8 From 331b79c569085fd3d717558cab80f305a5caf375 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Jul 2020 22:19:55 +0000 Subject: [PATCH 20/27] :arrow_up: Bump mysql-connector-java in /blade-core-boot Bumps [mysql-connector-java](https://github.com/mysql/mysql-connector-j) from 8.0.15 to 8.0.16. - [Release notes](https://github.com/mysql/mysql-connector-j/releases) - [Changelog](https://github.com/mysql/mysql-connector-j/blob/release/8.0/CHANGES) - [Commits](https://github.com/mysql/mysql-connector-j/compare/8.0.15...8.0.16) Signed-off-by: dependabot[bot] --- blade-core-boot/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blade-core-boot/pom.xml b/blade-core-boot/pom.xml index 1777a56..7678f34 100644 --- a/blade-core-boot/pom.xml +++ b/blade-core-boot/pom.xml @@ -94,7 +94,7 @@ mysql mysql-connector-java - 8.0.15 + 8.0.16 + + org.springblade + blade-core-tool + ${blade.tool.version} + + + + me.zhyd.oauth + JustAuth + 1.15.6 + + + org.apache.httpcomponents + httpclient + + + + diff --git a/blade-core-social/src/main/java/org/springblade/core/social/config/SocialConfiguration.java b/blade-core-social/src/main/java/org/springblade/core/social/config/SocialConfiguration.java new file mode 100644 index 0000000..10bd116 --- /dev/null +++ b/blade-core-social/src/main/java/org/springblade/core/social/config/SocialConfiguration.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.core.social.config; + +import com.xkcoding.http.HttpUtil; +import com.xkcoding.http.support.Http; +import com.xkcoding.http.support.httpclient.HttpClientImpl; +import org.springblade.core.social.props.SocialProperties; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * SocialConfiguration + * + * @author Chill + */ +@Configuration +@EnableConfigurationProperties(SocialProperties.class) +public class SocialConfiguration { + + @Bean + @ConditionalOnMissingBean(Http.class) + public Http simpleHttp() { + HttpClientImpl httpClient = new HttpClientImpl(); + HttpUtil.setHttp(httpClient); + return httpClient; + } + +} diff --git a/blade-core-social/src/main/java/org/springblade/core/social/props/SocialProperties.java b/blade-core-social/src/main/java/org/springblade/core/social/props/SocialProperties.java new file mode 100644 index 0000000..33ce734 --- /dev/null +++ b/blade-core-social/src/main/java/org/springblade/core/social/props/SocialProperties.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.core.social.props; + +import com.google.common.collect.Maps; +import lombok.Getter; +import lombok.Setter; +import me.zhyd.oauth.config.AuthConfig; +import me.zhyd.oauth.config.AuthDefaultSource; +import org.springframework.boot.context.properties.ConfigurationProperties; + +import java.util.Map; + +/** + * SocialProperties + * + * @author Chill + */ +@Getter +@Setter +@ConfigurationProperties(prefix = "social") +public class SocialProperties { + + /** + * 启用 + */ + private Boolean enabled = false; + + /** + * 域名地址 + */ + private String domain; + + /** + * 类型 + */ + private Map oauth = Maps.newHashMap(); + + /** + * 别名 + */ + private Map alias = Maps.newHashMap(); + +} diff --git a/blade-core-social/src/main/java/org/springblade/core/social/utils/SocialUtil.java b/blade-core-social/src/main/java/org/springblade/core/social/utils/SocialUtil.java new file mode 100644 index 0000000..d3e6140 --- /dev/null +++ b/blade-core-social/src/main/java/org/springblade/core/social/utils/SocialUtil.java @@ -0,0 +1,150 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.core.social.utils; + +import me.zhyd.oauth.config.AuthConfig; +import me.zhyd.oauth.config.AuthDefaultSource; +import me.zhyd.oauth.exception.AuthException; +import me.zhyd.oauth.request.*; +import org.springblade.core.social.props.SocialProperties; + +import java.util.Objects; + +/** + * SocialUtil + * + * @author Chill + */ +public class SocialUtil { + + /** + * 根据具体的授权来源,获取授权请求工具类 + * + * @param source 授权来源 + * @return AuthRequest + */ + public static AuthRequest getAuthRequest(String source, SocialProperties socialProperties) { + AuthDefaultSource authSource = Objects.requireNonNull(AuthDefaultSource.valueOf(source.toUpperCase())); + AuthConfig authConfig = socialProperties.getOauth().get(authSource); + if (authConfig == null) { + throw new AuthException("未获取到有效的Auth配置"); + } + AuthRequest authRequest = null; + switch (authSource) { + case GITHUB: + authRequest = new AuthGithubRequest(authConfig); + break; + case GITEE: + authRequest = new AuthGiteeRequest(authConfig); + break; + case OSCHINA: + authRequest = new AuthOschinaRequest(authConfig); + break; + case QQ: + authRequest = new AuthQqRequest(authConfig); + break; + case WECHAT_OPEN: + authRequest = new AuthWeChatOpenRequest(authConfig); + break; + case WECHAT_ENTERPRISE: + authRequest = new AuthWeChatEnterpriseRequest(authConfig); + break; + case WECHAT_MP: + authRequest = new AuthWeChatMpRequest(authConfig); + break; + case DINGTALK: + authRequest = new AuthDingTalkRequest(authConfig); + break; + case ALIPAY: + // 支付宝在创建回调地址时,不允许使用localhost或者127.0.0.1,所以这儿的回调地址使用的局域网内的ip + authRequest = new AuthAlipayRequest(authConfig); + break; + case BAIDU: + authRequest = new AuthBaiduRequest(authConfig); + break; + case WEIBO: + authRequest = new AuthWeiboRequest(authConfig); + break; + case CODING: + authRequest = new AuthCodingRequest(authConfig); + break; + case CSDN: + authRequest = new AuthCsdnRequest(authConfig); + break; + case TAOBAO: + authRequest = new AuthTaobaoRequest(authConfig); + break; + case GOOGLE: + authRequest = new AuthGoogleRequest(authConfig); + break; + case FACEBOOK: + authRequest = new AuthFacebookRequest(authConfig); + break; + case DOUYIN: + authRequest = new AuthDouyinRequest(authConfig); + break; + case LINKEDIN: + authRequest = new AuthLinkedinRequest(authConfig); + break; + case MICROSOFT: + authRequest = new AuthMicrosoftRequest(authConfig); + break; + case MI: + authRequest = new AuthMiRequest(authConfig); + break; + case TOUTIAO: + authRequest = new AuthToutiaoRequest(authConfig); + break; + case TEAMBITION: + authRequest = new AuthTeambitionRequest(authConfig); + break; + case PINTEREST: + authRequest = new AuthPinterestRequest(authConfig); + break; + case RENREN: + authRequest = new AuthRenrenRequest(authConfig); + break; + case STACK_OVERFLOW: + authRequest = new AuthStackOverflowRequest(authConfig); + break; + case HUAWEI: + authRequest = new AuthHuaweiRequest(authConfig); + break; + case KUJIALE: + authRequest = new AuthKujialeRequest(authConfig); + break; + case GITLAB: + authRequest = new AuthGitlabRequest(authConfig); + break; + case MEITUAN: + authRequest = new AuthMeituanRequest(authConfig); + break; + case ELEME: + authRequest = new AuthElemeRequest(authConfig); + break; + case TWITTER: + authRequest = new AuthTwitterRequest(authConfig); + break; + default: + break; + } + if (null == authRequest) { + throw new AuthException("未获取到有效的Auth配置"); + } + return authRequest; + } + +} diff --git a/blade-core-swagger/pom.xml b/blade-core-swagger/pom.xml index 6b9a346..d7661ad 100644 --- a/blade-core-swagger/pom.xml +++ b/blade-core-swagger/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.1 + 2.7.2 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 0ea633d..c4ccb52 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 = "2.7.1"; + private String version = "2.7.2"; /** * 许可证 **/ diff --git a/blade-core-test/pom.xml b/blade-core-test/pom.xml index dbeb991..7c69831 100644 --- a/blade-core-test/pom.xml +++ b/blade-core-test/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.7.1 + 2.7.2 4.0.0 diff --git a/blade-core-tool/pom.xml b/blade-core-tool/pom.xml index 8858fc3..97dd0b6 100644 --- a/blade-core-tool/pom.xml +++ b/blade-core-tool/pom.xml @@ -6,7 +6,7 @@ org.springblade blade-tool - 2.7.1 + 2.7.2 4.0.0 diff --git a/blade-core-transaction/pom.xml b/blade-core-transaction/pom.xml index 74f1a79..2ccb8cf 100644 --- a/blade-core-transaction/pom.xml +++ b/blade-core-transaction/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.1 + 2.7.2 4.0.0 diff --git a/pom.xml b/pom.xml index 153b653..9145669 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.7.1 + 2.7.2 pom blade-tool @@ -36,23 +36,23 @@ - 2.7.1 + 2.7.2 1.8 3.8.0 2.9.2 1.5.21 - 2.0.3 + 2.0.4 3.3.2 1.6.0 3.4.2 - 2.2.3 + 2.3.0 1.1.0 2.2.1.RELEASE 1.3.0 - 2.2.7.RELEASE - Hoxton.SR5 + 2.2.9.RELEASE + Hoxton.SR7 Cairo-SR8 UTF-8 @@ -67,6 +67,7 @@ blade-core-log blade-core-mybatis blade-core-secure + blade-core-social blade-core-swagger blade-core-test blade-core-tool From fe850c71e9fb973644b013f7667378f24d70ccb4 Mon Sep 17 00:00:00 2001 From: smallchill Date: Fri, 11 Sep 2020 10:24:40 +0800 Subject: [PATCH 23/27] =?UTF-8?q?:tada:=202.7.3.RELEASE=20=E5=8D=87?= =?UTF-8?q?=E7=BA=A7=E5=A4=9A=E7=A7=9F=E6=88=B7=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blade-core-boot/pom.xml | 2 +- .../boot/config/MybatisPlusConfiguration.java | 32 ++++++++++++++++--- .../core/boot/tenant/BladeTenantHandler.java | 10 +++--- .../core/boot/tenant/TenantConfiguration.java | 29 ++--------------- .../src/main/resources/bootstrap.yml | 2 +- blade-core-cloud/pom.xml | 2 +- blade-core-develop/pom.xml | 2 +- blade-core-launch/pom.xml | 2 +- .../core/launch/constant/AppConstant.java | 2 +- blade-core-log/pom.xml | 2 +- blade-core-mybatis/pom.xml | 2 +- blade-core-oss/pom.xml | 2 +- blade-core-secure/pom.xml | 2 +- blade-core-social/pom.xml | 2 +- blade-core-swagger/pom.xml | 2 +- .../core/swagger/SwaggerProperties.java | 2 +- blade-core-test/pom.xml | 2 +- blade-core-tool/pom.xml | 2 +- blade-core-transaction/pom.xml | 2 +- pom.xml | 8 ++--- 20 files changed, 56 insertions(+), 55 deletions(-) diff --git a/blade-core-boot/pom.xml b/blade-core-boot/pom.xml index 933f9be..a30012c 100644 --- a/blade-core-boot/pom.xml +++ b/blade-core-boot/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.7.2 + 2.7.3 4.0.0 diff --git a/blade-core-boot/src/main/java/org/springblade/core/boot/config/MybatisPlusConfiguration.java b/blade-core-boot/src/main/java/org/springblade/core/boot/config/MybatisPlusConfiguration.java index 336336b..abcf4d6 100644 --- a/blade-core-boot/src/main/java/org/springblade/core/boot/config/MybatisPlusConfiguration.java +++ b/blade-core-boot/src/main/java/org/springblade/core/boot/config/MybatisPlusConfiguration.java @@ -15,7 +15,12 @@ */ package org.springblade.core.boot.config; -import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; +import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer; +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor; +import lombok.AllArgsConstructor; import org.mybatis.spring.annotation.MapperScan; import org.springblade.core.mp.plugins.SqlLogInterceptor; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -29,13 +34,32 @@ import org.springframework.context.annotation.Configuration; * @author Chill */ @Configuration +@AllArgsConstructor @MapperScan("org.springblade.**.mapper.**") public class MybatisPlusConfiguration { + private final TenantLineHandler tenantLineHandler; + + /** + * mybatis-plus 拦截器集合 + */ @Bean - @ConditionalOnMissingBean(PaginationInterceptor.class) - public PaginationInterceptor paginationInterceptor() { - return new PaginationInterceptor(); + @ConditionalOnMissingBean(MybatisPlusInterceptor.class) + public MybatisPlusInterceptor mybatisPlusInterceptor() { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + // 配置租户拦截器 + interceptor.addInnerInterceptor(new TenantLineInnerInterceptor(tenantLineHandler)); + // 配置分页拦截器 + interceptor.addInnerInterceptor(new PaginationInnerInterceptor()); + return interceptor; + } + + /** + * mybatis-plus自3.4.0起采用新的分页插件,一缓和二缓遵循mybatis的规则,需要设置 MybatisConfiguration#useDeprecatedExecutor = false 避免缓存出现问题(该属性会在旧插件移除后一同移除) + */ + @Bean + public ConfigurationCustomizer configurationCustomizer() { + return configuration -> configuration.setUseDeprecatedExecutor(false); } /** diff --git a/blade-core-boot/src/main/java/org/springblade/core/boot/tenant/BladeTenantHandler.java b/blade-core-boot/src/main/java/org/springblade/core/boot/tenant/BladeTenantHandler.java index 13e22e6..0780d47 100644 --- a/blade-core-boot/src/main/java/org/springblade/core/boot/tenant/BladeTenantHandler.java +++ b/blade-core-boot/src/main/java/org/springblade/core/boot/tenant/BladeTenantHandler.java @@ -15,7 +15,7 @@ */ package org.springblade.core.boot.tenant; -import com.baomidou.mybatisplus.extension.plugins.tenant.TenantHandler; +import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import net.sf.jsqlparser.expression.Expression; @@ -31,7 +31,7 @@ import org.springblade.core.tool.utils.StringUtil; */ @Slf4j @AllArgsConstructor -public class BladeTenantHandler implements TenantHandler { +public class BladeTenantHandler implements TenantLineHandler { private final BladeTenantProperties properties; @@ -41,7 +41,7 @@ public class BladeTenantHandler implements TenantHandler { * @return 租户ID */ @Override - public Expression getTenantId(boolean where) { + public Expression getTenantId() { return new StringValue(Func.toStr(SecureUtil.getTenantId(), TenantConstant.DEFAULT_TENANT_ID)); } @@ -59,10 +59,10 @@ public class BladeTenantHandler implements TenantHandler { * 过滤租户表 * * @param tableName 表名 - * @return 是否进行过滤 + * @return 是否忽略, true:表示忽略,false:需要解析并拼接多租户条件 */ @Override - public boolean doTableFilter(String tableName) { + public boolean ignoreTable(String tableName) { return !( ( (properties.getTables().size() > 0 && properties.getTables().contains(tableName)) diff --git a/blade-core-boot/src/main/java/org/springblade/core/boot/tenant/TenantConfiguration.java b/blade-core-boot/src/main/java/org/springblade/core/boot/tenant/TenantConfiguration.java index 06a8feb..6cd8170 100644 --- a/blade-core-boot/src/main/java/org/springblade/core/boot/tenant/TenantConfiguration.java +++ b/blade-core-boot/src/main/java/org/springblade/core/boot/tenant/TenantConfiguration.java @@ -15,10 +15,7 @@ */ package org.springblade.core.boot.tenant; -import com.baomidou.mybatisplus.core.parser.ISqlParser; -import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; -import com.baomidou.mybatisplus.extension.plugins.tenant.TenantHandler; -import com.baomidou.mybatisplus.extension.plugins.tenant.TenantSqlParser; +import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler; import lombok.AllArgsConstructor; import org.springblade.core.boot.config.MybatisPlusConfiguration; import org.springframework.boot.autoconfigure.AutoConfigureBefore; @@ -27,9 +24,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import java.util.ArrayList; -import java.util.List; - /** * 多租户配置类 * @@ -52,8 +46,8 @@ public class TenantConfiguration { * @return TenantHandler */ @Bean - @ConditionalOnMissingBean(TenantHandler.class) - public TenantHandler bladeTenantHandler() { + @ConditionalOnMissingBean(TenantLineHandler.class) + public TenantLineHandler bladeTenantHandler() { return new BladeTenantHandler(properties); } @@ -68,21 +62,4 @@ public class TenantConfiguration { return new BladeTenantId(); } - /** - * 分页插件 - * - * @param tenantHandler 自定义租户处理器 - * @return PaginationInterceptor - */ - @Bean - public PaginationInterceptor paginationInterceptor(TenantHandler tenantHandler) { - PaginationInterceptor paginationInterceptor = new PaginationInterceptor(); - List sqlParserList = new ArrayList<>(); - TenantSqlParser tenantSqlParser = new TenantSqlParser(); - tenantSqlParser.setTenantHandler(tenantHandler); - sqlParserList.add(tenantSqlParser); - paginationInterceptor.setSqlParserList(sqlParserList); - return paginationInterceptor; - } - } diff --git a/blade-core-boot/src/main/resources/bootstrap.yml b/blade-core-boot/src/main/resources/bootstrap.yml index f87e636..f3f8664 100644 --- a/blade-core-boot/src/main/resources/bootstrap.yml +++ b/blade-core-boot/src/main/resources/bootstrap.yml @@ -97,7 +97,7 @@ mybatis-plus: swagger: title: SpringBlade 接口文档系统 description: SpringBlade 接口文档系统 - version: 2.7.2 + version: 2.7.3 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 5328eb5..b685220 100644 --- a/blade-core-cloud/pom.xml +++ b/blade-core-cloud/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.2 + 2.7.3 4.0.0 diff --git a/blade-core-develop/pom.xml b/blade-core-develop/pom.xml index 10b444a..2887098 100644 --- a/blade-core-develop/pom.xml +++ b/blade-core-develop/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.2 + 2.7.3 4.0.0 diff --git a/blade-core-launch/pom.xml b/blade-core-launch/pom.xml index ab89a71..baaa8aa 100644 --- a/blade-core-launch/pom.xml +++ b/blade-core-launch/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.2 + 2.7.3 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 f3f7541..0a1d6e8 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 = "2.7.2"; + String APPLICATION_VERSION = "2.7.3"; /** * 基础包 diff --git a/blade-core-log/pom.xml b/blade-core-log/pom.xml index 94041af..a722cb1 100644 --- a/blade-core-log/pom.xml +++ b/blade-core-log/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.2 + 2.7.3 4.0.0 diff --git a/blade-core-mybatis/pom.xml b/blade-core-mybatis/pom.xml index 1d2b061..7e2e60b 100644 --- a/blade-core-mybatis/pom.xml +++ b/blade-core-mybatis/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.2 + 2.7.3 4.0.0 diff --git a/blade-core-oss/pom.xml b/blade-core-oss/pom.xml index cd00546..d87639d 100644 --- a/blade-core-oss/pom.xml +++ b/blade-core-oss/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.2 + 2.7.3 4.0.0 diff --git a/blade-core-secure/pom.xml b/blade-core-secure/pom.xml index e3db633..f923e7b 100644 --- a/blade-core-secure/pom.xml +++ b/blade-core-secure/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.2 + 2.7.3 4.0.0 diff --git a/blade-core-social/pom.xml b/blade-core-social/pom.xml index a1e5953..6ec08c4 100644 --- a/blade-core-social/pom.xml +++ b/blade-core-social/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.2 + 2.7.3 4.0.0 diff --git a/blade-core-swagger/pom.xml b/blade-core-swagger/pom.xml index d7661ad..5a104da 100644 --- a/blade-core-swagger/pom.xml +++ b/blade-core-swagger/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.2 + 2.7.3 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 c4ccb52..1525640 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 = "2.7.2"; + private String version = "2.7.3"; /** * 许可证 **/ diff --git a/blade-core-test/pom.xml b/blade-core-test/pom.xml index 7c69831..d0ef651 100644 --- a/blade-core-test/pom.xml +++ b/blade-core-test/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.7.2 + 2.7.3 4.0.0 diff --git a/blade-core-tool/pom.xml b/blade-core-tool/pom.xml index 97dd0b6..2f9e51a 100644 --- a/blade-core-tool/pom.xml +++ b/blade-core-tool/pom.xml @@ -6,7 +6,7 @@ org.springblade blade-tool - 2.7.2 + 2.7.3 4.0.0 diff --git a/blade-core-transaction/pom.xml b/blade-core-transaction/pom.xml index 2ccb8cf..a535c21 100644 --- a/blade-core-transaction/pom.xml +++ b/blade-core-transaction/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.2 + 2.7.3 4.0.0 diff --git a/pom.xml b/pom.xml index 9145669..cb98dfe 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.7.2 + 2.7.3 pom blade-tool @@ -36,14 +36,14 @@ - 2.7.2 + 2.7.3 1.8 3.8.0 2.9.2 1.5.21 2.0.4 - 3.3.2 + 3.4.0 1.6.0 3.4.2 2.3.0 @@ -52,7 +52,7 @@ 1.3.0 2.2.9.RELEASE - Hoxton.SR7 + Hoxton.SR8 Cairo-SR8 UTF-8 From b02311fad3f9099fd33c340058610296ea8530a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=A2=A6=E6=8A=80=E6=9C=AF?= <596392912@qq.com> Date: Mon, 14 Sep 2020 17:50:20 +0800 Subject: [PATCH 24/27] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=20kv=20clone?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/springblade/core/tool/support/Kv.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/support/Kv.java b/blade-core-tool/src/main/java/org/springblade/core/tool/support/Kv.java index 819e250..cbd6a53 100644 --- a/blade-core-tool/src/main/java/org/springblade/core/tool/support/Kv.java +++ b/blade-core-tool/src/main/java/org/springblade/core/tool/support/Kv.java @@ -30,9 +30,8 @@ import java.util.HashMap; */ public class Kv extends LinkedCaseInsensitiveMap { - private Kv() { - + super(); } /** @@ -44,8 +43,8 @@ public class Kv extends LinkedCaseInsensitiveMap { return new Kv(); } - public static HashMap newMap() { - return new HashMap(16); + public static HashMap newMap() { + return new HashMap<>(16); } /** @@ -198,7 +197,9 @@ public class Kv extends LinkedCaseInsensitiveMap { @Override public Kv clone() { - return (Kv) super.clone(); + Kv clone = new Kv(); + clone.putAll(this); + return clone; } } From 5b9a64338f0305bcf4147b90e2061c1e1bd11cf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=A2=A6=E6=8A=80=E6=9C=AF?= <596392912@qq.com> Date: Tue, 22 Sep 2020 17:50:21 +0800 Subject: [PATCH 25/27] =?UTF-8?q?:arrow=5Fup:=20=E5=8D=87=E7=BA=A7=20mica?= =?UTF-8?q?=20auto=20=E5=88=B0=201.2.5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cb98dfe..66061a9 100644 --- a/pom.xml +++ b/pom.xml @@ -47,7 +47,7 @@ 1.6.0 3.4.2 2.3.0 - 1.1.0 + 1.2.5 2.2.1.RELEASE 1.3.0 From 0134dc660c78bbce50f6cc397d9ea07557c1ec6c Mon Sep 17 00:00:00 2001 From: smallchill Date: Fri, 6 Nov 2020 17:12:53 +0800 Subject: [PATCH 26/27] =?UTF-8?q?:tada:=202.8.0.RELEASE=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=9C=A8=E7=BA=BF=E6=8A=A5=E8=A1=A8=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +- blade-core-boot/pom.xml | 4 +- .../src/main/resources/bootstrap.yml | 2 +- blade-core-cloud/pom.xml | 4 +- blade-core-develop/pom.xml | 2 +- blade-core-launch/pom.xml | 2 +- .../core/launch/constant/AppConstant.java | 6 +- .../core/launch/constant/TokenConstant.java | 2 +- blade-core-log/pom.xml | 2 +- blade-core-mybatis/pom.xml | 2 +- blade-core-oss/pom.xml | 2 +- blade-core-report/pom.xml | 30 +++++ .../report/config/ReportConfiguration.java | 65 +++++++++++ .../report/datasource/ReportDataSource.java | 54 +++++++++ .../report/endpoint/ReportBootEndpoint.java | 38 ++++++ .../core/report/endpoint/ReportEndpoint.java | 71 +++++++++++ .../core/report/entity/ReportFileEntity.java | 65 +++++++++++ .../core/report/mapper/ReportFileMapper.java | 27 +++++ .../props/ReportDatabaseProperties.java | 32 +++++ .../core/report/props/ReportProperties.java | 35 ++++++ .../report/provider/DatabaseProvider.java | 110 ++++++++++++++++++ .../provider/ReportPlaceholderProvider.java | 39 +++++++ .../report/service/IReportFileService.java | 27 +++++ .../service/impl/ReportFileServiceImpl.java | 31 +++++ blade-core-secure/pom.xml | 11 +- .../io/jsonwebtoken/impl/Base64Codec.java | 37 ------ .../core/secure/registry/SecureRegistry.java | 1 - .../core/secure/utils/SecureUtil.java | 12 +- blade-core-social/pom.xml | 4 +- blade-core-swagger/pom.xml | 2 +- .../core/swagger/EnableSwagger.java | 32 +++++ .../swagger/SwaggerAutoConfiguration.java | 43 +++---- .../swagger/SwaggerLauncherServiceImpl.java | 43 +++++++ .../core/swagger/SwaggerProperties.java | 2 +- .../springblade/core/swagger/SwaggerUtil.java | 2 +- ...gblade.core.launch.service.LauncherService | 1 + blade-core-test/pom.xml | 2 +- blade-core-tool/pom.xml | 4 +- blade-core-transaction/pom.xml | 2 +- pom.xml | 26 +++-- 40 files changed, 779 insertions(+), 101 deletions(-) create mode 100644 blade-core-report/pom.xml create mode 100644 blade-core-report/src/main/java/org/springblade/core/report/config/ReportConfiguration.java create mode 100644 blade-core-report/src/main/java/org/springblade/core/report/datasource/ReportDataSource.java create mode 100644 blade-core-report/src/main/java/org/springblade/core/report/endpoint/ReportBootEndpoint.java create mode 100644 blade-core-report/src/main/java/org/springblade/core/report/endpoint/ReportEndpoint.java create mode 100644 blade-core-report/src/main/java/org/springblade/core/report/entity/ReportFileEntity.java create mode 100644 blade-core-report/src/main/java/org/springblade/core/report/mapper/ReportFileMapper.java create mode 100644 blade-core-report/src/main/java/org/springblade/core/report/props/ReportDatabaseProperties.java create mode 100644 blade-core-report/src/main/java/org/springblade/core/report/props/ReportProperties.java create mode 100644 blade-core-report/src/main/java/org/springblade/core/report/provider/DatabaseProvider.java create mode 100644 blade-core-report/src/main/java/org/springblade/core/report/provider/ReportPlaceholderProvider.java create mode 100644 blade-core-report/src/main/java/org/springblade/core/report/service/IReportFileService.java create mode 100644 blade-core-report/src/main/java/org/springblade/core/report/service/impl/ReportFileServiceImpl.java delete mode 100644 blade-core-secure/src/main/java/io/jsonwebtoken/impl/Base64Codec.java create mode 100644 blade-core-swagger/src/main/java/org/springblade/core/swagger/EnableSwagger.java create mode 100644 blade-core-swagger/src/main/java/org/springblade/core/swagger/SwaggerLauncherServiceImpl.java create mode 100644 blade-core-swagger/src/main/resources/META-INF/services/org.springblade.core.launch.service.LauncherService diff --git a/README.md b/README.md index 6c89615..69ebff8 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

Build Status - Coverage Status - Downloads + Coverage Status + Downloads

## SpringBlade微服务开发平台 diff --git a/blade-core-boot/pom.xml b/blade-core-boot/pom.xml index c884ad3..fe34379 100644 --- a/blade-core-boot/pom.xml +++ b/blade-core-boot/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.7.3 + 2.8.0 4.0.0 @@ -88,7 +88,7 @@ com.alibaba druid-spring-boot-starter - 1.1.22 + 1.2.1 diff --git a/blade-core-boot/src/main/resources/bootstrap.yml b/blade-core-boot/src/main/resources/bootstrap.yml index f3f8664..2b3841f 100644 --- a/blade-core-boot/src/main/resources/bootstrap.yml +++ b/blade-core-boot/src/main/resources/bootstrap.yml @@ -97,7 +97,7 @@ mybatis-plus: swagger: title: SpringBlade 接口文档系统 description: SpringBlade 接口文档系统 - version: 2.7.3 + version: 2.8.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 b685220..9572333 100644 --- a/blade-core-cloud/pom.xml +++ b/blade-core-cloud/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.3 + 2.8.0 4.0.0 @@ -86,7 +86,7 @@ com.alibaba fastjson - 1.2.73 + 1.2.74 diff --git a/blade-core-develop/pom.xml b/blade-core-develop/pom.xml index 2887098..c9fcc45 100644 --- a/blade-core-develop/pom.xml +++ b/blade-core-develop/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.3 + 2.8.0 4.0.0 diff --git a/blade-core-launch/pom.xml b/blade-core-launch/pom.xml index baaa8aa..2109d38 100644 --- a/blade-core-launch/pom.xml +++ b/blade-core-launch/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.3 + 2.8.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 0a1d6e8..3d00ded 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 = "2.7.3"; + String APPLICATION_VERSION = "2.8.0"; /** * 基础包 @@ -76,6 +76,10 @@ public interface AppConstant { * 链路追踪模块名称 */ String APPLICATION_ZIPKIN_NAME = APPLICATION_NAME_PREFIX + "zipkin"; + /** + * 报表系统名称 + */ + String APPLICATION_REPORT_NAME = APPLICATION_NAME_PREFIX + "report"; /** * 测试模块名称 */ 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 9a30741..39d9da6 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 @@ -22,7 +22,7 @@ package org.springblade.core.launch.constant; */ public interface TokenConstant { - String SIGN_KEY = "Blade"; + String SIGN_KEY = "bladexisapowerfulmicroservicearchitectureupgradedandoptimizedfromacommercialproject"; String AVATAR = "avatar"; String HEADER = "blade-auth"; String BEARER = "bearer"; diff --git a/blade-core-log/pom.xml b/blade-core-log/pom.xml index a722cb1..9c30b95 100644 --- a/blade-core-log/pom.xml +++ b/blade-core-log/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.3 + 2.8.0 4.0.0 diff --git a/blade-core-mybatis/pom.xml b/blade-core-mybatis/pom.xml index 7e2e60b..c314c6f 100644 --- a/blade-core-mybatis/pom.xml +++ b/blade-core-mybatis/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.3 + 2.8.0 4.0.0 diff --git a/blade-core-oss/pom.xml b/blade-core-oss/pom.xml index d87639d..2e7b7a7 100644 --- a/blade-core-oss/pom.xml +++ b/blade-core-oss/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.3 + 2.8.0 4.0.0 diff --git a/blade-core-report/pom.xml b/blade-core-report/pom.xml new file mode 100644 index 0000000..478351d --- /dev/null +++ b/blade-core-report/pom.xml @@ -0,0 +1,30 @@ + + + + blade-tool + org.springblade + 2.8.0 + + 4.0.0 + + blade-core-report + ${project.artifactId} + ${blade.tool.version} + jar + + + + org.springblade + blade-core-mybatis + ${blade.tool.version} + + + com.bstek.ureport + ureport2-console + 2.2.9 + + + + diff --git a/blade-core-report/src/main/java/org/springblade/core/report/config/ReportConfiguration.java b/blade-core-report/src/main/java/org/springblade/core/report/config/ReportConfiguration.java new file mode 100644 index 0000000..ef28971 --- /dev/null +++ b/blade-core-report/src/main/java/org/springblade/core/report/config/ReportConfiguration.java @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.core.report.config; + +import com.bstek.ureport.UReportPropertyPlaceholderConfigurer; +import com.bstek.ureport.console.UReportServlet; +import com.bstek.ureport.provider.report.ReportProvider; +import org.springblade.core.report.props.ReportDatabaseProperties; +import org.springblade.core.report.props.ReportProperties; +import org.springblade.core.report.provider.DatabaseProvider; +import org.springblade.core.report.provider.ReportPlaceholderProvider; +import org.springblade.core.report.service.IReportFileService; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.web.servlet.ServletRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; +import org.springframework.core.annotation.Order; + +import javax.servlet.Servlet; + +/** + * UReport配置类 + * + * @author Chill + */ +@Order +@Configuration +@ConditionalOnProperty(value = "report.enabled", havingValue = "true", matchIfMissing = true) +@EnableConfigurationProperties({ReportProperties.class, ReportDatabaseProperties.class}) +@ImportResource("classpath:ureport-console-context.xml") +public class ReportConfiguration { + + @Bean + public ServletRegistrationBean registrationBean() { + return new ServletRegistrationBean<>(new UReportServlet(), "/ureport/*"); + } + + @Bean + public UReportPropertyPlaceholderConfigurer uReportPropertyPlaceholderConfigurer(ReportProperties properties) { + return new ReportPlaceholderProvider(properties); + } + + @Bean + @ConditionalOnMissingBean + public ReportProvider reportProvider(ReportDatabaseProperties properties, IReportFileService service) { + return new DatabaseProvider(properties, service); + } + +} diff --git a/blade-core-report/src/main/java/org/springblade/core/report/datasource/ReportDataSource.java b/blade-core-report/src/main/java/org/springblade/core/report/datasource/ReportDataSource.java new file mode 100644 index 0000000..ebb6deb --- /dev/null +++ b/blade-core-report/src/main/java/org/springblade/core/report/datasource/ReportDataSource.java @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.core.report.datasource; + +import com.bstek.ureport.definition.datasource.BuildinDatasource; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.SQLException; + +/** + * UReport数据源配置 + * + * @author Chill + */ +@Slf4j +@AllArgsConstructor +public class ReportDataSource implements BuildinDatasource { + private static final String NAME = "ReportDataSource"; + + private final DataSource dataSource; + + @Override + public String name() { + return NAME; + } + + @Override + public Connection getConnection() { + try { + return dataSource.getConnection(); + } catch (SQLException e) { + log.error("report数据源链接失败"); + e.printStackTrace(); + } + return null; + } + +} diff --git a/blade-core-report/src/main/java/org/springblade/core/report/endpoint/ReportBootEndpoint.java b/blade-core-report/src/main/java/org/springblade/core/report/endpoint/ReportBootEndpoint.java new file mode 100644 index 0000000..2879ee3 --- /dev/null +++ b/blade-core-report/src/main/java/org/springblade/core/report/endpoint/ReportBootEndpoint.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.core.report.endpoint; + +import org.springblade.core.launch.constant.AppConstant; +import org.springblade.core.report.service.IReportFileService; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import springfox.documentation.annotations.ApiIgnore; + +/** + * UReport Boot版 API端点 + * + * @author Chill + */ +@ApiIgnore +@RestController +@RequestMapping(AppConstant.APPLICATION_REPORT_NAME + "/report/rest") +public class ReportBootEndpoint extends ReportEndpoint { + + public ReportBootEndpoint(IReportFileService service) { + super(service); + } + +} diff --git a/blade-core-report/src/main/java/org/springblade/core/report/endpoint/ReportEndpoint.java b/blade-core-report/src/main/java/org/springblade/core/report/endpoint/ReportEndpoint.java new file mode 100644 index 0000000..0ea59aa --- /dev/null +++ b/blade-core-report/src/main/java/org/springblade/core/report/endpoint/ReportEndpoint.java @@ -0,0 +1,71 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.core.report.endpoint; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import lombok.AllArgsConstructor; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.report.entity.ReportFileEntity; +import org.springblade.core.report.service.IReportFileService; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import java.util.Map; + +/** + * UReport API端点 + * + * @author Chill + */ +@ApiIgnore +@RestController +@AllArgsConstructor +@RequestMapping("/report/rest") +public class ReportEndpoint { + + private final IReportFileService service; + + /** + * 详情 + */ + @GetMapping("/detail") + public R detail(ReportFileEntity file) { + ReportFileEntity detail = service.getOne(Condition.getQueryWrapper(file)); + return R.data(detail); + } + + /** + * 分页 + */ + @GetMapping("/list") + public R> list(@RequestParam Map file, Query query) { + IPage pages = service.page(Condition.getPage(query), Condition.getQueryWrapper(file, ReportFileEntity.class)); + return R.data(pages); + } + + /** + * 删除 + */ + @PostMapping("/remove") + public R remove(@RequestParam String ids) { + boolean temp = service.removeByIds(Func.toLongList(ids)); + return R.status(temp); + } + +} diff --git a/blade-core-report/src/main/java/org/springblade/core/report/entity/ReportFileEntity.java b/blade-core-report/src/main/java/org/springblade/core/report/entity/ReportFileEntity.java new file mode 100644 index 0000000..1e60c61 --- /dev/null +++ b/blade-core-report/src/main/java/org/springblade/core/report/entity/ReportFileEntity.java @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.core.report.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * UReport实体类 + * + * @author Chill + */ +@Data +@TableName("blade_report_file") +public class ReportFileEntity implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(value = "id", type = IdType.ASSIGN_ID) + private Long id; + /** + * 文件名 + */ + private String name; + /** + * 文件内容 + */ + private byte[] content; + /** + * 创建时间 + */ + private Date createTime; + /** + * 更新时间 + */ + private Date updateTime; + /** + * 是否已删除 + */ + @TableLogic + private Integer isDeleted; + +} diff --git a/blade-core-report/src/main/java/org/springblade/core/report/mapper/ReportFileMapper.java b/blade-core-report/src/main/java/org/springblade/core/report/mapper/ReportFileMapper.java new file mode 100644 index 0000000..719afc4 --- /dev/null +++ b/blade-core-report/src/main/java/org/springblade/core/report/mapper/ReportFileMapper.java @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.core.report.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.springblade.core.report.entity.ReportFileEntity; + +/** + * UReport Mapper + * + * @author Chill + */ +public interface ReportFileMapper extends BaseMapper { +} diff --git a/blade-core-report/src/main/java/org/springblade/core/report/props/ReportDatabaseProperties.java b/blade-core-report/src/main/java/org/springblade/core/report/props/ReportDatabaseProperties.java new file mode 100644 index 0000000..e84328d --- /dev/null +++ b/blade-core-report/src/main/java/org/springblade/core/report/props/ReportDatabaseProperties.java @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.core.report.props; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * UReport配置类 + * + * @author Chill + */ +@Data +@ConfigurationProperties(prefix = "report.database.provider") +public class ReportDatabaseProperties { + private String name = "数据库文件系统"; + private String prefix = "blade-"; + private boolean disabled = false; +} diff --git a/blade-core-report/src/main/java/org/springblade/core/report/props/ReportProperties.java b/blade-core-report/src/main/java/org/springblade/core/report/props/ReportProperties.java new file mode 100644 index 0000000..823c981 --- /dev/null +++ b/blade-core-report/src/main/java/org/springblade/core/report/props/ReportProperties.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.core.report.props; + +import lombok.Data; +import org.springblade.core.tool.utils.StringPool; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * UReport配置类 + * + * @author Chill + */ +@Data +@ConfigurationProperties(prefix = "report") +public class ReportProperties { + private Boolean enabled = true; + private Boolean disableHttpSessionReportCache = false; + private Boolean disableFileProvider = true; + private String fileStoreDir = StringPool.EMPTY; + private Boolean debug = false; +} diff --git a/blade-core-report/src/main/java/org/springblade/core/report/provider/DatabaseProvider.java b/blade-core-report/src/main/java/org/springblade/core/report/provider/DatabaseProvider.java new file mode 100644 index 0000000..114918f --- /dev/null +++ b/blade-core-report/src/main/java/org/springblade/core/report/provider/DatabaseProvider.java @@ -0,0 +1,110 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.core.report.provider; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.bstek.ureport.provider.report.ReportFile; +import com.bstek.ureport.provider.report.ReportProvider; +import lombok.AllArgsConstructor; +import org.springblade.core.report.entity.ReportFileEntity; +import org.springblade.core.report.props.ReportDatabaseProperties; +import org.springblade.core.report.service.IReportFileService; +import org.springblade.core.tool.constant.BladeConstant; +import org.springblade.core.tool.utils.DateUtil; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * 数据库文件处理 + * + * @author Chill + */ +@AllArgsConstructor +public class DatabaseProvider implements ReportProvider { + + private final ReportDatabaseProperties properties; + private final IReportFileService service; + + @Override + public InputStream loadReport(String file) { + ReportFileEntity reportFileEntity = service.getOne(Wrappers.lambdaQuery().eq(ReportFileEntity::getName, getFileName(file))); + byte[] content = reportFileEntity.getContent(); + return new ByteArrayInputStream(content); + } + + @Override + public void deleteReport(String file) { + service.remove(Wrappers.lambdaUpdate().eq(ReportFileEntity::getName, getFileName(file))); + } + + @Override + public List getReportFiles() { + List list = service.list(); + List reportFiles = new ArrayList<>(); + list.forEach(reportFileEntity -> reportFiles.add(new ReportFile(reportFileEntity.getName(), reportFileEntity.getUpdateTime()))); + return reportFiles; + } + + @Override + public void saveReport(String file, String content) { + String fileName = getFileName(file); + ReportFileEntity reportFileEntity = service.getOne(Wrappers.lambdaQuery().eq(ReportFileEntity::getName, fileName)); + Date now = DateUtil.now(); + if (reportFileEntity == null) { + reportFileEntity = new ReportFileEntity(); + reportFileEntity.setName(fileName); + reportFileEntity.setContent(content.getBytes()); + reportFileEntity.setCreateTime(now); + reportFileEntity.setIsDeleted(BladeConstant.DB_NOT_DELETED); + } else { + reportFileEntity.setContent(content.getBytes()); + } + reportFileEntity.setUpdateTime(now); + service.saveOrUpdate(reportFileEntity); + } + + @Override + public String getName() { + return properties.getName(); + } + + @Override + public boolean disabled() { + return properties.isDisabled(); + } + + @Override + public String getPrefix() { + return properties.getPrefix(); + } + + /** + * 获取标准格式文件名 + * + * @param name 原文件名 + */ + private String getFileName(String name) { + if (name.startsWith(getPrefix())) { + name = name.substring(getPrefix().length()); + } + return name; + } + +} diff --git a/blade-core-report/src/main/java/org/springblade/core/report/provider/ReportPlaceholderProvider.java b/blade-core-report/src/main/java/org/springblade/core/report/provider/ReportPlaceholderProvider.java new file mode 100644 index 0000000..01e28a7 --- /dev/null +++ b/blade-core-report/src/main/java/org/springblade/core/report/provider/ReportPlaceholderProvider.java @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.core.report.provider; + +import com.bstek.ureport.UReportPropertyPlaceholderConfigurer; +import org.springblade.core.report.props.ReportProperties; + +import java.util.Properties; + +/** + * UReport自定义配置 + * + * @author Chill + */ +public class ReportPlaceholderProvider extends UReportPropertyPlaceholderConfigurer { + + public ReportPlaceholderProvider(ReportProperties properties) { + Properties props = new Properties(); + props.setProperty("ureport.disableHttpSessionReportCache", properties.getDisableHttpSessionReportCache().toString()); + props.setProperty("ureport.disableFileProvider", properties.getDisableFileProvider().toString()); + props.setProperty("ureport.fileStoreDir", properties.getFileStoreDir()); + props.setProperty("ureport.debug", properties.getDebug().toString()); + this.setProperties(props); + } + +} diff --git a/blade-core-report/src/main/java/org/springblade/core/report/service/IReportFileService.java b/blade-core-report/src/main/java/org/springblade/core/report/service/IReportFileService.java new file mode 100644 index 0000000..9cf5b13 --- /dev/null +++ b/blade-core-report/src/main/java/org/springblade/core/report/service/IReportFileService.java @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.core.report.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.springblade.core.report.entity.ReportFileEntity; + +/** + * UReport Service + * + * @author Chill + */ +public interface IReportFileService extends IService { +} diff --git a/blade-core-report/src/main/java/org/springblade/core/report/service/impl/ReportFileServiceImpl.java b/blade-core-report/src/main/java/org/springblade/core/report/service/impl/ReportFileServiceImpl.java new file mode 100644 index 0000000..2939eb6 --- /dev/null +++ b/blade-core-report/src/main/java/org/springblade/core/report/service/impl/ReportFileServiceImpl.java @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.core.report.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springblade.core.report.entity.ReportFileEntity; +import org.springblade.core.report.mapper.ReportFileMapper; +import org.springblade.core.report.service.IReportFileService; +import org.springframework.stereotype.Service; + +/** + * UReport Service + * + * @author Chill + */ +@Service +public class ReportFileServiceImpl extends ServiceImpl implements IReportFileService { +} diff --git a/blade-core-secure/pom.xml b/blade-core-secure/pom.xml index f923e7b..0593b60 100644 --- a/blade-core-secure/pom.xml +++ b/blade-core-secure/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.3 + 2.8.0 4.0.0 @@ -19,8 +19,13 @@ io.jsonwebtoken - jjwt - 0.9.1 + jjwt-impl + 0.11.2 + + + io.jsonwebtoken + jjwt-jackson + 0.11.2 diff --git a/blade-core-secure/src/main/java/io/jsonwebtoken/impl/Base64Codec.java b/blade-core-secure/src/main/java/io/jsonwebtoken/impl/Base64Codec.java deleted file mode 100644 index b73e2f2..0000000 --- a/blade-core-secure/src/main/java/io/jsonwebtoken/impl/Base64Codec.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2014 jsonwebtoken.io - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.jsonwebtoken.impl; - -import java.util.Base64; - -/** - * Base64Codec - * - * @author jjwt - */ -public class Base64Codec extends AbstractTextCodec { - - @Override - public String encode(byte[] data) { - return Base64.getEncoder().encodeToString(data); - } - - @Override - public byte[] decode(String encoded) { - return Base64.getDecoder().decode(encoded); - } - -} diff --git a/blade-core-secure/src/main/java/org/springblade/core/secure/registry/SecureRegistry.java b/blade-core-secure/src/main/java/org/springblade/core/secure/registry/SecureRegistry.java index 80d06c0..978b0b7 100644 --- a/blade-core-secure/src/main/java/org/springblade/core/secure/registry/SecureRegistry.java +++ b/blade-core-secure/src/main/java/org/springblade/core/secure/registry/SecureRegistry.java @@ -38,7 +38,6 @@ public class SecureRegistry { public SecureRegistry() { this.defaultExcludePatterns.add("/actuator/health/**"); this.defaultExcludePatterns.add("/v2/api-docs/**"); - this.defaultExcludePatterns.add("/v2/api-docs-ext/**"); this.defaultExcludePatterns.add("/auth/**"); this.defaultExcludePatterns.add("/token/**"); this.defaultExcludePatterns.add("/log/**"); 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 eadae24..553dbfb 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 @@ -53,9 +53,9 @@ public class SecureUtil { private final static String TENANT_ID = TokenConstant.TENANT_ID; private final static String CLIENT_ID = TokenConstant.CLIENT_ID; private final static Integer AUTH_LENGTH = TokenConstant.AUTH_LENGTH; - private static String BASE64_SECURITY = Base64.getEncoder().encodeToString(TokenConstant.SIGN_KEY.getBytes(Charsets.UTF_8)); + private static final String BASE64_SECURITY = Base64.getEncoder().encodeToString(TokenConstant.SIGN_KEY.getBytes(Charsets.UTF_8)); - private static IClientDetailsService clientDetailsService; + private static final IClientDetailsService clientDetailsService; static { clientDetailsService = SpringUtil.getBean(IClientDetailsService.class); @@ -297,8 +297,8 @@ public class SecureUtil { */ public static Claims parseJWT(String jsonWebToken) { try { - return Jwts.parser() - .setSigningKey(Base64.getDecoder().decode(BASE64_SECURITY)) + return Jwts.parserBuilder() + .setSigningKey(Base64.getDecoder().decode(BASE64_SECURITY)).build() .parseClaimsJws(jsonWebToken).getBody(); } catch (Exception ex) { return null; @@ -339,10 +339,10 @@ public class SecureUtil { Key signingKey = new SecretKeySpec(apiKeySecretBytes, signatureAlgorithm.getJcaName()); //添加构成JWT的类 - JwtBuilder builder = Jwts.builder().setHeaderParam("typ", "JsonWebToken") + JwtBuilder builder = Jwts.builder().setHeaderParam("typ", "JWT") .setIssuer(issuer) .setAudience(audience) - .signWith(signatureAlgorithm, signingKey); + .signWith(signingKey); //设置JWT参数 user.forEach(builder::claim); diff --git a/blade-core-social/pom.xml b/blade-core-social/pom.xml index 6ec08c4..b1f44bc 100644 --- a/blade-core-social/pom.xml +++ b/blade-core-social/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.3 + 2.8.0 4.0.0 @@ -25,7 +25,7 @@ me.zhyd.oauth JustAuth - 1.15.6 + 1.15.8 org.apache.httpcomponents diff --git a/blade-core-swagger/pom.xml b/blade-core-swagger/pom.xml index 5a104da..5951fe1 100644 --- a/blade-core-swagger/pom.xml +++ b/blade-core-swagger/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.3 + 2.8.0 4.0.0 diff --git a/blade-core-swagger/src/main/java/org/springblade/core/swagger/EnableSwagger.java b/blade-core-swagger/src/main/java/org/springblade/core/swagger/EnableSwagger.java new file mode 100644 index 0000000..ab12ea7 --- /dev/null +++ b/blade-core-swagger/src/main/java/org/springblade/core/swagger/EnableSwagger.java @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.core.swagger; + +import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; + +import java.lang.annotation.*; + +/** + * Swagger配置开关 + * + * @author Chill + */ +@Documented +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@EnableSwagger2WebMvc +public @interface EnableSwagger { +} diff --git a/blade-core-swagger/src/main/java/org/springblade/core/swagger/SwaggerAutoConfiguration.java b/blade-core-swagger/src/main/java/org/springblade/core/swagger/SwaggerAutoConfiguration.java index 56fc7ce..34dcf05 100644 --- a/blade-core-swagger/src/main/java/org/springblade/core/swagger/SwaggerAutoConfiguration.java +++ b/blade-core-swagger/src/main/java/org/springblade/core/swagger/SwaggerAutoConfiguration.java @@ -16,25 +16,23 @@ package org.springblade.core.swagger; -import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; +import com.google.common.collect.Lists; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import org.springframework.context.annotation.Profile; import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration; import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.PathSelectors; import springfox.documentation.service.*; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.service.contexts.SecurityContext; +import springfox.documentation.spring.web.plugins.ApiSelectorBuilder; import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -44,15 +42,14 @@ import java.util.List; * @author Chill */ @Configuration -@EnableKnife4j -@EnableSwagger2 -@Profile({"dev", "test"}) +@EnableSwagger @EnableConfigurationProperties(SwaggerProperties.class) @Import(BeanValidatorPluginsConfiguration.class) public class SwaggerAutoConfiguration { - private static final String DEFAULT_EXCLUDE_PATH = "/error"; - private static final String BASE_PATH = "/**"; + private static final String DEFAULT_MAPPING_PATH = "/"; + private static final String DEFAULT_BASE_PATH = "/**"; + private static final List DEFAULT_EXCLUDE_PATH = Arrays.asList("/error", "/actuator/**"); @Bean @ConditionalOnMissingBean @@ -64,29 +61,27 @@ public class SwaggerAutoConfiguration { public Docket api(SwaggerProperties swaggerProperties) { // base-path处理 if (swaggerProperties.getBasePath().size() == 0) { - swaggerProperties.getBasePath().add(BASE_PATH); + swaggerProperties.getBasePath().add(DEFAULT_BASE_PATH); } - //noinspection unchecked - List> basePath = new ArrayList(); - swaggerProperties.getBasePath().forEach(path -> basePath.add(PathSelectors.ant(path))); // exclude-path处理 if (swaggerProperties.getExcludePath().size() == 0) { - swaggerProperties.getExcludePath().add(DEFAULT_EXCLUDE_PATH); + swaggerProperties.getExcludePath().addAll(DEFAULT_EXCLUDE_PATH); } - List> excludePath = new ArrayList<>(); - swaggerProperties.getExcludePath().forEach(path -> excludePath.add(PathSelectors.ant(path))); - - //noinspection Guava - return new Docket(DocumentationType.SWAGGER_2) + ApiSelectorBuilder apis = new Docket(DocumentationType.SWAGGER_2) .host(swaggerProperties.getHost()) .apiInfo(apiInfo(swaggerProperties)).select() - .apis(SwaggerUtil.basePackages(swaggerProperties.getBasePackages())) - .paths(Predicates.and(Predicates.not(Predicates.or(excludePath)), Predicates.or(basePath))) - .build() + .apis(SwaggerUtil.basePackages(swaggerProperties.getBasePackages())); + + swaggerProperties.getBasePath().forEach(p -> apis.paths(PathSelectors.ant(p))); + swaggerProperties.getExcludePath().forEach(p -> apis.paths(PathSelectors.ant(p).negate())); + + return apis.build() .securitySchemes(Collections.singletonList(securitySchema())) .securityContexts(Collections.singletonList(securityContext())) - .pathMapping("/"); + .securityContexts(Lists.newArrayList(securityContext())) + .securitySchemes(Collections.singletonList(securitySchema())) + .pathMapping(DEFAULT_MAPPING_PATH); } /** diff --git a/blade-core-swagger/src/main/java/org/springblade/core/swagger/SwaggerLauncherServiceImpl.java b/blade-core-swagger/src/main/java/org/springblade/core/swagger/SwaggerLauncherServiceImpl.java new file mode 100644 index 0000000..667c0bb --- /dev/null +++ b/blade-core-swagger/src/main/java/org/springblade/core/swagger/SwaggerLauncherServiceImpl.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springblade.core.swagger; + +import org.springblade.core.launch.constant.AppConstant; +import org.springblade.core.launch.service.LauncherService; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.core.Ordered; + +import java.util.Properties; + +/** + * 初始化Swagger配置 + * + * @author Chill + */ +public class SwaggerLauncherServiceImpl implements LauncherService { + @Override + public void launcher(SpringApplicationBuilder builder, String appName, String profile) { + Properties props = System.getProperties(); + if (profile.equals(AppConstant.PROD_CODE)) { + props.setProperty("knife4j.production", "true"); + } + } + + @Override + public int getOrder() { + return Ordered.LOWEST_PRECEDENCE; + } +} 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 1525640..b53eeb1 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 = "2.7.3"; + private String version = "2.8.0"; /** * 许可证 **/ diff --git a/blade-core-swagger/src/main/java/org/springblade/core/swagger/SwaggerUtil.java b/blade-core-swagger/src/main/java/org/springblade/core/swagger/SwaggerUtil.java index ac32be3..a6a0aae 100644 --- a/blade-core-swagger/src/main/java/org/springblade/core/swagger/SwaggerUtil.java +++ b/blade-core-swagger/src/main/java/org/springblade/core/swagger/SwaggerUtil.java @@ -17,10 +17,10 @@ package org.springblade.core.swagger; import com.google.common.base.Function; import com.google.common.base.Optional; -import com.google.common.base.Predicate; import springfox.documentation.RequestHandler; import java.util.List; +import java.util.function.Predicate; /** * Swagger工具类 diff --git a/blade-core-swagger/src/main/resources/META-INF/services/org.springblade.core.launch.service.LauncherService b/blade-core-swagger/src/main/resources/META-INF/services/org.springblade.core.launch.service.LauncherService new file mode 100644 index 0000000..03ce0b3 --- /dev/null +++ b/blade-core-swagger/src/main/resources/META-INF/services/org.springblade.core.launch.service.LauncherService @@ -0,0 +1 @@ +org.springblade.core.swagger.SwaggerLauncherServiceImpl diff --git a/blade-core-test/pom.xml b/blade-core-test/pom.xml index d0ef651..3c4b8ca 100644 --- a/blade-core-test/pom.xml +++ b/blade-core-test/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.7.3 + 2.8.0 4.0.0 diff --git a/blade-core-tool/pom.xml b/blade-core-tool/pom.xml index 2f9e51a..90f8d10 100644 --- a/blade-core-tool/pom.xml +++ b/blade-core-tool/pom.xml @@ -6,7 +6,7 @@ org.springblade blade-tool - 2.7.3 + 2.8.0 4.0.0 @@ -31,7 +31,7 @@ com.google.guava guava - 26.0-jre + 30.0-jre diff --git a/blade-core-transaction/pom.xml b/blade-core-transaction/pom.xml index a535c21..1ee758c 100644 --- a/blade-core-transaction/pom.xml +++ b/blade-core-transaction/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.7.3 + 2.8.0 4.0.0 diff --git a/pom.xml b/pom.xml index 66061a9..a610c2d 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.7.3 + 2.8.0 pom blade-tool @@ -36,22 +36,23 @@ - 2.7.3 + 2.8.0 1.8 3.8.0 - 2.9.2 - 1.5.21 - 2.0.4 + 2.10.5 + 1.6.2 + 2.0.6 3.4.0 1.6.0 3.4.2 2.3.0 1.2.5 - 2.2.1.RELEASE + 2.2.3.RELEASE 1.3.0 + 2.0.0.RELEASE - 2.2.9.RELEASE + 2.2.11.RELEASE Hoxton.SR8 Cairo-SR8 @@ -73,10 +74,21 @@ blade-core-tool blade-core-oss blade-core-transaction + blade-core-report + + org.springframework.plugin + spring-plugin-core + ${spring.plugin.version} + + + org.springframework.plugin + spring-plugin-metadata + ${spring.plugin.version} + org.springframework.boot spring-boot-dependencies From 231fbd653fa30e6cd96ae0c97a2ea8e71a4d672a Mon Sep 17 00:00:00 2001 From: smallchill Date: Fri, 6 Nov 2020 17:14:22 +0800 Subject: [PATCH 27/27] =?UTF-8?q?:tada:=202.8.0.RELEASE=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=9C=A8=E7=BA=BF=E6=8A=A5=E8=A1=A8=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blade-core-boot/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blade-core-boot/pom.xml b/blade-core-boot/pom.xml index fe34379..2f8dd02 100644 --- a/blade-core-boot/pom.xml +++ b/blade-core-boot/pom.xml @@ -88,7 +88,7 @@ com.alibaba druid-spring-boot-starter - 1.2.1 + 1.1.22