publish 1.0.6

This commit is contained in:
曾文豪
2023-05-26 13:23:17 +08:00
parent 659deb6132
commit 458d118d85
15 changed files with 52 additions and 29 deletions

View File

@@ -1,8 +1,9 @@
## 1.0.5 ## 1.0.6
### 新增 ### 新增
> 1新增 **OperationIgnore** 注解,可以指定接口忽略操作日志的收集。 > 1新增 **OperationIgnore** 注解,可以指定接口忽略操作日志的收集。
> 2**OperationLog** 增加 desensitize 属性,用来脱敏指定的字段。
## 1.0.2 ## 1.0.2

20
pom.xml
View File

@@ -6,7 +6,7 @@
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>1.0.5</version> <version>1.0.6</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>springboot-parent</name> <name>springboot-parent</name>
<description>杭州铁晟科技有限公司基础依赖</description> <description>杭州铁晟科技有限公司基础依赖</description>
@@ -57,55 +57,55 @@
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-database</artifactId> <artifactId>springboot-database</artifactId>
<version>1.0.5</version> <version>1.0.6</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-login</artifactId> <artifactId>springboot-login</artifactId>
<version>1.0.5</version> <version>1.0.6</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-web</artifactId> <artifactId>springboot-web</artifactId>
<version>1.0.5</version> <version>1.0.6</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-util</artifactId> <artifactId>springboot-util</artifactId>
<version>1.0.5</version> <version>1.0.6</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-platform</artifactId> <artifactId>springboot-platform</artifactId>
<version>1.0.5</version> <version>1.0.6</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-message</artifactId> <artifactId>springboot-message</artifactId>
<version>1.0.5</version> <version>1.0.6</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-encrypt</artifactId> <artifactId>springboot-encrypt</artifactId>
<version>1.0.5</version> <version>1.0.6</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-annotation</artifactId> <artifactId>springboot-annotation</artifactId>
<version>1.0.5</version> <version>1.0.6</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-poi</artifactId> <artifactId>springboot-poi</artifactId>
<version>1.0.5</version> <version>1.0.6</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>1.0.5</version> <version>1.0.6</version>
</parent> </parent>
<artifactId>springboot-ademo</artifactId> <artifactId>springboot-ademo</artifactId>

View File

@@ -8,6 +8,7 @@ import cn.hutool.poi.excel.ExcelUtil;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener; import com.alibaba.excel.read.listener.ReadListener;
import com.tiesheng.annotation.operation.OperationLog;
import com.tiesheng.annotation.token.TokenIgnore; import com.tiesheng.annotation.token.TokenIgnore;
import com.tiesheng.core.service.CoreLogService; import com.tiesheng.core.service.CoreLogService;
import com.tiesheng.core.service.CoreMessageService; import com.tiesheng.core.service.CoreMessageService;
@@ -24,10 +25,13 @@ import com.tiesheng.util.config.Ip2regionConfig;
import com.tiesheng.util.pojos.ApiResp; import com.tiesheng.util.pojos.ApiResp;
import com.tiesheng.util.pojos.FileUploadPath; import com.tiesheng.util.pojos.FileUploadPath;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -88,11 +92,11 @@ public class TestController {
} }
@RequestMapping("/send") @PostMapping("/send")
@TokenIgnore @OperationLog(desensitize = "fdyNo")
public ApiResp<MessageReqResp> sendMessage() { public ApiResp<MessageReqResp> sendMessage(@RequestBody @Valid PoiBean dto) {
MessageReqResp reqResp = coreMessageService.send(new UserChannel("13567116463", "sms"), MessageReqResp reqResp = coreMessageService.send(new UserChannel(dto.getFdyNo(), "sms"),
JSONUtil.createObj().putOpt("code", "123456").putOpt("template_code", "SMS_154950909")); JSONUtil.createObj().putOpt("code", "123456").putOpt("template_code", "SMS_154950909"));
return ApiResp.respOK(reqResp); return ApiResp.respOK(reqResp);

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>1.0.5</version> <version>1.0.6</version>
</parent> </parent>
<artifactId>springboot-annotation</artifactId> <artifactId>springboot-annotation</artifactId>

View File

@@ -21,4 +21,12 @@ public @interface OperationLog {
*/ */
String insertKey() default ""; String insertKey() default "";
/**
* 需要脱敏的字段
*
* @return
*/
String[] desensitize();
} }

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>1.0.5</version> <version>1.0.6</version>
</parent> </parent>
<artifactId>springboot-database</artifactId> <artifactId>springboot-database</artifactId>

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>1.0.5</version> <version>1.0.6</version>
</parent> </parent>
<artifactId>springboot-encrypt</artifactId> <artifactId>springboot-encrypt</artifactId>

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>1.0.5</version> <version>1.0.6</version>
</parent> </parent>
<artifactId>springboot-login</artifactId> <artifactId>springboot-login</artifactId>

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>1.0.5</version> <version>1.0.6</version>
</parent> </parent>
<artifactId>springboot-message</artifactId> <artifactId>springboot-message</artifactId>

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>1.0.5</version> <version>1.0.6</version>
</parent> </parent>
<artifactId>springboot-platform</artifactId> <artifactId>springboot-platform</artifactId>

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>1.0.5</version> <version>1.0.6</version>
</parent> </parent>
<artifactId>springboot-poi</artifactId> <artifactId>springboot-poi</artifactId>

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>1.0.5</version> <version>1.0.6</version>
</parent> </parent>
<artifactId>springboot-util</artifactId> <artifactId>springboot-util</artifactId>

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>1.0.5</version> <version>1.0.6</version>
</parent> </parent>
<artifactId>springboot-web</artifactId> <artifactId>springboot-web</artifactId>

View File

@@ -2,6 +2,7 @@ package com.tiesheng.core.config.operation;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.tiesheng.annotation.operation.OperationIgnore; import com.tiesheng.annotation.operation.OperationIgnore;
import com.tiesheng.annotation.operation.OperationLog; import com.tiesheng.annotation.operation.OperationLog;
@@ -17,6 +18,7 @@ import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@@ -74,11 +76,11 @@ public class OperationAspect {
insertKey = operationLog.insertKey(); insertKey = operationLog.insertKey();
} }
Object reqObj = null; Map<String, Object> reqMaps = null;
ConcurrentHashMap<String, Object> allParams = new ConcurrentHashMap<>(16); ConcurrentHashMap<String, Object> allParams = new ConcurrentHashMap<>(16);
if (joinPoint.getArgs().length > 0) { if (joinPoint.getArgs().length > 0) {
reqObj = joinPoint.getArgs()[0]; reqMaps = BeanUtil.beanToMap(joinPoint.getArgs()[0], false, true);
allParams.putAll(BeanUtil.beanToMap(reqObj, false, true)); allParams.putAll(reqMaps);
} }
Object response = joinPoint.proceed(joinPoint.getArgs()); Object response = joinPoint.proceed(joinPoint.getArgs());
@@ -98,7 +100,15 @@ public class OperationAspect {
subject = ServletKit.getRequest().getRequestURI(); subject = ServletKit.getRequest().getRequestURI();
} }
coreLogService.addOperationLog(title, subject, reqObj); // 指定字段脱敏
if (reqMaps != null && operationLog != null
&& ArrayUtil.isNotEmpty(operationLog.desensitize())) {
for (String key : operationLog.desensitize()) {
reqMaps.put(key, "******");
}
}
coreLogService.addOperationLog(title, subject, reqMaps);
return response; return response;
} }