From 1b7f4121d337b24ccc963d459e1db43cec518822 Mon Sep 17 00:00:00 2001 From: smallchill Date: Thu, 16 May 2019 23:41:32 +0800 Subject: [PATCH] :tada: 2.3.1.RELEASE --- blade-core-boot/pom.xml | 2 +- .../core/boot/tenant/BladeTenantHandler.java | 3 +- .../core/boot/tenant/TenantConstant.java | 30 ++++++++++++++++ .../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 +- .../springblade/core/mp/base/BaseEntity.java | 8 ----- .../core/mp/base/BaseServiceImpl.java | 10 +++--- blade-core-secure/pom.xml | 2 +- blade-core-swagger/pom.xml | 2 +- .../core/swagger/SwaggerProperties.java | 2 +- blade-core-tool/pom.xml | 2 +- .../tool/config/MessageConfiguration.java | 5 ++- .../core/tool/config/ToolConfiguration.java | 3 ++ .../core/tool/support/xss/XssFilter.java | 17 +++++---- .../core/tool/support/xss/XssProperties.java | 35 +++++++++++++++++++ pom.xml | 6 ++-- 21 files changed, 104 insertions(+), 37 deletions(-) create mode 100644 blade-core-boot/src/main/java/org/springblade/core/boot/tenant/TenantConstant.java create mode 100644 blade-core-tool/src/main/java/org/springblade/core/tool/support/xss/XssProperties.java diff --git a/blade-core-boot/pom.xml b/blade-core-boot/pom.xml index d2eb66e..7e6d247 100644 --- a/blade-core-boot/pom.xml +++ b/blade-core-boot/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.3.0 + 2.3.1 4.0.0 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 be87868..6d3c2e1 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 @@ -21,6 +21,7 @@ import lombok.extern.slf4j.Slf4j; import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.StringValue; import org.springblade.core.secure.utils.SecureUtil; +import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; /** @@ -41,7 +42,7 @@ public class BladeTenantHandler implements TenantHandler { */ @Override public Expression getTenantId() { - return new StringValue(SecureUtil.getTenantCode()); + return new StringValue(Func.toStr(SecureUtil.getTenantCode(), TenantConstant.DEFAULT_TENANT_CODE)); } /** diff --git a/blade-core-boot/src/main/java/org/springblade/core/boot/tenant/TenantConstant.java b/blade-core-boot/src/main/java/org/springblade/core/boot/tenant/TenantConstant.java new file mode 100644 index 0000000..9b6b4ef --- /dev/null +++ b/blade-core-boot/src/main/java/org/springblade/core/boot/tenant/TenantConstant.java @@ -0,0 +1,30 @@ +/** + * 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.boot.tenant; + +/** + * 租户常量. + * + * @author zhuangqian + */ +public interface TenantConstant { + + /** + * 默认租户编号 + */ + String DEFAULT_TENANT_CODE = "000000"; + +} diff --git a/blade-core-boot/src/main/resources/bootstrap.yml b/blade-core-boot/src/main/resources/bootstrap.yml index d990529..d36c5be 100644 --- a/blade-core-boot/src/main/resources/bootstrap.yml +++ b/blade-core-boot/src/main/resources/bootstrap.yml @@ -75,7 +75,7 @@ mybatis-plus: swagger: title: SpringBlade 接口文档系统 description: SpringBlade 接口文档系统 - version: 2.3.0 + version: 2.3.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 7f4d042..e214e93 100644 --- a/blade-core-cloud/pom.xml +++ b/blade-core-cloud/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.3.0 + 2.3.1 4.0.0 diff --git a/blade-core-develop/pom.xml b/blade-core-develop/pom.xml index 7642af8..afd7c6d 100644 --- a/blade-core-develop/pom.xml +++ b/blade-core-develop/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.3.0 + 2.3.1 4.0.0 diff --git a/blade-core-launch/pom.xml b/blade-core-launch/pom.xml index 1e5619b..710de02 100644 --- a/blade-core-launch/pom.xml +++ b/blade-core-launch/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.3.0 + 2.3.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 db8f541..6bedb89 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.3.0"; + String APPLICATION_VERSION = "2.3.1"; /** * 基础包 diff --git a/blade-core-log/pom.xml b/blade-core-log/pom.xml index ca5ee08..5c823a4 100644 --- a/blade-core-log/pom.xml +++ b/blade-core-log/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.3.0 + 2.3.1 4.0.0 diff --git a/blade-core-mybatis/pom.xml b/blade-core-mybatis/pom.xml index e266629..f9fd71d 100644 --- a/blade-core-mybatis/pom.xml +++ b/blade-core-mybatis/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.3.0 + 2.3.1 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 88d3787..ced5140 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 @@ -16,8 +16,6 @@ package org.springblade.core.mp.base; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; @@ -35,12 +33,6 @@ import java.time.LocalDateTime; */ @Data public class BaseEntity implements Serializable { - /** - * 主键id - */ - @TableId(value = "id", type = IdType.AUTO) - @ApiModelProperty(value = "主键id") - private Integer id; /** * 创建人 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 9c93ecc..c800070 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 @@ -16,7 +16,6 @@ package org.springblade.core.mp.base; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springblade.core.secure.BladeUser; import org.springblade.core.secure.utils.SecureUtil; @@ -29,6 +28,7 @@ import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.time.LocalDateTime; import java.util.List; +import java.util.Objects; /** * 业务封装基础类 @@ -52,7 +52,7 @@ public class BaseServiceImpl, T extends BaseEntity> exte public boolean save(T entity) { BladeUser user = SecureUtil.getUser(); LocalDateTime now = LocalDateTime.now(); - entity.setCreateUser(user.getUserId()); + entity.setCreateUser(Objects.requireNonNull(user).getUserId()); entity.setCreateTime(now); entity.setUpdateUser(user.getUserId()); entity.setUpdateTime(now); @@ -64,7 +64,7 @@ public class BaseServiceImpl, T extends BaseEntity> exte @Override public boolean updateById(T entity) { BladeUser user = SecureUtil.getUser(); - entity.setUpdateUser(user.getUserId()); + entity.setUpdateUser(Objects.requireNonNull(user).getUserId()); entity.setUpdateTime(LocalDateTime.now()); return super.updateById(entity); } @@ -73,9 +73,9 @@ public class BaseServiceImpl, T extends BaseEntity> exte public boolean deleteLogic(@NotEmpty List ids) { BladeUser user = SecureUtil.getUser(); T entity = BeanUtil.newInstance(modelClass); - entity.setUpdateUser(user.getUserId()); + entity.setUpdateUser(Objects.requireNonNull(user).getUserId()); entity.setUpdateTime(LocalDateTime.now()); - return super.update(entity, Wrappers.update().lambda().in(T::getId, ids)) && super.removeByIds(ids); + return super.removeByIds(ids); } } diff --git a/blade-core-secure/pom.xml b/blade-core-secure/pom.xml index 33d4c19..890e82d 100644 --- a/blade-core-secure/pom.xml +++ b/blade-core-secure/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.3.0 + 2.3.1 4.0.0 diff --git a/blade-core-swagger/pom.xml b/blade-core-swagger/pom.xml index a4121ba..71fc968 100644 --- a/blade-core-swagger/pom.xml +++ b/blade-core-swagger/pom.xml @@ -5,7 +5,7 @@ blade-tool org.springblade - 2.3.0 + 2.3.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 c2f76a4..7e5dbf5 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 @@ -53,7 +53,7 @@ public class SwaggerProperties { /** * 版本 **/ - private String version = "2.3.0"; + private String version = "2.3.1"; /** * 许可证 **/ diff --git a/blade-core-tool/pom.xml b/blade-core-tool/pom.xml index 2941660..b3d42a7 100644 --- a/blade-core-tool/pom.xml +++ b/blade-core-tool/pom.xml @@ -6,7 +6,7 @@ org.springblade blade-tool - 2.3.0 + 2.3.1 4.0.0 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 18d187d..acb4fdb 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 @@ -20,6 +20,7 @@ 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; @@ -45,6 +46,8 @@ public class MessageConfiguration implements WebMvcConfigurer { private final ObjectMapper objectMapper; + private final XssProperties xssProperties; + /** * 使用 JACKSON 作为JSON MessageConverter */ @@ -67,7 +70,7 @@ public class MessageConfiguration implements WebMvcConfigurer { public FilterRegistrationBean xssFilterRegistration() { FilterRegistrationBean registration = new FilterRegistrationBean(); registration.setDispatcherTypes(DispatcherType.REQUEST); - registration.setFilter(new XssFilter()); + registration.setFilter(new XssFilter(xssProperties)); registration.addUrlPatterns("/*"); registration.setName("xssFilter"); registration.setOrder(Ordered.LOWEST_PRECEDENCE); 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..7994b4f 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,7 +16,9 @@ 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; @@ -30,6 +32,7 @@ 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/support/xss/XssFilter.java b/blade-core-tool/src/main/java/org/springblade/core/tool/support/xss/XssFilter.java index a842223..e94fa3e 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 @@ -15,6 +15,8 @@ */ package org.springblade.core.tool.support.xss; +import lombok.AllArgsConstructor; + import javax.servlet.*; import javax.servlet.http.HttpServletRequest; import java.io.IOException; @@ -24,23 +26,24 @@ import java.io.IOException; * * @author Chill */ +@AllArgsConstructor public class XssFilter implements Filter { + private XssProperties xssProperties; + @Override - public void init(FilterConfig config) throws ServletException { + public void init(FilterConfig config) { } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { - ServletRequest requestWrapper = null; - if (request instanceof HttpServletRequest) { - requestWrapper = new XssHttpServletRequestWrapper((HttpServletRequest) request); - } - if (requestWrapper == null) { + String path = ((HttpServletRequest) request).getServletPath(); + if (xssProperties.getExcludePatterns().stream().anyMatch(path::contains)) { chain.doFilter(request, response); } else { - chain.doFilter(requestWrapper, response); + XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper((HttpServletRequest) request); + chain.doFilter(xssRequest, response); } } 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 new file mode 100644 index 0000000..3535e8e --- /dev/null +++ b/blade-core-tool/src/main/java/org/springblade/core/tool/support/xss/XssProperties.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 XssProperties { + + private final List excludePatterns = new ArrayList<>(); + +} diff --git a/pom.xml b/pom.xml index 974e98f..4b4253e 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springblade blade-tool - 2.3.0 + 2.3.1 pom blade-tool @@ -36,7 +36,7 @@ - 2.3.0 + 2.3.1 1.8 3.8.0 @@ -51,7 +51,7 @@ 1.0.1 0.9.0.RELEASE - 2.1.4.RELEASE + 2.1.5.RELEASE Greenwich.SR1 Cairo-SR7