Compare commits

..

8 Commits

Author SHA1 Message Date
曾文豪
e709050ba3 publish 2.0.0.rc6 2024-07-11 16:03:07 +08:00
曾文豪
59926aa2f4 publish 2.0.0.rc5 2024-07-11 15:37:03 +08:00
曾文豪
5da83bb477 publish 2.0.0.rc4 2024-07-11 15:21:59 +08:00
曾文豪
fb1f7c4e37 perf:移除matching-strategy属性 2024-07-04 16:22:46 +08:00
曾文豪
f831f4faf0 publish 2.0.0.rc3 2024-07-03 14:01:53 +08:00
曾文豪
d7016b418e perf:操作日志执行批量插入 2024-07-03 13:57:10 +08:00
曾文豪
fd92109e2e fix:角色列表和角色授权bug 2024-07-03 13:31:23 +08:00
曾文豪
c9679eeeac publish 2.0.0.rc2 2024-06-28 10:57:08 +08:00
97 changed files with 330 additions and 283 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -1,94 +1,7 @@
## 1.1.0
## 2.0.0.rc4
- featglobalConfig增加ext属性。
- feat增加网络请求超时、重定向的配置。
- perf更新数据库对比插件。
- feat(web)增加DaoBase的常量。
- perf(web):操作日志优化。
- perfTsTokenConfig不在提供静态方法
- perf移除TsTokenAspect由TokenWebMvcConfigurer替代并实现TokenBean参数注入
## 1.0.12
- perf(encrypt):开启关闭加解密移动到**yaml**中配置,移除**EnableEncryptConfig**注解。
- feat(login):登录接口增加验签步骤,可通过**validLoginSign**属性开启或关闭(默认)。
- perf(login):可重写**onSignError**方法自定义验签错误的跳转。
- fix(login)修复微信、钉钉授权跳转地址错误的bug
## 1.0.7
- feat(web): 增加uploadFileCustomize方法允许自定义文件存放情况
- feat(database): 增加db/data目录存放初始化数据的sql
- perf(login): 增加默认值防止token解析异常
## 1.0.6
- feat(web):新增 **OperationIgnore** 注解,可以指定接口忽略操作日志的收集。
- feat(web)**OperationLog** 增加 desensitize 属性,用来脱敏指定的字段。
## 1.0.2
- feat(database):增加数据库定时备份;
- feat(database)增加过期备份的删除操作默认过期时间为7天
- perf(message):调整阿里云短信类,方便扩展其他方法。
- perf(message)消息发送接口该body类型为 **JSONObject**
- perf(message):调整消息发送接口和方法(不兼容旧版本)
## 1.0.1
- perf(web)fastjson增加配置 **DisableCircularReferenceDetect**,禁用相同的对象写成引用的形式。
## 1.0.0
- perfhutool依赖升级5.8.11 -> 5.8.16
- perffastjson依赖升级1.2.78 -> 1.2.83
- perfmybatis-plus依赖升级3.5.1 -> 3.5.3
- perf**TieshengWebConfigurer** 增加 **configSystemCheck** 方法,可根据情况校验系统配置参数。
从该版本开始,仓库地址改为:
``` pom
<repositories>
<repository>
<id>kepai-repo</id>
<url>http://git.kepai365.com/tiesheng/repository/raw/master</url>
</repository>
</repositories>
```
## 0.9.3
> 1增加版本对比器防止某些情况下版本对比失效
>
## 0.8.3
### 调整
> 1优化返回数据加密
> 2上传文件接口调整统一为**application/json**格式;
## 0.8.0
### 调整
> 1移除**PasswordUtil**类,新增**EncryptConfig**配置;
> 2默认启用网络请求的加解密前端请配合接口使用。
## 0.7.4
### 新增
> 现在操作日志默认收集不包括GET请求使用方法名称和接口作为参数存储。如果存在OperationLog注解则使用注解的内容。
## 0.7.3
### 增加
> 1TsTokenConfig增加新的属性**ignorePaths**用于通过路径忽略token
> 2PasswordUtils增加密码复杂度校验方法
> 3PasswordUtils.verifyPassword增加登录次数限制10分钟内不能错误6次
>
### 调整
> 1TsTokenConfig中的**ignores**属性调整为**testMap**

