From cd04e833902ee4bacf21eb26e815b64df13e0bdf Mon Sep 17 00:00:00 2001 From: smallchill Date: Sat, 18 Jan 2025 18:19:14 +0800 Subject: [PATCH] =?UTF-8?q?:tada:=204.4.0.RELEASE=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E9=BB=91=E7=99=BD=E5=90=8D=E5=8D=95=E3=80=81=E8=84=B1=E6=95=8F?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E3=80=81BladeRedis=E6=96=B0=E7=89=88?= =?UTF-8?q?=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +- blade-auth/pom.xml | 4 ++ .../auth/controller/AuthController.java | 6 +- .../auth/granter/CaptchaTokenGranter.java | 5 +- .../core/log/controller/LogApiController.java | 23 +++----- .../log/controller/LogErrorController.java | 25 +++----- .../log/controller/LogUsualController.java | 23 +++----- .../springblade/core/log/pojo/LogApiVO.java | 44 ++++++++++++++ .../springblade/core/log/pojo/LogErrorVO.java | 54 +++++++++++++++++ .../springblade/core/log/pojo/LogUsualVO.java | 48 +++++++++++++++ .../core/log/pojo/package-info.java | 6 ++ .../core/log/wrapper/LogApiWrapper.java | 52 ++++++++++++++++ .../core/log/wrapper/LogErrorWrapper.java | 59 +++++++++++++++++++ .../core/log/wrapper/LogUsualWrapper.java | 56 ++++++++++++++++++ doc/nacos/blade.yaml | 10 ++-- pom.xml | 6 +- script/docker/.env | 2 +- script/kuboard/kuboard_spring-blade.yaml | 24 ++++---- 18 files changed, 376 insertions(+), 77 deletions(-) create mode 100644 blade-service/blade-log/src/main/java/org/springblade/core/log/pojo/LogApiVO.java create mode 100644 blade-service/blade-log/src/main/java/org/springblade/core/log/pojo/LogErrorVO.java create mode 100644 blade-service/blade-log/src/main/java/org/springblade/core/log/pojo/LogUsualVO.java create mode 100644 blade-service/blade-log/src/main/java/org/springblade/core/log/pojo/package-info.java create mode 100644 blade-service/blade-log/src/main/java/org/springblade/core/log/wrapper/LogApiWrapper.java create mode 100644 blade-service/blade-log/src/main/java/org/springblade/core/log/wrapper/LogErrorWrapper.java create mode 100644 blade-service/blade-log/src/main/java/org/springblade/core/log/wrapper/LogUsualWrapper.java diff --git a/README.md b/README.md index c52aa5df..0d316b62 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

