publish 2.0.0.rc4

This commit is contained in:
曾文豪
2024-07-11 15:21:59 +08:00
parent fb1f7c4e37
commit 5da83bb477
33 changed files with 240 additions and 250 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -1,94 +1,7 @@
## 1.1.0 ## 2.0.0.rc4
- featglobalConfig增加ext属性。 - perfTsTokenConfig不在提供静态方法
- feat增加网络请求超时、重定向的配置。 - perf移除TsTokenAspect由TokenWebMvcConfigurer替代并实现TokenBean参数注入
- 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**

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> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.0.rc3</version> <version>2.0.0.rc4</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>springboot-parent</name> <name>springboot-parent</name>
<description>杭州铁晟科技有限公司基础依赖</description> <description>杭州铁晟科技有限公司基础依赖</description>
@@ -58,61 +58,61 @@
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-database</artifactId> <artifactId>springboot-database</artifactId>
<version>2.0.0.rc3</version> <version>2.0.0.rc4</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>2.0.0.rc3</version> <version>2.0.0.rc4</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>2.0.0.rc3</version> <version>2.0.0.rc4</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>2.0.0.rc3</version> <version>2.0.0.rc4</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>2.0.0.rc3</version> <version>2.0.0.rc4</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>2.0.0.rc3</version> <version>2.0.0.rc4</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>2.0.0.rc3</version> <version>2.0.0.rc4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-role</artifactId> <artifactId>springboot-role</artifactId>
<version>2.0.0.rc3</version> <version>2.0.0.rc4</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>2.0.0.rc3</version> <version>2.0.0.rc4</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>2.0.0.rc3</version> <version>2.0.0.rc4</version>
</dependency> </dependency>
<dependency> <dependency>

Binary file not shown.

View File

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

Binary file not shown.

Binary file not shown.

BIN
springboot-annotation/.DS_Store vendored Normal file

Binary file not shown.

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>2.0.0.rc3</version> <version>2.0.0.rc4</version>
</parent> </parent>
<artifactId>springboot-annotation</artifactId> <artifactId>springboot-annotation</artifactId>

BIN
springboot-database/.DS_Store vendored Normal file

Binary file not shown.

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>2.0.0.rc3</version> <version>2.0.0.rc4</version>
</parent> </parent>
<artifactId>springboot-database</artifactId> <artifactId>springboot-database</artifactId>

BIN
springboot-encrypt/.DS_Store vendored Normal file

Binary file not shown.

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>2.0.0.rc3</version> <version>2.0.0.rc4</version>
</parent> </parent>
<artifactId>springboot-encrypt</artifactId> <artifactId>springboot-encrypt</artifactId>

BIN
springboot-login/.DS_Store vendored Normal file

Binary file not shown.

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>2.0.0.rc3</version> <version>2.0.0.rc4</version>
</parent> </parent>
<artifactId>springboot-login</artifactId> <artifactId>springboot-login</artifactId>

View File

@@ -0,0 +1,92 @@
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.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);
return tsTokenConfig.validToken(header, true);
}
});
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new HandlerInterceptor() {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
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> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.0.rc3</version> <version>2.0.0.rc4</version>
</parent> </parent>
<artifactId>springboot-message</artifactId> <artifactId>springboot-message</artifactId>

BIN
springboot-platform/.DS_Store vendored Normal file

Binary file not shown.

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>2.0.0.rc3</version> <version>2.0.0.rc4</version>
</parent> </parent>
<artifactId>springboot-platform</artifactId> <artifactId>springboot-platform</artifactId>

BIN
springboot-poi/.DS_Store vendored Normal file

Binary file not shown.

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>2.0.0.rc3</version> <version>2.0.0.rc4</version>
</parent> </parent>
<artifactId>springboot-poi</artifactId> <artifactId>springboot-poi</artifactId>

BIN
springboot-role/.DS_Store vendored Normal file

Binary file not shown.

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>2.0.0.rc3</version> <version>2.0.0.rc4</version>
</parent> </parent>
<artifactId>springboot-role</artifactId> <artifactId>springboot-role</artifactId>

View File

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

BIN
springboot-util/.DS_Store vendored Normal file

Binary file not shown.

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>2.0.0.rc3</version> <version>2.0.0.rc4</version>
</parent> </parent>
<artifactId>springboot-util</artifactId> <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.map.MapUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.servlet.ServletUtil; 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.JWT;
import cn.hutool.jwt.JWTValidator; import cn.hutool.jwt.JWTValidator;
import com.tiesheng.util.ServletKit;
import com.tiesheng.util.exception.ApiException; import com.tiesheng.util.exception.ApiException;
import com.tiesheng.util.pojos.TokenBean; import com.tiesheng.util.pojos.TokenBean;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import javax.servlet.http.HttpServletRequest;
import java.util.Map; import java.util.Map;
@@ -23,6 +23,11 @@ import java.util.Map;
@ConfigurationProperties("tiesheng.token") @ConfigurationProperties("tiesheng.token")
public class TsTokenConfig { public class TsTokenConfig {
/**
* token常量
*/
public static final String TOKEN_KEY = "token";
private Map<String, TokenBean> testMap = MapUtil.newHashMap(); private Map<String, TokenBean> testMap = MapUtil.newHashMap();
private String encryptKey = "%kIp9frQCu"; private String encryptKey = "%kIp9frQCu";
private Integer expireHours = 48; private Integer expireHours = 48;
@@ -30,28 +35,6 @@ public class TsTokenConfig {
private boolean validLoginSign = false; 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 * 验证token
* *
@@ -72,8 +55,8 @@ public class TsTokenConfig {
* @param thrExp * @param thrExp
* @return * @return
*/ */
public TokenBean validToken(boolean thrExp) { public TokenBean validToken(HttpServletRequest request, boolean thrExp) {
String token = ServletUtil.getHeader(ServletKit.getRequest(), "token", "utf-8"); String token = ServletUtil.getHeader(request, TOKEN_KEY, "utf-8");
return validToken(token, thrExp); return validToken(token, thrExp);
} }
@@ -92,14 +75,7 @@ public class TsTokenConfig {
try { try {
JWT decode = JWT.of(token); JWT decode = JWT.of(token);
JWTValidator.of(decode).validateDate(); JWTValidator.of(decode).validateDate();
String id = decode.getPayload("id").toString(); tokenBean = JSONUtil.toBean(decode.getPayloads(), TokenBean.class);
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);
} catch (Exception ignored) { } catch (Exception ignored) {
} }

BIN
springboot-web/.DS_Store vendored Normal file

Binary file not shown.

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>2.0.0.rc3</version> <version>2.0.0.rc4</version>
</parent> </parent>
<artifactId>springboot-web</artifactId> <artifactId>springboot-web</artifactId>

View File

@@ -38,6 +38,8 @@ public class OperationAspect {
@Autowired @Autowired
CoreLogService coreLogService; CoreLogService coreLogService;
@Autowired
TsTokenConfig tsTokenConfig;
@Pointcut("execution(* com..controller..*.*(..))") @Pointcut("execution(* com..controller..*.*(..))")
@@ -109,7 +111,8 @@ public class OperationAspect {
} }
} }
coreLogService.addOperationLog(TsTokenConfig.getWithoutThr(), title, subject, reqMaps); coreLogService.addOperationLog(
tsTokenConfig.validToken(request, false), title, subject, reqMaps);
return response; return response;
} }