94
CHANGELOG_V1.md Normal file
View File

@@ -0,0 +1,94 @@
## 1.1.0
- featglobalConfig增加ext属性。
- feat增加网络请求超时、重定向的配置。
- perf更新数据库对比插件。
- feat(web)增加DaoBase的常量。
- perf(web):操作日志优化。
## 1.0.12
- perf(encrypt):开启关闭加解密移动到**yaml**中配置,移除**EnableEncryptConfig**注解。
- feat(login):登录接口增加验签步骤,可通过**validLoginSign**属性开启或关闭(默认)。
- perf(login):可重写**onSignError**方法自定义验签错误的跳转。
- fix(login)修复微信、钉钉授权跳转地址错误的bug
## 1.0.7
- feat(web): 增加uploadFileCustomize方法允许自定义文件存放情况
- feat(database): 增加db/data目录存放初始化数据的sql
- perf(login): 增加默认值防止token解析异常
## 1.0.6
- feat(web):新增 **OperationIgnore** 注解,可以指定接口忽略操作日志的收集。
- feat(web)**OperationLog** 增加 desensitize 属性,用来脱敏指定的字段。
## 1.0.2
- feat(database):增加数据库定时备份;
- feat(database)增加过期备份的删除操作默认过期时间为7天
- perf(message):调整阿里云短信类,方便扩展其他方法。
- perf(message)消息发送接口该body类型为 **JSONObject**
- perf(message):调整消息发送接口和方法(不兼容旧版本)
## 1.0.1
- perf(web)fastjson增加配置 **DisableCircularReferenceDetect**,禁用相同的对象写成引用的形式。
## 1.0.0
- perfhutool依赖升级5.8.11 -> 5.8.16
- perffastjson依赖升级1.2.78 -> 1.2.83
- perfmybatis-plus依赖升级3.5.1 -> 3.5.3
- perf**TieshengWebConfigurer** 增加 **configSystemCheck** 方法,可根据情况校验系统配置参数。
从该版本开始,仓库地址改为:
``` pom
<repositories>
<repository>
<id>kepai-repo</id>
<url>http://git.kepai365.com/tiesheng/repository/raw/master</url>
</repository>
</repositories>
```
## 0.9.3
> 1增加版本对比器防止某些情况下版本对比失效
>
## 0.8.3
### 调整
> 1优化返回数据加密
> 2上传文件接口调整统一为**application/json**格式;
## 0.8.0
### 调整
> 1移除**PasswordUtil**类,新增**EncryptConfig**配置;
> 2默认启用网络请求的加解密前端请配合接口使用。
## 0.7.4
### 新增
> 现在操作日志默认收集不包括GET请求使用方法名称和接口作为参数存储。如果存在OperationLog注解则使用注解的内容。
## 0.7.3
### 增加
> 1TsTokenConfig增加新的属性**ignorePaths**用于通过路径忽略token
> 2PasswordUtils增加密码复杂度校验方法
> 3PasswordUtils.verifyPassword增加登录次数限制10分钟内不能错误6次
>
### 调整
> 1TsTokenConfig中的**ignores**属性调整为**testMap**

22
pom.xml
View File

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

Binary file not shown.

View File

@@ -6,11 +6,11 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.0.rc1</version>
<version>2.0.0.rc6</version>
</parent>
<artifactId>springboot-ademo</artifactId>
<version>2.0.0.rc1</version>
<version>2.0.0.rc6</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>

Binary file not shown.

Binary file not shown.

View File