- Downloads + Downloads Build Status Build Status Coverage Status @@ -33,8 +33,8 @@ |----------------------|------------| | Java | 17+ | | NodeJS | 18+ | -| Spring | 6.1.14 | -| Spring Boot | 3.2.10 | +| Spring | 6.1.15 | +| Spring Boot | 3.2.12 | | Spring Cloud | 2023.0.3 | | Spring Cloud Alibaba | 2023.0.1.2 | | Nacos Alibaba | 2.3.2 | diff --git a/blade-auth/pom.xml b/blade-auth/pom.xml index 110fb317..0bffcb6a 100644 --- a/blade-auth/pom.xml +++ b/blade-auth/pom.xml @@ -37,6 +37,10 @@ org.springblade blade-starter-social + + org.springblade + blade-starter-redis + org.springblade blade-user-api diff --git a/blade-auth/src/main/java/org/springblade/auth/controller/AuthController.java b/blade-auth/src/main/java/org/springblade/auth/controller/AuthController.java index e932edf9..6c0a7aa6 100644 --- a/blade-auth/src/main/java/org/springblade/auth/controller/AuthController.java +++ b/blade-auth/src/main/java/org/springblade/auth/controller/AuthController.java @@ -25,11 +25,11 @@ import org.springblade.auth.granter.TokenParameter; import org.springblade.auth.utils.TokenUtil; import org.springblade.common.cache.CacheNames; +import org.springblade.core.redis.cache.BladeRedis; import org.springblade.core.secure.AuthInfo; import org.springblade.core.tool.api.R; import org.springblade.core.tool.support.Kv; import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.RedisUtil; import org.springblade.core.tool.utils.WebUtil; import org.springblade.system.user.entity.UserInfo; import org.springframework.web.bind.annotation.GetMapping; @@ -50,7 +50,7 @@ @Tag(name = "用户授权认证", description = "授权接口") public class AuthController { - private RedisUtil redisUtil; + private BladeRedis bladeRedis; @PostMapping("token") @Operation(summary = "获取认证token", description = "传入租户ID:tenantId,账号:account,密码:password") @@ -87,7 +87,7 @@ public R captcha() { String verCode = specCaptcha.text().toLowerCase(); String key = UUID.randomUUID().toString(); // 存入redis并设置过期时间为30分钟 - redisUtil.set(CacheNames.CAPTCHA_KEY + key, verCode, 30L, TimeUnit.MINUTES); + bladeRedis.setEx(CacheNames.CAPTCHA_KEY + key, verCode, 30L, TimeUnit.MINUTES); // 将key和base64返回给前端 return R.data(Kv.init().set("key", key).set("image", specCaptcha.toBase64())); } diff --git a/blade-auth/src/main/java/org/springblade/auth/granter/CaptchaTokenGranter.java b/blade-auth/src/main/java/org/springblade/auth/granter/CaptchaTokenGranter.java index 3f77c258..4bcadba5 100644 --- a/blade-auth/src/main/java/org/springblade/auth/granter/CaptchaTokenGranter.java +++ b/blade-auth/src/main/java/org/springblade/auth/granter/CaptchaTokenGranter.java @@ -20,6 +20,7 @@ import org.springblade.auth.utils.TokenUtil; import org.springblade.common.cache.CacheNames; import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.redis.cache.BladeRedis; import org.springblade.core.secure.props.BladeAuthProperties; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.*; @@ -41,7 +42,7 @@ public class CaptchaTokenGranter implements ITokenGranter { public static final String GRANT_TYPE = "captcha"; private IUserClient userClient; - private RedisUtil redisUtil; + private BladeRedis bladeRedis; private BladeAuthProperties authProperties; @@ -52,7 +53,7 @@ public UserInfo grant(TokenParameter tokenParameter) { String key = request.getHeader(TokenUtil.CAPTCHA_HEADER_KEY); String code = request.getHeader(TokenUtil.CAPTCHA_HEADER_CODE); // 获取验证码 - String redisCode = String.valueOf(redisUtil.get(CacheNames.CAPTCHA_KEY + key)); + String redisCode = Func.toStr(bladeRedis.get(CacheNames.CAPTCHA_KEY + key)); // 判断验证码 if (code == null || !StringUtil.equalsIgnoreCase(redisCode, code)) { throw new ServiceException(TokenUtil.CAPTCHA_NOT_CORRECT); diff --git a/blade-service/blade-log/src/main/java/org/springblade/core/log/controller/LogApiController.java b/blade-service/blade-log/src/main/java/org/springblade/core/log/controller/LogApiController.java index 692dd3fe..e0a019c9 100644 --- a/blade-service/blade-log/src/main/java/org/springblade/core/log/controller/LogApiController.java +++ b/blade-service/blade-log/src/main/java/org/springblade/core/log/controller/LogApiController.java @@ -17,29 +17,25 @@ import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.Parameter; import lombok.AllArgsConstructor; import org.springblade.core.log.model.LogApi; -import org.springblade.core.log.model.LogApiVo; +import org.springblade.core.log.pojo.LogApiVO; import org.springblade.core.log.service.ILogApiService; +import org.springblade.core.log.wrapper.LogApiWrapper; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.secure.annotation.PreAuth; import org.springblade.core.tool.api.R; import org.springblade.core.tool.constant.RoleConstant; -import org.springblade.core.tool.utils.BeanUtil; -import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringPool; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import java.util.List; import java.util.Map; -import java.util.stream.Collectors; /** * 控制器 @@ -59,8 +55,10 @@ public class LogApiController { * 查询单条 */ @GetMapping("/detail") + @PreAuth(RoleConstant.HAS_ROLE_ADMIN) public R detail(LogApi log) { - return R.data(logService.getOne(Condition.getQueryWrapper(log))); + LogApi logApi = logService.getOne(Condition.getQueryWrapper(log)); + return R.data(LogApiWrapper.build().entity(logApi)); } /** @@ -68,18 +66,11 @@ public R detail(LogApi log) { */ @GetMapping("/list") @PreAuth(RoleConstant.HAS_ROLE_ADMIN) - public R> list(@Parameter(hidden = true) @RequestParam Map log, Query query) { + public R> list(@Parameter(hidden = true) @RequestParam Map log, Query query) { query.setAscs("create_time"); query.setDescs(StringPool.EMPTY); IPage pages = logService.page(Condition.getPage(query), Condition.getQueryWrapper(log, LogApi.class)); - List records = pages.getRecords().stream().map(logApi -> { - LogApiVo vo = BeanUtil.copyProperties(logApi, LogApiVo.class); - vo.setStrId(Func.toStr(logApi.getId())); - return vo; - }).collect(Collectors.toList()); - IPage pageVo = new Page<>(pages.getCurrent(), pages.getSize(), pages.getTotal()); - pageVo.setRecords(records); - return R.data(pageVo); + return R.data(LogApiWrapper.build().pageVO(pages)); } } diff --git a/blade-service/blade-log/src/main/java/org/springblade/core/log/controller/LogErrorController.java b/blade-service/blade-log/src/main/java/org/springblade/core/log/controller/LogErrorController.java index 255b312f..b35ffd9a 100644 --- a/blade-service/blade-log/src/main/java/org/springblade/core/log/controller/LogErrorController.java +++ b/blade-service/blade-log/src/main/java/org/springblade/core/log/controller/LogErrorController.java @@ -17,29 +17,25 @@ import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.Parameter; import lombok.AllArgsConstructor; import org.springblade.core.log.model.LogError; -import org.springblade.core.log.model.LogErrorVo; +import org.springblade.core.log.pojo.LogErrorVO; import org.springblade.core.log.service.ILogErrorService; +import org.springblade.core.log.wrapper.LogErrorWrapper; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.secure.annotation.PreAuth; import org.springblade.core.tool.api.R; import org.springblade.core.tool.constant.RoleConstant; -import org.springblade.core.tool.utils.BeanUtil; -import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringPool; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import java.util.List; import java.util.Map; -import java.util.stream.Collectors; /** * 控制器 @@ -59,8 +55,10 @@ public class LogErrorController { * 查询单条 */ @GetMapping("/detail") - public R detail(LogError logError) { - return R.data(errorLogService.getOne(Condition.getQueryWrapper(logError))); + @PreAuth(RoleConstant.HAS_ROLE_ADMIN) + public R detail(LogError log) { + LogError logError = errorLogService.getOne(Condition.getQueryWrapper(log)); + return R.data(LogErrorWrapper.build().entity(logError)); } /** @@ -68,18 +66,11 @@ public R detail(LogError logError) { */ @GetMapping("/list") @PreAuth(RoleConstant.HAS_ROLE_ADMIN) - public R> list(@Parameter(hidden = true) @RequestParam Map logError, Query query) { + public R> list(@Parameter(hidden = true) @RequestParam Map logError, Query query) { query.setAscs("create_time"); query.setDescs(StringPool.EMPTY); IPage pages = errorLogService.page(Condition.getPage(query), Condition.getQueryWrapper(logError, LogError.class)); - List records = pages.getRecords().stream().map(logApi -> { - LogErrorVo vo = BeanUtil.copyProperties(logApi, LogErrorVo.class); - vo.setStrId(Func.toStr(logApi.getId())); - return vo; - }).collect(Collectors.toList()); - IPage pageVo = new Page<>(pages.getCurrent(), pages.getSize(), pages.getTotal()); - pageVo.setRecords(records); - return R.data(pageVo); + return R.data(LogErrorWrapper.build().pageVO(pages)); } } diff --git a/blade-service/blade-log/src/main/java/org/springblade/core/log/controller/LogUsualController.java b/blade-service/blade-log/src/main/java/org/springblade/core/log/controller/LogUsualController.java index a628073d..a0548ad8 100644 --- a/blade-service/blade-log/src/main/java/org/springblade/core/log/controller/LogUsualController.java +++ b/blade-service/blade-log/src/main/java/org/springblade/core/log/controller/LogUsualController.java @@ -17,29 +17,25 @@ import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.Parameter; import lombok.AllArgsConstructor; import org.springblade.core.log.model.LogUsual; -import org.springblade.core.log.model.LogUsualVo; +import org.springblade.core.log.pojo.LogUsualVO; import org.springblade.core.log.service.ILogUsualService; +import org.springblade.core.log.wrapper.LogUsualWrapper; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.secure.annotation.PreAuth; import org.springblade.core.tool.api.R; import org.springblade.core.tool.constant.RoleConstant; -import org.springblade.core.tool.utils.BeanUtil; -import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringPool; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import java.util.List; import java.util.Map; -import java.util.stream.Collectors; /** * 控制器 @@ -59,8 +55,10 @@ public class LogUsualController { * 查询单条 */ @GetMapping("/detail") + @PreAuth(RoleConstant.HAS_ROLE_ADMIN) public R detail(LogUsual log) { - return R.data(logService.getOne(Condition.getQueryWrapper(log))); + LogUsual logUsual = logService.getOne(Condition.getQueryWrapper(log)); + return R.data(LogUsualWrapper.build().entity(logUsual)); } /** @@ -68,18 +66,11 @@ public R detail(LogUsual log) { */ @GetMapping("/list") @PreAuth(RoleConstant.HAS_ROLE_ADMIN) - public R> list(@Parameter(hidden = true) @RequestParam Map log, Query query) { + public R> list(@Parameter(hidden = true) @RequestParam Map log, Query query) { query.setAscs("create_time"); query.setDescs(StringPool.EMPTY); IPage pages = logService.page(Condition.getPage(query), Condition.getQueryWrapper(log, LogUsual.class)); - List records = pages.getRecords().stream().map(logApi -> { - LogUsualVo vo = BeanUtil.copyProperties(logApi, LogUsualVo.class); - vo.setStrId(Func.toStr(logApi.getId())); - return vo; - }).collect(Collectors.toList()); - IPage pageVo = new Page<>(pages.getCurrent(), pages.getSize(), pages.getTotal()); - pageVo.setRecords(records); - return R.data(pageVo); + return R.data(LogUsualWrapper.build().pageVO(pages)); } } diff --git a/blade-service/blade-log/src/main/java/org/springblade/core/log/pojo/LogApiVO.java b/blade-service/blade-log/src/main/java/org/springblade/core/log/pojo/LogApiVO.java new file mode 100644 index 00000000..91fa9fe6 --- /dev/null +++ b/blade-service/blade-log/src/main/java/org/springblade/core/log/pojo/LogApiVO.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com). + *

+ * 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 org.springblade.core.log.pojo; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.log.model.LogApi; + +import java.io.Serial; + +/** + * LogApiVO + * + * @author Chill + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class LogApiVO extends LogApi { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 操作提交的数据 + */ + @JsonIgnore + private String params; + + +} diff --git a/blade-service/blade-log/src/main/java/org/springblade/core/log/pojo/LogErrorVO.java b/blade-service/blade-log/src/main/java/org/springblade/core/log/pojo/LogErrorVO.java new file mode 100644 index 00000000..39ae29ba --- /dev/null +++ b/blade-service/blade-log/src/main/java/org/springblade/core/log/pojo/LogErrorVO.java @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com). + *

