publish 0.7.4

This commit is contained in:
曾文豪
2023-02-28 11:32:45 +08:00
parent c3edb50e80
commit d758d65033
14 changed files with 53 additions and 27 deletions

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>0.7.3</version> <version>0.7.4</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>0.7.3</version> <version>0.7.4</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>0.7.3</version> <version>0.7.4</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>0.7.3</version> <version>0.7.4</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>0.7.3</version> <version>0.7.4</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>0.7.3</version> <version>0.7.4</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>0.7.3</version> <version>0.7.4</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>0.7.3</version> <version>0.7.4</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>0.7.3</version> <version>0.7.4</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>0.7.3</version> <version>0.7.4</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>0.7.3</version> <version>0.7.4</version>
</parent> </parent>
<artifactId>springboot-ademo</artifactId> <artifactId>springboot-ademo</artifactId>

View File

@@ -20,7 +20,10 @@ public class DemoWebConfigurer implements TieshengWebConfigurer {
@Override @Override
public RequestUserInfo getCurrentUserName(TokenBean tokenBean) { public RequestUserInfo getCurrentUserName(TokenBean tokenBean) {
return null; RequestUserInfo info = new RequestUserInfo();
info.setId("1");
info.setName("test");
return info;
} }
@Override @Override

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>0.7.3</version> <version>0.7.4</version>
</parent> </parent>
<artifactId>springboot-annotation</artifactId> <artifactId>springboot-annotation</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>0.7.3</version> <version>0.7.4</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>0.7.3</version> <version>0.7.4</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>0.7.3</version> <version>0.7.4</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>0.7.3</version> <version>0.7.4</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>0.7.3</version> <version>0.7.4</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>0.7.3</version> <version>0.7.4</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>0.7.3</version> <version>0.7.4</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>0.7.3</version> <version>0.7.4</version>
</parent> </parent>
<artifactId>springboot-web</artifactId> <artifactId>springboot-web</artifactId>

View File

@@ -5,6 +5,7 @@ import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.tiesheng.annotation.operation.OperationLog; import com.tiesheng.annotation.operation.OperationLog;
import com.tiesheng.core.service.CoreLogService; import com.tiesheng.core.service.CoreLogService;
import com.tiesheng.util.ServletKit;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
@@ -13,6 +14,7 @@ import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -35,7 +37,7 @@ public class OperationAspect {
CoreLogService coreLogService; CoreLogService coreLogService;
@Pointcut("@annotation(com.tiesheng.annotation.operation.OperationLog)") @Pointcut("execution(* com..controller..*.*(..))")
public void methodArgs() { public void methodArgs() {
} }
@@ -48,11 +50,24 @@ public class OperationAspect {
*/ */
@Around("methodArgs()") @Around("methodArgs()")
public Object around(ProceedingJoinPoint joinPoint) throws Throwable { public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
// GET请求不处理
HttpServletRequest request = ServletKit.getRequest();
if (StrUtil.equalsIgnoreCase(request.getMethod(), "GET")) {
return joinPoint.proceed(joinPoint.getArgs());
}
String title = "", subject = "";
String insertKey = "";
MethodSignature signature = (MethodSignature) joinPoint.getSignature(); MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod(); Method method = signature.getMethod();
OperationLog operationLog = method.getAnnotation(OperationLog.class); OperationLog operationLog = method.getAnnotation(OperationLog.class);
String subject = operationLog.subject(); if (operationLog != null) {
String insertKey = operationLog.insertKey(); title = operationLog.title();
subject = operationLog.subject();
insertKey = operationLog.insertKey();
}
Object reqObj = null; Object reqObj = null;
Map<String, Object> allParams = new HashMap<>(16); Map<String, Object> allParams = new HashMap<>(16);
@@ -65,7 +80,6 @@ public class OperationAspect {
allParams.putAll(BeanUtil.beanToMap(response)); allParams.putAll(BeanUtil.beanToMap(response));
if (!StrUtil.isEmpty(subject)) { if (!StrUtil.isEmpty(subject)) {
// 添加、编辑关键字处理 // 添加、编辑关键字处理
if (!StrUtil.isEmpty(insertKey)) { if (!StrUtil.isEmpty(insertKey)) {
String insertVal = MapUtil.getStr(allParams, insertKey); String insertVal = MapUtil.getStr(allParams, insertKey);
@@ -74,9 +88,12 @@ public class OperationAspect {
// 占位符处理 // 占位符处理
subject = StrUtil.format(subject, allParams); subject = StrUtil.format(subject, allParams);
} else {
title = method.getName();
subject = ServletKit.getRequest().getRequestURI();
} }
coreLogService.addOperationLog(operationLog.title(), subject, reqObj); coreLogService.addOperationLog(title, subject, reqObj);
return response; return response;
} }

View File

@@ -1,6 +1,7 @@
package com.tiesheng.core.service; package com.tiesheng.core.service;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.servlet.ServletUtil; import cn.hutool.extra.servlet.ServletUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.tiesheng.core.mapper.CoreLogLoginMapper; import com.tiesheng.core.mapper.CoreLogLoginMapper;
@@ -54,8 +55,13 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
* 添加操作日志 * 添加操作日志
*/ */
public void addOperationLog(String title, String subject, Object params) { public void addOperationLog(String title, String subject, Object params) {
TokenBean tokenBean = TsTokenConfig.getWithoutThr();
if (tokenBean == null || StrUtil.isEmpty(tokenBean.getId())) {
return;
}
RequestUserInfo requestUserInfo = tieshengWebConfigurer.getCurrentUserName(tokenBean);
CoreLogOperation operation = new CoreLogOperation(); CoreLogOperation operation = new CoreLogOperation();
RequestUserInfo requestUserInfo = tieshengWebConfigurer.getCurrentUserName(TsTokenConfig.get());
operation.setUserId(requestUserInfo.getId()); operation.setUserId(requestUserInfo.getId());
operation.setUserName(requestUserInfo.getName()); operation.setUserName(requestUserInfo.getName());
operation.setTitle(title); operation.setTitle(title);