@@ -40,11 +40,11 @@ public class DemoWebConfigurer implements TieshengWebConfigurer {
public void redirect(TokenBean bean, String to, String extra, HttpServletResponse response) {
// 默认跳转到mobile
to = StrUtil.emptyToDefault(to, "mobile");
to = StrUtil.emptyToDefault(to, "static/mobile");
bean.setEnvironmentType(to);
if (Objects.equals(bean.getEnvironmentType(), "mobile")) {
globalConfig.redirect("mobile", "/?token=" + bean.toToken(), response);
if (Objects.equals(bean.getEnvironmentType(), "static/mobile")) {
globalConfig.redirect("static/mobile", "/?token=" + bean.toToken(), response);
}
}

View File

@@ -9,6 +9,7 @@ import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.tiesheng.annotation.token.TokenIgnore;
import com.tiesheng.util.pojos.TokenBean;
import com.tiesheng.web.service.CoreLogService;
import com.tiesheng.web.service.CoreMessageService;
import com.tiesheng.web.util.ProcessImportConsumer;
@@ -55,8 +56,9 @@ public class TestController {
@RequestMapping("/index")
public ApiResp<String> index() {
return ApiResp.respOK("hello world");
@TokenIgnore
public void index(HttpServletResponse response) {
globalConfig.redirect("mobile", "/test", response);
}
@RequestMapping("/redirect")

View File

@@ -13,16 +13,9 @@ spring:
web:
resources:
static-locations: classpath:/static/,file:static/
mvc:
pathmatch:
matching-strategy: ant_path_matcher
## 日志
logging:
file:
name: runtime/logs/tiesheng.log
tiesheng:
token:
ignore-paths:
- /test/index

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
springboot-annotation/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.0.rc1</version>
<version>2.0.0.rc6</version>
</parent>
<artifactId>springboot-annotation</artifactId>

BIN
springboot-database/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.0.rc1</version>
<version>2.0.0.rc6</version>
</parent>
<artifactId>springboot-database</artifactId>

BIN
springboot-encrypt/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.0.rc1</version>
<version>2.0.0.rc6</version>
</parent>
<artifactId>springboot-encrypt</artifactId>

BIN
springboot-login/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.0.rc1</version>
<version>2.0.0.rc6</version>
</parent>
<artifactId>springboot-login</artifactId>

View File

@@ -0,0 +1,105 @@
package com.tiesheng.login.config;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.tiesheng.annotation.token.TokenIgnore;
import com.tiesheng.util.config.TsTokenConfig;
import com.tiesheng.util.pojos.TokenBean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.MethodParameter;
import org.springframework.web.bind.support.WebDataBinderFactory;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
import java.util.List;
@Configuration
public class TokenWebMvcConfigurer implements WebMvcConfigurer {
@Resource
TsTokenConfig tsTokenConfig;
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
resolvers.add(new HandlerMethodArgumentResolver() {
@Override
public boolean supportsParameter(MethodParameter parameter) {
return parameter.getParameterType().isAssignableFrom(TokenBean.class);
}
@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) {
String header = webRequest.getHeader(TsTokenConfig.TOKEN_KEY);
boolean thrExp = true;
Method method = parameter.getMethod();
if (method != null) {
TokenIgnore annotation = method.getAnnotation(TokenIgnore.class);
thrExp = annotation == null;
}
return tsTokenConfig.validToken(header, thrExp);
}
});
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new HandlerInterceptor() {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
// 非接口类直接跳过
if (!(handler instanceof HandlerMethod)) {
return true;
}
String requestURI = request.getRequestURI();
String[] ignorePaths = tsTokenConfig.getIgnorePaths();
if (ObjUtil.isNotEmpty(ignorePaths)) {
for (String path : ignorePaths) {
if (path.contains("/**") &&
StrUtil.startWith(requestURI, path.replace("/**", ""))) {
// 通配路径
return true;
} else if (requestURI.equals(path)) {
// 完整路径
return true;
}
}
}
// 过滤不要需要验证的接口(注解)
HandlerMethod handlerMethod = (HandlerMethod) handler;
TokenIgnore annotation = handlerMethod.getBeanType().getAnnotation(TokenIgnore.class);
if (annotation != null) {
return true;
}
TokenIgnore apiTokenIgnore = handlerMethod.getMethodAnnotation(TokenIgnore.class);
if (apiTokenIgnore != null) {
return true;
}
// token验证
tsTokenConfig.validToken(request, true);
return true;
}
});
}
}