+ * 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 org.springblade.core.log.pojo; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.log.model.LogError; + +import java.io.Serial; + +/** + * LogErrorVO + * + * @author Chill + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class LogErrorVO extends LogError { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 操作提交的数据 + */ + @JsonIgnore + private String params; + + /** + * 堆栈信息 + */ + @JsonIgnore + private String stackTrace; + + /** + * 异常消息 + */ + @JsonIgnore + private String message; +} diff --git a/blade-service/blade-log/src/main/java/org/springblade/core/log/pojo/LogUsualVO.java b/blade-service/blade-log/src/main/java/org/springblade/core/log/pojo/LogUsualVO.java new file mode 100644 index 00000000..5bc2b164 --- /dev/null +++ b/blade-service/blade-log/src/main/java/org/springblade/core/log/pojo/LogUsualVO.java @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com). + *

+ * 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 org.springblade.core.log.pojo; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.log.model.LogUsual; + +import java.io.Serial; + +/** + * LogUsualVO + * + * @author Chill + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class LogUsualVO extends LogUsual { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 操作提交的数据 + */ + @JsonIgnore + private String params; + + /** + * 日志数据 + */ + @JsonIgnore + private String logData; +} diff --git a/blade-service/blade-log/src/main/java/org/springblade/core/log/pojo/package-info.java b/blade-service/blade-log/src/main/java/org/springblade/core/log/pojo/package-info.java new file mode 100644 index 00000000..1340f814 --- /dev/null +++ b/blade-service/blade-log/src/main/java/org/springblade/core/log/pojo/package-info.java @@ -0,0 +1,6 @@ +/** + * Created by Blade. + * + * @author zhuangqian + */ +package org.springblade.core.log.pojo; diff --git a/blade-service/blade-log/src/main/java/org/springblade/core/log/wrapper/LogApiWrapper.java b/blade-service/blade-log/src/main/java/org/springblade/core/log/wrapper/LogApiWrapper.java new file mode 100644 index 00000000..0259fd27 --- /dev/null +++ b/blade-service/blade-log/src/main/java/org/springblade/core/log/wrapper/LogApiWrapper.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com). + *

+ * 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 org.springblade.core.log.wrapper; + +import org.springblade.core.log.model.LogApi; +import org.springblade.core.log.pojo.LogApiVO; +import org.springblade.core.mp.support.BaseEntityWrapper; +import org.springblade.core.tool.sensitive.SensitiveUtil; +import org.springblade.core.tool.sensitive.SensitiveWord; +import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.core.tool.utils.StringUtil; + +import java.util.Objects; + +/** + * Log包装类,返回视图层所需的字段 + * + * @author Chill + */ +public class LogApiWrapper extends BaseEntityWrapper { + + public static LogApiWrapper build() { + return new LogApiWrapper(); + } + + @Override + public LogApiVO entityVO(LogApi logApi) { + return Objects.requireNonNull(BeanUtil.copyProperties(logApi, LogApiVO.class)); + } + + public LogApi entity(LogApi logApi) { + String params = logApi.getParams(); + if (StringUtil.isNotBlank(params)) { + logApi.setParams(SensitiveUtil.processWithWords(params, SensitiveWord.SECURE.getWords())); + } + return logApi; + } + +} diff --git a/blade-service/blade-log/src/main/java/org/springblade/core/log/wrapper/LogErrorWrapper.java b/blade-service/blade-log/src/main/java/org/springblade/core/log/wrapper/LogErrorWrapper.java new file mode 100644 index 00000000..c75485dc --- /dev/null +++ b/blade-service/blade-log/src/main/java/org/springblade/core/log/wrapper/LogErrorWrapper.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com). + *