View File

@@ -1,88 +0,0 @@
package com.tiesheng.login.config;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.tiesheng.annotation.token.TokenIgnore;
import com.tiesheng.util.ServletKit;
import com.tiesheng.util.config.TsTokenConfig;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.lang.reflect.Method;
/**
* @author hao
* @ProjectName CmccSpring
* @Copyright Hangzhou ShuoChuang Technology Co.,Ltd All Right Reserved
* @Description 这里是对文件的描述
* @data 2019-07-15
* @note 这里写文件的详细功能和改动
* @note
*/
@Aspect
@Component
public class TsTokenAspect {
@Autowired
TsTokenConfig tsTokenConfig;
/**
* 切入点
*/
@Pointcut("execution(* com..controller..*.*(..))")
public void methodArgs() {
}
/**
* 获取操作日志说明
*
* @param joinPoint
*/
@Before("methodArgs()")
public void before(JoinPoint joinPoint) {
// 过滤不要需要验证的接口path
String requestURI = ServletKit.getRequest().getRequestURI();
String[] ignorePaths = tsTokenConfig.getIgnorePaths();
if (ObjUtil.isNotEmpty(ignorePaths)) {
for (String path : ignorePaths) {
if (path.contains("/**") &&
StrUtil.startWith(requestURI, path.replace("/**", ""))) {
// 通配路径
return;
} else if (requestURI.equals(path)) {
// 完整路径
return;
}
}
}
// 过滤不要需要验证的接口(注解)
Object aThis = joinPoint.getTarget();
TokenIgnore annotation = aThis.getClass().getAnnotation(TokenIgnore.class);
if (annotation != null) {
return;
}
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
TokenIgnore apiTokenIgnore = method.getAnnotation(TokenIgnore.class);
if (apiTokenIgnore != null) {
return;
}
// token验证
tsTokenConfig.validToken(true);
}
}

BIN
springboot-message/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.0.rc1</version>
<version>2.0.0.rc6</version>
</parent>
<artifactId>springboot-message</artifactId>

BIN
springboot-platform/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.0.rc1</version>
<version>2.0.0.rc6</version>
</parent>
<artifactId>springboot-platform</artifactId>

BIN
springboot-poi/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.0.rc1</version>
<version>2.0.0.rc6</version>
</parent>
<artifactId>springboot-poi</artifactId>

BIN
springboot-role/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.0.rc1</version>
<version>2.0.0.rc6</version>
</parent>
<artifactId>springboot-role</artifactId>

View File