+ * 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 org.springblade.core.log.wrapper; + +import org.springblade.core.log.model.LogError; +import org.springblade.core.log.pojo.LogErrorVO; +import org.springblade.core.mp.support.BaseEntityWrapper; +import org.springblade.core.tool.sensitive.SensitiveUtil; +import org.springblade.core.tool.sensitive.SensitiveWord; +import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.core.tool.utils.StringUtil; + +import java.util.Objects; + +/** + * Log包装类,返回视图层所需的字段 + * + * @author Chill + */ +public class LogErrorWrapper extends BaseEntityWrapper { + + public static LogErrorWrapper build() { + return new LogErrorWrapper(); + } + + @Override + public LogErrorVO entityVO(LogError logError) { + return Objects.requireNonNull(BeanUtil.copyProperties(logError, LogErrorVO.class)); + } + + public LogError entity(LogError logError) { + String params = logError.getParams(); + String stackTrace = logError.getStackTrace(); + String message = logError.getMessage(); + if (StringUtil.isNotBlank(params)) { + logError.setParams(SensitiveUtil.processWithWords(params, SensitiveWord.SECURE.getWords())); + } + if (StringUtil.isNotBlank(stackTrace)) { + logError.setStackTrace(SensitiveUtil.processWithWords(stackTrace, SensitiveWord.SECURE.getWords())); + } + if (StringUtil.isNotBlank(message)) { + logError.setMessage(SensitiveUtil.processWithWords(message, SensitiveWord.SECURE.getWords())); + } + return logError; + } +} diff --git a/blade-service/blade-log/src/main/java/org/springblade/core/log/wrapper/LogUsualWrapper.java b/blade-service/blade-log/src/main/java/org/springblade/core/log/wrapper/LogUsualWrapper.java new file mode 100644 index 00000000..aa5e7297 --- /dev/null +++ b/blade-service/blade-log/src/main/java/org/springblade/core/log/wrapper/LogUsualWrapper.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com). + *