@@ -1,5 +1,6 @@
package com.tiesheng.role.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -12,7 +13,6 @@ import com.tiesheng.role.pojos.vo.GroupTypeDTO;
import com.tiesheng.role.pojos.vo.RoleUserPageVO;
import com.tiesheng.role.pojos.vo.ServiceMenuVO;
import com.tiesheng.role.service.CoreRoleService;
import com.tiesheng.util.config.TsTokenConfig;
import com.tiesheng.util.exception.ApiException;
import com.tiesheng.util.pojos.ApiResp;
import com.tiesheng.util.pojos.IdDTO;
@@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@@ -43,6 +44,7 @@ public class RoleController {
public ApiResp<List<CoreRoleGroup>> groupList(@Valid GroupTypeDTO dto) {
return ApiResp.respOK(coreRoleService.list(
new QueryWrapper<CoreRoleGroup>()
.eq("is_deleted", 0)
.eq("type", dto.getType())
.orderByAsc("sort")
));
@@ -248,15 +250,18 @@ public class RoleController {
* @return
*/
@GetMapping("/owner/server")
public ApiResp<List<CoreRoleServer>> ownerServer() {
TokenBean tokenBean = TsTokenConfig.get();
public ApiResp<List<CoreRoleServer>> ownerServer(TokenBean tokenBean) {
List<CoreRoleAuthority> allOwnerMenus = coreRoleService.getOwnerAuthorityLeafList(tokenBean.getId(), tokenBean.getRoleId());
List<String> list = allOwnerMenus.stream().map(CoreRoleAuthority::getService).collect(Collectors.toList());
List<CoreRoleServer> roleServerList = coreRoleService.getServerMapper().selectList(new QueryWrapper<CoreRoleServer>()
.in("id", allOwnerMenus.stream().map(CoreRoleAuthority::getService).collect(Collectors.toList()))
.eq(CoreRoleServer.IS_DELETED, 0)
.eq("is_open", 1)
);
List<CoreRoleServer> roleServerList = new ArrayList<>();
if (CollUtil.isNotEmpty(list)) {
roleServerList = coreRoleService.getServerMapper().selectList(new QueryWrapper<CoreRoleServer>()
.in("id", list)
.eq(CoreRoleServer.IS_DELETED, 0)
.eq("is_open", 1)
);
}
return ApiResp.respOK(roleServerList);
}
@@ -268,11 +273,8 @@ public class RoleController {
* @return
*/
@GetMapping("/owner/menu")
public ApiResp<List<ServiceMenuVO>> ownerMenu(@Valid OwnerMenuDTO dto) {
TokenBean tokenBean = TsTokenConfig.get();
public ApiResp<List<ServiceMenuVO>> ownerMenu(TokenBean tokenBean, @Valid OwnerMenuDTO dto) {
List<ServiceMenuVO> ownerMenus = coreRoleService.getOwnerMenus(tokenBean.getId(), tokenBean.getRoleId(), dto);
return ApiResp.respOK(ownerMenus);
}
@@ -282,9 +284,8 @@ public class RoleController {
* @return
*/
@GetMapping("/owner/point")
public ApiResp<List<CoreRoleAuthority>> ownerPoint(@Valid OwnerPointDTO dto) {
public ApiResp<List<CoreRoleAuthority>> ownerPoint(TokenBean tokenBean, @Valid OwnerPointDTO dto) {
TokenBean tokenBean = TsTokenConfig.get();
List<CoreRoleAuthority> allOwnerMenus = coreRoleService.getOwnerAuthorityLeafList(tokenBean.getId(), tokenBean.getRoleId());
String parentId;

View File

@@ -9,7 +9,6 @@ import com.tiesheng.role.pojos.dao.CoreRoleAuthority;
import com.tiesheng.role.pojos.dao.CoreRoleGroup;
import com.tiesheng.role.pojos.dao.CoreRoleGroupRx;
import com.tiesheng.role.pojos.dto.GroupRxUpdateDTO;
import com.tiesheng.role.pojos.dto.MenuListDTO;
import com.tiesheng.role.pojos.dto.OwnerMenuDTO;
import com.tiesheng.role.pojos.vo.ServiceMenuVO;
import com.tiesheng.util.service.TsServiceBase;
@@ -17,7 +16,10 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
@Service
@@ -96,7 +98,10 @@ public class CoreRoleService extends TsServiceBase<CoreRoleGroupMapper, CoreRole
coreRoleGroupRx.setMenuId(menuId);
list.add(coreRoleGroupRx);
}
coreRoleGroupRxMapper.batchInsert(list);
if (CollUtil.isNotEmpty(list)) {
coreRoleGroupRxMapper.batchInsert(list);
}
}

View File

@@ -19,10 +19,10 @@
<insert id="batchInsert">
insert into core_role_group_rx(id, create_time, update_time, is_deleted, group_id, menu_id)
values
<foreach collection="list" separator="," open="(" close=")" item="item">
uuid(), now(), now(), 0,
#{item.groupId},
#{item.menuId}
</foreach>
<foreach collection="list" separator="," item="item">
(uuid(), now(), now(), 0,
#{item.groupId},
#{item.menuId})
</foreach>
</insert>
</mapper>

BIN
springboot-util/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.0.rc1</version>
<version>2.0.0.rc6</version>
</parent>
<artifactId>springboot-util</artifactId>

View File

@@ -4,15 +4,15 @@ package com.tiesheng.util.config;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.servlet.ServletUtil;
import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.json.JSONUtil;
import cn.hutool.jwt.JWT;
import cn.hutool.jwt.JWTValidator;
import com.tiesheng.util.ServletKit;
import com.tiesheng.util.exception.ApiException;
import com.tiesheng.util.pojos.TokenBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
@@ -23,6 +23,11 @@ import java.util.Map;
@ConfigurationProperties("tiesheng.token")
public class TsTokenConfig {
/**
* token常量
*/
public static final String TOKEN_KEY = "token";
private Map<String, TokenBean> testMap = MapUtil.newHashMap();
private String encryptKey = "%kIp9frQCu";
private Integer expireHours = 48;
@@ -30,28 +35,6 @@ public class TsTokenConfig {
private boolean validLoginSign = false;
/**
* 获取当前登录的token
*
* @return
*/
public static TokenBean get() {
TsTokenConfig tokenConfig = SpringUtil.getBean(TsTokenConfig.class);
return tokenConfig.validToken(true);
}
/**
* 获取当前登录的token
*
* @return
*/
public static TokenBean getWithoutThr() {
TsTokenConfig tokenConfig = SpringUtil.getBean(TsTokenConfig.class);
return tokenConfig.validToken(false);
}
/**
* 验证token
*
@@ -72,8 +55,8 @@ public class TsTokenConfig {
* @param thrExp
* @return
*/
public TokenBean validToken(boolean thrExp) {
String token = ServletUtil.getHeader(ServletKit.getRequest(), "token", "utf-8");
public TokenBean validToken(HttpServletRequest request, boolean thrExp) {
String token = ServletUtil.getHeader(request, TOKEN_KEY, "utf-8");
return validToken(token, thrExp);
}
@@ -92,14 +75,7 @@ public class TsTokenConfig {
try {
JWT decode = JWT.of(token);
JWTValidator.of(decode).validateDate();
String id = decode.getPayload("id").toString();
String environmentType = decode.getPayload("environmentType").toString();
String service = decode.getPayload("service").toString();
String extra = StrUtil.toStringOrNull(decode.getPayload("extra"));
String roleId = StrUtil.toStringOrNull(decode.getPayload("roleId"));
tokenBean = new TokenBean(id, environmentType, service);
tokenBean.setRoleId(roleId);
tokenBean.setExtra(extra);
tokenBean = JSONUtil.toBean(decode.getPayloads(), TokenBean.class);
} catch (Exception ignored) {
}

BIN
springboot-web/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.0.rc1</version>
<version>2.0.0.rc6</version>
</parent>
<artifactId>springboot-web</artifactId>

View File

@@ -6,8 +6,9 @@ import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import com.tiesheng.annotation.operation.OperationIgnore;
import com.tiesheng.annotation.operation.OperationLog;
import com.tiesheng.web.service.CoreLogService;
import com.tiesheng.util.ServletKit;
import com.tiesheng.util.config.TsTokenConfig;
import com.tiesheng.web.service.CoreLogService;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
@@ -37,6 +38,8 @@ public class OperationAspect {
@Autowired
CoreLogService coreLogService;
@Autowired
TsTokenConfig tsTokenConfig;
@Pointcut("execution(* com..controller..*.*(..))")
@@ -108,7 +111,8 @@ public class OperationAspect {
}
}
coreLogService.addOperationLog(title, subject, reqMaps);
coreLogService.addOperationLog(
tsTokenConfig.validToken(request, false), title, subject, reqMaps);
return response;
}

View File

@@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tiesheng.web.pojos.dao.CoreLogOperation;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface CoreLogOperationMapper extends BaseMapper<CoreLogOperation> {
@@ -20,4 +22,12 @@ public interface CoreLogOperationMapper extends BaseMapper<CoreLogOperation> {
Page<CoreLogOperation> page(IPage<CoreLogOperation> page, @Param("ew") QueryWrapper<CoreLogOperation> queryWrapper);
/**
* 批量插入日志
*
* @param coreLogOperations
* @return
*/
int batchInsert(@Param("list") List<CoreLogOperation> coreLogOperations);
}

View File

@@ -2,11 +2,17 @@ package com.tiesheng.web.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.servlet.ServletUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tiesheng.util.ServletKit;
import com.tiesheng.util.config.Ip2regionConfig;
import com.tiesheng.util.exception.ApiException;
import com.tiesheng.util.pojos.TokenBean;
import com.tiesheng.util.service.TsServiceBase;
import com.tiesheng.web.mapper.CoreLogLoginMapper;
import com.tiesheng.web.mapper.CoreLogMessageMapper;
import com.tiesheng.web.mapper.CoreLogOperationMapper;
@@ -19,12 +25,6 @@ import com.tiesheng.web.pojos.dao.CorePlatformUnique;
import com.tiesheng.web.pojos.vo.ProcessDetailVo;
import com.tiesheng.web.util.ProcessImportConsumer;
import com.tiesheng.web.util.ProcessSyncConsumer;
import com.tiesheng.util.config.TsTokenConfig;
import com.tiesheng.util.pojos.TokenBean;
import com.tiesheng.util.ServletKit;
import com.tiesheng.util.config.Ip2regionConfig;
import com.tiesheng.util.exception.ApiException;
import com.tiesheng.util.service.TsServiceBase;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -38,6 +38,11 @@ import java.util.List;
@Service
public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLogOperation> {
/**
* 日志缓存
*/
private static final List<CoreLogOperation> cacheOperations = new ArrayList<>();
@Autowired
TieshengWebConfigurer tieshengWebConfigurer;
@Autowired
@@ -177,14 +182,19 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
/**
* 添加操作日志
*/
public void addOperationLog(String title, String subject, Object params) {
TokenBean tokenBean = TsTokenConfig.getWithoutThr();
if (tokenBean == null || StrUtil.isEmpty(tokenBean.getId())) {
return;
public void addOperationLog(TokenBean tokenBean, String title, String subject, Object params) {
RequestUserInfo requestUserInfo = null;
if (tokenBean != null && !StrUtil.isEmpty(tokenBean.getId())) {
requestUserInfo = tieshengWebConfigurer.getCurrentUserName(tokenBean);
}
if (requestUserInfo == null) {
requestUserInfo = new RequestUserInfo();
}
RequestUserInfo requestUserInfo = tieshengWebConfigurer.getCurrentUserName(tokenBean);
CoreLogOperation operation = new CoreLogOperation();
operation.setCreateTime(DateUtil.date());
operation.setUpdateTime(DateUtil.date());
operation.setUserId(requestUserInfo.getId());
operation.setUserName(requestUserInfo.getName());
operation.setTitle(title);
@@ -192,7 +202,15 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
if (params != null) {
operation.setParams(JSONUtil.toJsonStr(params));
}
save(operation);
synchronized (CoreLogOperation.class) {
cacheOperations.add(operation);
if (cacheOperations.size() >= 100) {
getBaseMapper().batchInsert(cacheOperations);
cacheOperations.clear();
}
}
}
///////////////////////////////////////////////////////////////////////////

View File

@@ -24,4 +24,18 @@
${ew.customSqlSegment}
</select>
<insert id="batchInsert">
insert into core_log_operation(id, create_time, update_time, is_deleted, user_id, user_name, title, subject,
params)
values
<foreach collection="list" item="it" separator=",">
(uuid(), #{it.createTime}, #{it.updateTime}, 0,
#{it.userId},
#{it.userName},
#{it.title},
#{it.subject},
#{it.params})
</foreach>
</insert>
</mapper>