+ * 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 org.springblade.core.log.wrapper; + +import org.springblade.core.log.model.LogUsual; +import org.springblade.core.log.pojo.LogUsualVO; +import org.springblade.core.mp.support.BaseEntityWrapper; +import org.springblade.core.tool.sensitive.SensitiveUtil; +import org.springblade.core.tool.sensitive.SensitiveWord; +import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.core.tool.utils.StringUtil; + +import java.util.Objects; + +/** + * Log包装类,返回视图层所需的字段 + * + * @author Chill + */ +public class LogUsualWrapper extends BaseEntityWrapper { + + public static LogUsualWrapper build() { + return new LogUsualWrapper(); + } + + @Override + public LogUsualVO entityVO(LogUsual logUsual) { + return Objects.requireNonNull(BeanUtil.copyProperties(logUsual, LogUsualVO.class)); + } + + public LogUsual entity(LogUsual logUsual) { + String params = logUsual.getParams(); + String logData = logUsual.getLogData(); + if (StringUtil.isNotBlank(params)) { + logUsual.setParams(SensitiveUtil.processWithWords(params, SensitiveWord.SECURE.getWords())); + } + if (StringUtil.isNotBlank(logData)) { + logUsual.setLogData(SensitiveUtil.processWithWords(logData, SensitiveWord.SECURE.getWords())); + } + return logUsual; + } + +} diff --git a/doc/nacos/blade.yaml b/doc/nacos/blade.yaml index a2f88a1b..67a7376a 100644 --- a/doc/nacos/blade.yaml +++ b/doc/nacos/blade.yaml @@ -73,7 +73,7 @@ knife4j: swagger: title: SpringBlade 接口文档系统 description: SpringBlade 接口文档系统 - version: 4.3.0 + version: 4.4.0 license: Powered By SpringBlade licenseUrl: https://bladex.cn terms-of-service-url: https://bladex.cn @@ -86,14 +86,14 @@ swagger: blade: auth: #使用 @org.springblade.test.Sm2KeyGenerator 获取,用于国密sm2验签,需和前端保持一致 - public-key: 请配置sm2公钥 + public-key: ${BLADE_OAUTH2_PUBLIC_KEY} #使用 @org.springblade.test.Sm2KeyGenerator 获取,用于国密sm2解密,前端无需配置 - private-key: 请配置sm2私钥 + private-key: ${BLADE_OAUTH2_PRIVATE_KEY} token: #使用 @org.springblade.test.SignKeyGenerator 获取 - sign-key: 请配置32位签名 + sign-key: ${BLADE_TOKEN_SIGN_KEY} #使用 @org.springblade.test.SignKeyGenerator 获取 - aes-key: 请配置cryptoKey + aes-key: ${BLADE_TOKEN_CRYPTO_KEY} xss: enabled: true skip-url: diff --git a/pom.xml b/pom.xml index 1dd4ac98..80fefb8b 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,9 @@ pom - 4.3.0 + 4.4.0 + + 4.4.2 17 3.11.0 @@ -41,7 +43,7 @@ org.springblade blade-core-bom - ${revision} + ${blade.tool.version} pom import diff --git a/script/docker/.env b/script/docker/.env index 616e36bd..caee97d1 100644 --- a/script/docker/.env +++ b/script/docker/.env @@ -1,2 +1,2 @@ REGISTER=192.168.0.157/blade -TAG=4.3.0 +TAG=4.4.0 diff --git a/script/kuboard/kuboard_spring-blade.yaml b/script/kuboard/kuboard_spring-blade.yaml index a96ae527..bc978373 100644 --- a/script/kuboard/kuboard_spring-blade.yaml +++ b/script/kuboard/kuboard_spring-blade.yaml @@ -152,7 +152,7 @@ spec: spec: containers: - name: blade-admin - image: 'swr.cn-east-2.myhuaweicloud.com/blade/blade-admin:4.3.0' + image: 'swr.cn-east-2.myhuaweicloud.com/blade/blade-admin:4.4.0' args: - '--spring.profiles.active=${PROFILE}' - '--spring.cloud.nacos.config.server-addr=${NACOS_SERVER_ADDR}' @@ -386,7 +386,7 @@ spec: spec: containers: - name: blade-auth - image: 'swr.cn-east-2.myhuaweicloud.com/blade/blade-auth:4.3.0' + image: 'swr.cn-east-2.myhuaweicloud.com/blade/blade-auth:4.4.0' args: - '--spring.profiles.active=${PROFILE}' - '--spring.cloud.nacos.config.server-addr=${NACOS_SERVER_ADDR}' @@ -625,7 +625,7 @@ spec: spec: containers: - name: blade-desk - image: 'swr.cn-east-2.myhuaweicloud.com/blade/blade-desk:4.3.0' + image: 'swr.cn-east-2.myhuaweicloud.com/blade/blade-desk:4.4.0' args: - '--spring.profiles.active=${PROFILE}' - '--spring.cloud.nacos.config.server-addr=${NACOS_SERVER_ADDR}' @@ -864,7 +864,7 @@ spec: spec: containers: - name: blade-develop - image: 'swr.cn-east-2.myhuaweicloud.com/blade/blade-develop:4.3.0' + image: 'swr.cn-east-2.myhuaweicloud.com/blade/blade-develop:4.4.0' args: - '--spring.profiles.active=${PROFILE}' - '--spring.cloud.nacos.config.server-addr=${NACOS_SERVER_ADDR}' @@ -1096,7 +1096,7 @@ spec: spec: containers: - name: blade-gateway - image: 'swr.cn-east-2.myhuaweicloud.com/blade/blade-gateway:4.3.0' + image: 'swr.cn-east-2.myhuaweicloud.com/blade/blade-gateway:4.4.0' args: - '--spring.profiles.active=${PROFILE}' - '--spring.cloud.nacos.config.server-addr=${NACOS_SERVER_ADDR}' @@ -1331,7 +1331,7 @@ spec: spec: containers: - name: blade-log - image: 'swr.cn-east-2.myhuaweicloud.com/blade/blade-log:4.3.0' + image: 'swr.cn-east-2.myhuaweicloud.com/blade/blade-log:4.4.0' args: - '--spring.profiles.active=${PROFILE}' - '--spring.cloud.nacos.config.server-addr=${NACOS_SERVER_ADDR}' @@ -1565,7 +1565,7 @@ spec: spec: containers: - name: blade-report - image: 'swr.cn-east-2.myhuaweicloud.com/blade/blade-report:4.3.0' + image: 'swr.cn-east-2.myhuaweicloud.com/blade/blade-report:4.4.0' args: - '--spring.profiles.active=${PROFILE}' - '--spring.cloud.nacos.config.server-addr=${NACOS_SERVER_ADDR}' @@ -1799,7 +1799,7 @@ spec: spec: containers: - name: blade-resource - image: 'swr.cn-east-2.myhuaweicloud.com/blade/blade-resource:4.3.0' + image: 'swr.cn-east-2.myhuaweicloud.com/blade/blade-resource:4.4.0' args: - '--spring.profiles.active=${PROFILE}' - '--spring.cloud.nacos.config.server-addr=${NACOS_SERVER_ADDR}' @@ -2033,7 +2033,7 @@ spec: spec: containers: - name: blade-system - image: 'swr.cn-east-2.myhuaweicloud.com/blade/blade-system:4.3.0' + image: 'swr.cn-east-2.myhuaweicloud.com/blade/blade-system:4.4.0' args: - '--spring.profiles.active=${PROFILE}' - '--spring.cloud.nacos.config.server-addr=${NACOS_SERVER_ADDR}' @@ -2262,7 +2262,7 @@ spec: spec: containers: - name: saber-web - image: 'swr.cn-east-2.myhuaweicloud.com/blade/saber-web:4.3.0' + image: 'swr.cn-east-2.myhuaweicloud.com/blade/saber-web:4.4.0' ports: - name: web containerPort: 80 @@ -2487,7 +2487,7 @@ spec: spec: containers: - name: blade-swagger - image: 'swr.cn-east-2.myhuaweicloud.com/blade/blade-swagger:4.3.0' + image: 'swr.cn-east-2.myhuaweicloud.com/blade/blade-swagger:4.4.0' args: - '--spring.profiles.active=${PROFILE}' - '--spring.cloud.nacos.config.server-addr=${NACOS_SERVER_ADDR}' @@ -3515,7 +3515,7 @@ spec: spec: containers: - name: mysql - image: 'swr.cn-east-2.myhuaweicloud.com/blade/saber-db:v4.3.0' + image: 'swr.cn-east-2.myhuaweicloud.com/blade/saber-db:v4.4.0' ports: - name: mysql containerPort: 3306