Compare commits
56 Commits
1.1.3
...
2.0.0.rc22
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d4e97babf4 | ||
|
|
a1c75d010b | ||
|
|
9b6b3af33e | ||
|
|
91833a44bb | ||
|
|
8dc8709499 | ||
|
|
b34d9d6242 | ||
|
|
2c9519a35e | ||
|
|
f5dfce08ed | ||
|
|
5d4e97b206 | ||
|
|
82d3f471f9 | ||
|
|
316909dd61 | ||
|
|
5e308be3ba | ||
|
|
ba80cebc45 | ||
|
|
0f5cdb49c0 | ||
|
|
1ee4b4af30 | ||
|
|
bb38428708 | ||
|
|
a22467d4f1 | ||
|
|
ad90c83cf7 | ||
|
|
cdae6a9868 | ||
|
|
be08001f3f | ||
|
|
333d283e24 | ||
|
|
450d1fb869 | ||
|
|
1412782327 | ||
|
|
6127cd50a9 | ||
|
|
19f4d0395e | ||
|
|
d52edbb23c | ||
|
|
6c6d713c01 | ||
|
|
8ea34c3ee0 | ||
|
|
d357fa7c85 | ||
|
|
6332d1486b | ||
|
|
e709050ba3 | ||
|
|
59926aa2f4 | ||
|
|
5da83bb477 | ||
|
|
fb1f7c4e37 | ||
|
|
f831f4faf0 | ||
|
|
d7016b418e | ||
|
|
fd92109e2e | ||
|
|
c9679eeeac | ||
|
|
08a3c52f34 | ||
|
|
5a25006189 | ||
|
|
093d39a108 | ||
|
|
c0ded4356f | ||
|
|
8f7d543c8b | ||
|
|
67bb6041c6 | ||
|
|
78cb8dafeb | ||
|
|
d77eb50a5b | ||
|
|
aee4fa86f6 | ||
|
|
a10b57f6fc | ||
|
|
d2229e0028 | ||
|
|
80cd48b97c | ||
|
|
0e6bee4714 | ||
|
|
ae67cc53ec | ||
|
|
419cb06ff6 | ||
|
|
384ac928e3 | ||
|
|
130cd45de2 | ||
|
|
6840faa9d8 |
93
CHANGELOG.md
@@ -1,94 +1,7 @@
|
|||||||
## 1.1.0
|
## 2.0.0.rc4
|
||||||
|
|
||||||
- feat:globalConfig增加ext属性。
|
- perf:TsTokenConfig不在提供静态方法
|
||||||
- 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
|
|
||||||
|
|
||||||
- perf:hutool依赖升级:5.8.11 -> 5.8.16
|
|
||||||
- perf:fastjson依赖升级:1.2.78 -> 1.2.83
|
|
||||||
- perf:mybatis-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
|
|
||||||
|
|
||||||
### 增加
|
|
||||||
|
|
||||||
> 1,TsTokenConfig增加新的属性**ignorePaths**,用于通过路径忽略token;
|
|
||||||
> 2,PasswordUtils增加密码复杂度校验方法;
|
|
||||||
> 3,PasswordUtils.verifyPassword增加登录次数限制:10分钟内不能错误6次;
|
|
||||||
>
|
|
||||||
|
|
||||||
### 调整
|
|
||||||
|
|
||||||
> 1,TsTokenConfig中的**ignores**属性调整为**testMap**;
|
|
||||||
|
|||||||
94
CHANGELOG_V1.md
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
## 1.1.0
|
||||||
|
|
||||||
|
- feat:globalConfig增加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
|
||||||
|
|
||||||
|
- perf:hutool依赖升级:5.8.11 -> 5.8.16
|
||||||
|
- perf:fastjson依赖升级:1.2.78 -> 1.2.83
|
||||||
|
- perf:mybatis-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
|
||||||
|
|
||||||
|
### 增加
|
||||||
|
|
||||||
|
> 1,TsTokenConfig增加新的属性**ignorePaths**,用于通过路径忽略token;
|
||||||
|
> 2,PasswordUtils增加密码复杂度校验方法;
|
||||||
|
> 3,PasswordUtils.verifyPassword增加登录次数限制:10分钟内不能错误6次;
|
||||||
|
>
|
||||||
|
|
||||||
|
### 调整
|
||||||
|
|
||||||
|
> 1,TsTokenConfig中的**ignores**属性调整为**testMap**;
|
||||||
27
pom.xml
@@ -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.1.3</version>
|
<version>2.0.0.rc22</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>springboot-parent</name>
|
<name>springboot-parent</name>
|
||||||
<description>杭州铁晟科技有限公司基础依赖</description>
|
<description>杭州铁晟科技有限公司基础依赖</description>
|
||||||
@@ -28,6 +28,7 @@
|
|||||||
<module>springboot-message</module>
|
<module>springboot-message</module>
|
||||||
<module>springboot-encrypt</module>
|
<module>springboot-encrypt</module>
|
||||||
<module>springboot-annotation</module>
|
<module>springboot-annotation</module>
|
||||||
|
<module>springboot-role</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
@@ -57,55 +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>1.1.3</version>
|
<version>2.0.0.rc22</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.1.3</version>
|
<version>2.0.0.rc22</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.1.3</version>
|
<version>2.0.0.rc22</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.1.3</version>
|
<version>2.0.0.rc22</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.1.3</version>
|
<version>2.0.0.rc22</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.1.3</version>
|
<version>2.0.0.rc22</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.1.3</version>
|
<version>2.0.0.rc22</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
|
<artifactId>springboot-role</artifactId>
|
||||||
|
<version>2.0.0.rc22</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.1.3</version>
|
<version>2.0.0.rc22</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.1.3</version>
|
<version>2.0.0.rc22</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
BIN
springboot-ademo/.DS_Store
vendored
@@ -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>1.1.3</version>
|
<version>2.0.0.rc22</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-ademo</artifactId>
|
<artifactId>springboot-ademo</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>2.0.0.rc22</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
@@ -26,11 +26,22 @@
|
|||||||
<artifactId>springboot-web</artifactId>
|
<artifactId>springboot-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
|
<artifactId>springboot-role</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>easyexcel</artifactId>
|
<artifactId>easyexcel</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>redis.clients</groupId>
|
||||||
|
<artifactId>jedis</artifactId>
|
||||||
|
<version>3.7.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
|||||||
BIN
springboot-ademo/src/main/java/com/tiesheng/.DS_Store
vendored
Normal file
BIN
springboot-ademo/src/main/java/com/tiesheng/demo/.DS_Store
vendored
Normal file
@@ -1,7 +1,7 @@
|
|||||||
package com.tiesheng.demo;
|
package com.tiesheng.demo;
|
||||||
|
|
||||||
|
|
||||||
import com.tiesheng.core.EnableTieshengWeb;
|
import com.tiesheng.web.EnableTieshengWeb;
|
||||||
import com.tiesheng.demo.config.DemoWebConfigurer;
|
import com.tiesheng.demo.config.DemoWebConfigurer;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
@@ -13,7 +13,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableTieshengWeb(webConfigurer = DemoWebConfigurer.class)
|
@EnableTieshengWeb(webConfigurer = DemoWebConfigurer.class)
|
||||||
//@EnableEncryptConfig
|
|
||||||
public class DemoApplication {
|
public class DemoApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
package com.tiesheng.demo.config;
|
package com.tiesheng.demo.config;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.tiesheng.core.pojos.RequestUserInfo;
|
import com.tiesheng.login.pojos.RequestUserInfo;
|
||||||
import com.tiesheng.core.pojos.dao.CorePlatformUnique;
|
import com.tiesheng.login.pojos.dao.CorePlatformUnique;
|
||||||
import com.tiesheng.core.service.TieshengWebConfigurer;
|
import com.tiesheng.login.service.TsLoginConfigurer;
|
||||||
import com.tiesheng.login.config.token.bean.TokenBean;
|
|
||||||
import com.tiesheng.util.config.GlobalConfig;
|
import com.tiesheng.util.config.GlobalConfig;
|
||||||
|
import com.tiesheng.util.pojos.TokenBean;
|
||||||
|
import com.tiesheng.web.service.TieshengWebConfigurer;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -13,24 +14,31 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DemoWebConfigurer implements TieshengWebConfigurer {
|
public class DemoWebConfigurer implements TieshengWebConfigurer, TsLoginConfigurer {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
GlobalConfig globalConfig;
|
GlobalConfig globalConfig;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RequestUserInfo getCurrentUserName(TokenBean tokenBean) {
|
public RequestUserInfo getCurrentUserName(TokenBean tokenBean) {
|
||||||
RequestUserInfo info = new RequestUserInfo();
|
RequestUserInfo info = new RequestUserInfo();
|
||||||
info.setId("1");
|
if (Objects.equals(tokenBean.getId(), "1")) {
|
||||||
info.setName("test");
|
return info;
|
||||||
|
}
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TokenBean login(CorePlatformUnique platformUnique) {
|
public TokenBean login(CorePlatformUnique platformUnique) {
|
||||||
TokenBean tokenBean = null;
|
TokenBean tokenBean = null;
|
||||||
if (!StrUtil.isEmpty(platformUnique.getUserId())) {
|
if (!StrUtil.isEmpty(platformUnique.getUserId())) {
|
||||||
tokenBean = new TokenBean(platformUnique.getUserId(), "", globalConfig.getService());
|
tokenBean = new TokenBean(platformUnique.getUserId(), "super");
|
||||||
|
} else if (Objects.equals(platformUnique.getUniqueId(), "1110290049")) {
|
||||||
|
tokenBean = new TokenBean("1", "super");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tokenBean != null) {
|
||||||
|
tokenBean.setExtra("1110290049");
|
||||||
}
|
}
|
||||||
|
|
||||||
return tokenBean;
|
return tokenBean;
|
||||||
@@ -39,13 +47,11 @@ public class DemoWebConfigurer implements TieshengWebConfigurer {
|
|||||||
@Override
|
@Override
|
||||||
public void redirect(TokenBean bean, String to, String extra, HttpServletResponse response) {
|
public void redirect(TokenBean bean, String to, String extra, HttpServletResponse response) {
|
||||||
|
|
||||||
// 默认跳转到mobile
|
|
||||||
to = StrUtil.emptyToDefault(to, "mobile");
|
|
||||||
bean.setEnvironmentType(to);
|
|
||||||
|
|
||||||
if (Objects.equals(bean.getEnvironmentType(), "mobile")) {
|
|
||||||
globalConfig.redirect("mobile", "/?token=" + bean.toToken(), response);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TsLoginConfigurer configureLogin() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
package com.tiesheng.demo.config;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class DemoWebMvcConfigurer implements WebMvcConfigurer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
||||||
registry.addResourceHandler("/mobile/**").addResourceLocations("classpath:/mobile/0.0.13/");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
//package com.tiesheng.demo.config;
|
|
||||||
//
|
|
||||||
//import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
|
||||||
//import org.springframework.security.core.GrantedAuthority;
|
|
||||||
//import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
|
||||||
//import org.springframework.security.core.context.SecurityContextHolder;
|
|
||||||
//import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
|
|
||||||
//import org.springframework.web.filter.OncePerRequestFilter;
|
|
||||||
//
|
|
||||||
//import javax.servlet.FilterChain;
|
|
||||||
//import javax.servlet.ServletException;
|
|
||||||
//import javax.servlet.http.HttpServletRequest;
|
|
||||||
//import javax.servlet.http.HttpServletResponse;
|
|
||||||
//import java.io.IOException;
|
|
||||||
//import java.util.ArrayList;
|
|
||||||
//import java.util.List;
|
|
||||||
//
|
|
||||||
//public class JWTAuthenticationFilter extends OncePerRequestFilter {
|
|
||||||
//
|
|
||||||
// public JWTAuthenticationFilter(JwtTokenProvider tokenProvider) {
|
|
||||||
// this.tokenProvider = tokenProvider;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
|
||||||
// String authHeader = request.getHeader("Authorization");
|
|
||||||
// if (authHeader != null && authHeader.startsWith("Bearer ")) {
|
|
||||||
// String token = authHeader.substring(7);
|
|
||||||
// String username = tokenProvider.getUsername(token);
|
|
||||||
// if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) {
|
|
||||||
// if (tokenProvider.validateToken(token)) {
|
|
||||||
// List<GrantedAuthority> authorities = new ArrayList<>();
|
|
||||||
// // 根据你的应用程序需求设置权限
|
|
||||||
// authorities.add(new SimpleGrantedAuthority("ROLE_USER"));
|
|
||||||
// UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, null, authorities);
|
|
||||||
// authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
|
|
||||||
// SecurityContextHolder.getContext().setAuthentication(authenticationToken);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// filterChain.doFilter(request, response);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
package com.tiesheng.demo.config;
|
package com.tiesheng.demo.config;
|
||||||
|
|
||||||
|
|
||||||
import com.tiesheng.core.service.CoreConfigService;
|
import com.tiesheng.web.service.CoreConfigService;
|
||||||
import com.tiesheng.core.service.CoreJobService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -14,19 +13,11 @@ import javax.annotation.PostConstruct;
|
|||||||
@Component
|
@Component
|
||||||
public class TestJobConfig {
|
public class TestJobConfig {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
CoreJobService coreJobService;
|
|
||||||
@Autowired
|
@Autowired
|
||||||
CoreConfigService coreConfigService;
|
CoreConfigService coreConfigService;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
|
|
||||||
coreConfigService.refreshFunc("230328001", "demo", "辅导员统计", "辅导员责任班级,学生展示");
|
|
||||||
|
|
||||||
// 辅导员职位
|
|
||||||
coreJobService.refresh("class_fdy", "辅导员", "辅导员", 1);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
//package com.tiesheng.demo.config;
|
|
||||||
//
|
|
||||||
//import cn.hutool.extra.spring.SpringUtil;
|
|
||||||
//import org.springframework.context.annotation.Configuration;
|
|
||||||
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
|
||||||
//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
|
||||||
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
|
||||||
//import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
|
||||||
//
|
|
||||||
//import javax.servlet.http.HttpServletResponse;
|
|
||||||
//
|
|
||||||
//@Configuration
|
|
||||||
//@EnableWebSecurity
|
|
||||||
//public class TieshengSecurityAdapter extends WebSecurityConfigurerAdapter {
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected void configure(HttpSecurity http) throws Exception {
|
|
||||||
// SpringUtil.getBeanFactory().getA
|
|
||||||
// http.csrf().disable() // JWT 通常与状态无关,因此 CSRF 保护不适用
|
|
||||||
// .authorizeRequests()
|
|
||||||
// .antMatchers("/login").permitAll() // 登录接口允许所有人访问
|
|
||||||
// .anyRequest().authenticated() // 其他所有请求需要认证
|
|
||||||
// .and()
|
|
||||||
// .exceptionHandling()
|
|
||||||
// .authenticationEntryPoint((request, response, authException) -> response.sendError(HttpServletResponse.SC_UNAUTHORIZED))
|
|
||||||
// .and()
|
|
||||||
// .addFilterBefore(new JWTAuthenticationFilter(tokenProvider), UsernamePasswordAuthenticationFilter.class);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -2,42 +2,45 @@ package com.tiesheng.demo.controller;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.date.TimeInterval;
|
import cn.hutool.core.date.TimeInterval;
|
||||||
import cn.hutool.json.JSONUtil;
|
|
||||||
import cn.hutool.log.LogFactory;
|
import cn.hutool.log.LogFactory;
|
||||||
import cn.hutool.poi.excel.ExcelUtil;
|
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.role.RoleAuthority;
|
||||||
import com.tiesheng.annotation.token.TokenIgnore;
|
import com.tiesheng.annotation.token.TokenIgnore;
|
||||||
import com.tiesheng.core.service.CoreLogService;
|
|
||||||
import com.tiesheng.core.service.CoreMessageService;
|
|
||||||
import com.tiesheng.core.util.ProcessImportConsumer;
|
|
||||||
import com.tiesheng.database.config.DbBackupConfig;
|
import com.tiesheng.database.config.DbBackupConfig;
|
||||||
import com.tiesheng.demo.pojos.PoiBean;
|
import com.tiesheng.demo.pojos.PoiBean;
|
||||||
import com.tiesheng.demo.pojos.TestFile;
|
import com.tiesheng.demo.pojos.TestFile;
|
||||||
import com.tiesheng.login.config.token.TsTokenConfig;
|
import com.tiesheng.platform.config.ding.PlatformDingConfig;
|
||||||
import com.tiesheng.message.pojos.MessageReqResp;
|
import com.tiesheng.platform.config.ding.bean.DingUserInfo;
|
||||||
import com.tiesheng.message.pojos.UserChannel;
|
|
||||||
import com.tiesheng.util.config.EncryptConfig;
|
import com.tiesheng.util.config.EncryptConfig;
|
||||||
import com.tiesheng.util.config.GlobalConfig;
|
import com.tiesheng.util.config.GlobalConfig;
|
||||||
import com.tiesheng.util.config.Ip2regionConfig;
|
import com.tiesheng.util.config.Ip2regionConfig;
|
||||||
|
import com.tiesheng.util.config.TsTokenConfig;
|
||||||
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 com.tiesheng.util.service.TsCacheService;
|
||||||
|
import com.tiesheng.web.service.CoreLogService;
|
||||||
|
import com.tiesheng.web.util.ProcessImportConsumer;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
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;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hao
|
* @author hao
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/test")
|
@RequestMapping("/test")
|
||||||
|
@RoleAuthority(value = "test", group = "test")
|
||||||
public class TestController {
|
public class TestController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -49,59 +52,75 @@ public class TestController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
EncryptConfig encryptConfig;
|
EncryptConfig encryptConfig;
|
||||||
@Autowired
|
@Autowired
|
||||||
CoreMessageService coreMessageService;
|
|
||||||
@Autowired
|
|
||||||
CoreLogService coreLogService;
|
CoreLogService coreLogService;
|
||||||
@Autowired
|
@Autowired
|
||||||
DbBackupConfig dbBackupConfig;
|
DbBackupConfig dbBackupConfig;
|
||||||
|
@Autowired
|
||||||
|
TsCacheService tsCacheService;
|
||||||
|
@Autowired
|
||||||
|
PlatformDingConfig platformDingConfig;
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping("/index")
|
@RequestMapping("/index")
|
||||||
public ApiResp<String> index() {
|
@TokenIgnore
|
||||||
return ApiResp.respOK("hello world");
|
public void index(HttpServletResponse response) {
|
||||||
|
globalConfig.redirect("mobile", "/test", response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/redirect")
|
@RequestMapping("/redirect")
|
||||||
@TokenIgnore
|
@TokenIgnore
|
||||||
public void redirect(HttpServletResponse response) {
|
@RoleAuthority("redirect")
|
||||||
|
public ApiResp<String> redirect(HttpServletResponse response) {
|
||||||
|
|
||||||
ArrayList<String> strings = CollUtil.newArrayList("11111", "22222");
|
// ArrayList<String> strings = CollUtil.newArrayList("11111", "22222");
|
||||||
coreLogService.addProcess("fdfd", strings, new ProcessImportConsumer<String>() {
|
// coreLogService.addProcess("fdfd", strings, new ProcessImportConsumer<String>() {
|
||||||
@Override
|
// @Override
|
||||||
public int accept(List<String> list) {
|
// public int accept(List<String> list) {
|
||||||
LogFactory.get().info("list: " + list.size());
|
// LogFactory.get().info("list: " + list.size());
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public String getFailFile() {
|
// public String getFailFile() {
|
||||||
LogFactory.get().info("getFailFile: " + strings.size());
|
// LogFactory.get().info("getFailFile: " + strings.size());
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
LogFactory.get().info("strings: " + strings.size());
|
// LogFactory.get().info("strings: " + strings.size());
|
||||||
|
|
||||||
|
|
||||||
// tsTokenConfig.validToken("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NzYwMDY4NzUsImlkIjoiMSIsImVudmlyb25tZW50VHlwZSI6Im1vYmlsZSIsInNlcnZpY2UiOiJjb250ZXN0LXJlc2VydmUiLCJleHRyYSI6IiJ9.nsfxEFpCNHC7eNCS5DJXdu1VDdnHrTjSfgrozND70Lc", true);
|
// tsTokenConfig.validToken("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NzYwMDY4NzUsImlkIjoiMSIsImVudmlyb25tZW50VHlwZSI6Im1vYmlsZSIsInNlcnZpY2UiOiJjb250ZXN0LXJlc2VydmUiLCJleHRyYSI6IiJ9.nsfxEFpCNHC7eNCS5DJXdu1VDdnHrTjSfgrozND70Lc", true);
|
||||||
globalConfig.redirect("mobile", "/test", response);
|
// globalConfig.redirect("mobile", "/test", response);
|
||||||
|
return ApiResp.respOK("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/send")
|
@GetMapping("/send")
|
||||||
@TokenIgnore
|
@TokenIgnore
|
||||||
public ApiResp<MessageReqResp> sendMessage() {
|
public ApiResp<String> sendMessage() {
|
||||||
|
|
||||||
MessageReqResp reqResp = coreMessageService.send(new UserChannel("13567116463", "sms"),
|
// MessageReqResp reqResp = coreMessageService.send(new UserChannel("13567116463", "sms"),
|
||||||
JSONUtil.createObj().putOpt("action", "sms-visitor-invite"));
|
// JSONUtil.createObj().putOpt("action", "sms-visitor-invite"));
|
||||||
|
|
||||||
return ApiResp.respOK(reqResp);
|
return ApiResp.respOK(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping("/export")
|
@RequestMapping("/export")
|
||||||
|
@TokenIgnore
|
||||||
public ApiResp<String> export() {
|
public ApiResp<String> export() {
|
||||||
|
|
||||||
|
// tsCacheService.put("fdfhdfd", "fdfdfdfd");
|
||||||
|
// String s = tsCacheService.get("fdfhdfd");
|
||||||
|
// LogFactory.get().info("export: " + s);
|
||||||
|
|
||||||
|
platformDingConfig.syncDeptUser("", null, new Consumer<DingUserInfo>() {
|
||||||
|
@Override
|
||||||
|
public void accept(DingUserInfo dingUserInfo) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// List<TestFile> list = new ArrayList<>();
|
// List<TestFile> list = new ArrayList<>();
|
||||||
// list.add(new TestFile("11111"));
|
// list.add(new TestFile("11111"));
|
||||||
// list.add(new TestFile("22222"));
|
// list.add(new TestFile("22222"));
|
||||||
@@ -122,14 +141,13 @@ public class TestController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping("searchIP")
|
@PostMapping("searchIP")
|
||||||
@TokenIgnore
|
@TokenIgnore
|
||||||
public ApiResp<String> searchIp() {
|
public ApiResp<String> searchIp() {
|
||||||
String search = ip2regionConfig.search("127.0.0.1");
|
String search = ip2regionConfig.search("127.0.0.1");
|
||||||
return ApiResp.respOK(search);
|
return ApiResp.respOK(search);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping("desensitize")
|
@RequestMapping("desensitize")
|
||||||
@TokenIgnore
|
@TokenIgnore
|
||||||
public ApiResp<List<TestFile>> desensitize() {
|
public ApiResp<List<TestFile>> desensitize() {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import cn.hutool.core.date.DateUtil;
|
|||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.tiesheng.message.config.aliyun.AliyunSmsHandler;
|
import com.tiesheng.message.config.aliyun.AliyunSmsHandler;
|
||||||
import com.tiesheng.message.pojos.AliyunTempParam;
|
import com.tiesheng.message.config.aliyun.AliyunTempParam;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|||||||
@@ -7,8 +7,16 @@ spring:
|
|||||||
url: jdbc:mysql://47.96.30.85:3306/com_tiesheng_web?useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&queryTimeout=5400&allowMultiQueries=true&serverTimezone=GMT%2B8
|
url: jdbc:mysql://47.96.30.85:3306/com_tiesheng_web?useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&queryTimeout=5400&allowMultiQueries=true&serverTimezone=GMT%2B8
|
||||||
username: com_tiesheng_web
|
username: com_tiesheng_web
|
||||||
password: 4Xo$XheGFc
|
password: 4Xo$XheGFc
|
||||||
|
# redis:
|
||||||
|
# url: redis://kyF0zUL3011111@47.96.30.85:6234
|
||||||
|
|
||||||
platform:
|
platform:
|
||||||
|
ding:
|
||||||
|
global:
|
||||||
|
corpId: dingebe664cb3baf3a52a39a90f97fcb1e09
|
||||||
|
agentId: 2474444028
|
||||||
|
appKey: dingyvf1niiajfaajyo5
|
||||||
|
appSecret: y6SGZ4fvPbdbj4RVbDWLeMBkGgplaOdnTA_9wN5TDdOV_Y47alYc1LDlIHjsBJE1
|
||||||
wxmp:
|
wxmp:
|
||||||
global:
|
global:
|
||||||
app-id: wxa0343fe519824651
|
app-id: wxa0343fe519824651
|
||||||
@@ -18,12 +26,14 @@ tiesheng:
|
|||||||
token:
|
token:
|
||||||
test-map:
|
test-map:
|
||||||
"1111":
|
"1111":
|
||||||
id: "1111"
|
id: "1"
|
||||||
|
role-id: "super"
|
||||||
global:
|
global:
|
||||||
version: 2
|
version: 2
|
||||||
host: http://localhost:8100
|
host: http://localhost:8100
|
||||||
|
service: demo
|
||||||
aliyun:
|
aliyun:
|
||||||
access-key-id: LTAI5tJtbgBCnTY5eS4SmrTf
|
access-key-id: LTAI5tJtbgBCnTY5eS4SmrTf
|
||||||
access-key-secret: JIHqpRUFffCHhXaJEVvWN31WcexWqG
|
access-key-secret: JIHqpRUFffCHhXaJEVvWN31WcexWqG
|
||||||
encrypt:
|
encrypt:
|
||||||
body: true
|
body: false
|
||||||
|
|||||||
@@ -13,16 +13,9 @@ spring:
|
|||||||
web:
|
web:
|
||||||
resources:
|
resources:
|
||||||
static-locations: classpath:/static/,file:static/
|
static-locations: classpath:/static/,file:static/
|
||||||
mvc:
|
|
||||||
pathmatch:
|
|
||||||
matching-strategy: ant_path_matcher
|
|
||||||
|
|
||||||
## 日志
|
## 日志
|
||||||
logging:
|
logging:
|
||||||
file:
|
file:
|
||||||
name: runtime/logs/tiesheng.log
|
name: runtime/logs/tiesheng.log
|
||||||
tiesheng:
|
|
||||||
token:
|
|
||||||
ignore-paths:
|
|
||||||
- /test/index
|
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8.9 KiB |
@@ -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.1.3</version>
|
<version>2.0.0.rc22</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-annotation</artifactId>
|
<artifactId>springboot-annotation</artifactId>
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.tiesheng.annotation.role;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
@Target({ElementType.METHOD, ElementType.TYPE})
|
||||||
|
@Documented
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface RoleAuthority {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编号
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String value();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台类型
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String platform() default "web";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分组
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String[] group() default {};
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.tiesheng.annotation.role;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
@Target({ElementType.METHOD})
|
||||||
|
@Documented
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface RoleIgnore {
|
||||||
|
}
|
||||||
BIN
springboot-database/.DS_Store
vendored
Normal 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.1.3</version>
|
<version>2.0.0.rc22</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-database</artifactId>
|
<artifactId>springboot-database</artifactId>
|
||||||
|
|||||||
BIN
springboot-encrypt/.DS_Store
vendored
Normal 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.1.3</version>
|
<version>2.0.0.rc22</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-encrypt</artifactId>
|
<artifactId>springboot-encrypt</artifactId>
|
||||||
|
|||||||
BIN
springboot-login/.DS_Store
vendored
Normal 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.1.3</version>
|
<version>2.0.0.rc22</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-login</artifactId>
|
<artifactId>springboot-login</artifactId>
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.tiesheng.login;
|
|
||||||
|
|
||||||
import com.tiesheng.platform.PlatformAutoConfigurer;
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
import org.springframework.context.annotation.Import;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author hao
|
|
||||||
*/
|
|
||||||
|
|
||||||
@ComponentScan({
|
|
||||||
"com.tiesheng.login.**.*",
|
|
||||||
})
|
|
||||||
@Import(PlatformAutoConfigurer.class)
|
|
||||||
public class LoginAutoConfigurer {
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
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.login.pojos.RequestUserInfo;
|
||||||
|
import com.tiesheng.login.service.TsLoginConfigurer;
|
||||||
|
import com.tiesheng.util.config.TsTokenConfig;
|
||||||
|
import com.tiesheng.util.exception.ApiException;
|
||||||
|
import com.tiesheng.util.pojos.TokenBean;
|
||||||
|
import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController;
|
||||||
|
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;
|
||||||
|
@Resource
|
||||||
|
TsLoginConfigurer tsLoginConfigurer;
|
||||||
|
|
||||||
|
@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;
|
||||||
|
if (handlerMethod.getBeanType() == BasicErrorController.class) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
TokenIgnore annotation = handlerMethod.getBeanType().getAnnotation(TokenIgnore.class);
|
||||||
|
if (annotation != null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
TokenIgnore apiTokenIgnore = handlerMethod.getMethodAnnotation(TokenIgnore.class);
|
||||||
|
if (apiTokenIgnore != null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证TOKEN是否存在
|
||||||
|
TokenBean tokenBean = tsTokenConfig.validToken(request, true);
|
||||||
|
|
||||||
|
// 验证用户是否存在
|
||||||
|
RequestUserInfo cachedUserInfo = tsLoginConfigurer.getCachedUserInfo(tokenBean);
|
||||||
|
if (cachedUserInfo == null) {
|
||||||
|
throw new ApiException("非法TOKEN,请重新登录");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
package com.tiesheng.login.config.token;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import com.tiesheng.annotation.token.TokenIgnore;
|
|
||||||
import com.tiesheng.util.ServletKit;
|
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -6,13 +6,11 @@ import cn.hutool.core.util.URLUtil;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.tiesheng.annotation.operation.OperationIgnore;
|
import com.tiesheng.annotation.operation.OperationIgnore;
|
||||||
import com.tiesheng.annotation.token.TokenIgnore;
|
import com.tiesheng.annotation.token.TokenIgnore;
|
||||||
import com.tiesheng.login.config.token.TsTokenConfig;
|
|
||||||
import com.tiesheng.login.config.token.bean.TokenBean;
|
|
||||||
import com.tiesheng.login.pojos.CodeExtraDTO;
|
import com.tiesheng.login.pojos.CodeExtraDTO;
|
||||||
import com.tiesheng.login.pojos.DoLoginInfo;
|
import com.tiesheng.login.pojos.DoLoginInfo;
|
||||||
import com.tiesheng.login.pojos.UniqueIndexDTO;
|
import com.tiesheng.login.pojos.UniqueIndexDTO;
|
||||||
import com.tiesheng.login.pojos.WxminiLoginVo;
|
import com.tiesheng.login.pojos.WxminiLoginVo;
|
||||||
import com.tiesheng.login.service.TieshengLoginConfigurer;
|
import com.tiesheng.login.service.CorePlatformUniqueService;
|
||||||
import com.tiesheng.platform.config.ding.PlatformDingConfig;
|
import com.tiesheng.platform.config.ding.PlatformDingConfig;
|
||||||
import com.tiesheng.platform.config.ding.bean.DingJsapiSignature;
|
import com.tiesheng.platform.config.ding.bean.DingJsapiSignature;
|
||||||
import com.tiesheng.platform.config.ding.bean.DingUserInfo;
|
import com.tiesheng.platform.config.ding.bean.DingUserInfo;
|
||||||
@@ -23,8 +21,10 @@ import com.tiesheng.platform.config.wxmp.bean.WxConfigBean;
|
|||||||
import com.tiesheng.platform.config.wxmp.bean.WxJsapiSignature;
|
import com.tiesheng.platform.config.wxmp.bean.WxJsapiSignature;
|
||||||
import com.tiesheng.platform.config.wxmp.bean.WxUserInfo;
|
import com.tiesheng.platform.config.wxmp.bean.WxUserInfo;
|
||||||
import com.tiesheng.util.config.GlobalConfig;
|
import com.tiesheng.util.config.GlobalConfig;
|
||||||
|
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.TokenBean;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ public class LoginController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
PlatformWxminiConfig platformWxminiConfig;
|
PlatformWxminiConfig platformWxminiConfig;
|
||||||
@Autowired
|
@Autowired
|
||||||
TieshengLoginConfigurer tieshengLoginConfigurer;
|
CorePlatformUniqueService corePlatformUniqueService;
|
||||||
@Autowired
|
@Autowired
|
||||||
GlobalConfig globalConfig;
|
GlobalConfig globalConfig;
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -65,13 +65,13 @@ public class LoginController {
|
|||||||
@OperationIgnore
|
@OperationIgnore
|
||||||
public void uniqueIndex(UniqueIndexDTO dto, HttpServletResponse response) {
|
public void uniqueIndex(UniqueIndexDTO dto, HttpServletResponse response) {
|
||||||
if (tsTokenConfig.isValidLoginSign() && !dto.validSign()) {
|
if (tsTokenConfig.isValidLoginSign() && !dto.validSign()) {
|
||||||
tieshengLoginConfigurer.onSignError(response);
|
corePlatformUniqueService.onSignError(response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo("web_unique_redirect",
|
TokenBean tokenBean = corePlatformUniqueService.login(new DoLoginInfo("web_unique_redirect",
|
||||||
dto.getNo(), dto.getPlatform(), dto.getInfo()));
|
dto.getNo(), dto.getPlatform(), dto.getInfo()));
|
||||||
tieshengLoginConfigurer.onLoginRedirect(tokenBean, dto.getTo(), dto.getExtra(), response);
|
corePlatformUniqueService.redirect(tokenBean, dto.getTo(), dto.getExtra(), response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ public class LoginController {
|
|||||||
@PostMapping("/unique/index")
|
@PostMapping("/unique/index")
|
||||||
@OperationIgnore
|
@OperationIgnore
|
||||||
public ApiResp<String> uniqueIndex(@RequestBody UniqueIndexDTO dto) {
|
public ApiResp<String> uniqueIndex(@RequestBody UniqueIndexDTO dto) {
|
||||||
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo("web_unique_index",
|
TokenBean tokenBean = corePlatformUniqueService.login(new DoLoginInfo("web_unique_index",
|
||||||
dto.getNo(), dto.getPlatform(), dto.getInfo()));
|
dto.getNo(), dto.getPlatform(), dto.getInfo()));
|
||||||
if (tokenBean == null || StrUtil.isEmpty(tokenBean.getId())) {
|
if (tokenBean == null || StrUtil.isEmpty(tokenBean.getId())) {
|
||||||
throw new ApiException("登录失败");
|
throw new ApiException("登录失败");
|
||||||
@@ -134,9 +134,9 @@ public class LoginController {
|
|||||||
public void dingOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) {
|
public void dingOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) {
|
||||||
DingUserSimple userSimple = platformDingConfig.getUserIdByCode(service, dto.getCode());
|
DingUserSimple userSimple = platformDingConfig.getUserIdByCode(service, dto.getCode());
|
||||||
DingUserInfo dingUserInfo = platformDingConfig.topapiV2UserGet(service, userSimple.getUserid());
|
DingUserInfo dingUserInfo = platformDingConfig.topapiV2UserGet(service, userSimple.getUserid());
|
||||||
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo(dingUserInfo.getAppId(),
|
TokenBean tokenBean = corePlatformUniqueService.login(new DoLoginInfo(dingUserInfo.getAppId(),
|
||||||
dingUserInfo.getUserid(), "ding", JSON.toJSONString(dingUserInfo)));
|
dingUserInfo.getUserid(), "ding", JSON.toJSONString(dingUserInfo)));
|
||||||
tieshengLoginConfigurer.onLoginRedirect(tokenBean, dto.getTo(), dto.getExtra(), response);
|
corePlatformUniqueService.redirect(tokenBean, dto.getTo(), dto.getExtra(), response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -182,9 +182,9 @@ public class LoginController {
|
|||||||
@OperationIgnore
|
@OperationIgnore
|
||||||
public void wxmpOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) {
|
public void wxmpOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) {
|
||||||
WxUserInfo wxUserInfo = platformWxmpConfig.getOAuth2AccessToken(service, dto.getCode());
|
WxUserInfo wxUserInfo = platformWxmpConfig.getOAuth2AccessToken(service, dto.getCode());
|
||||||
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo(wxUserInfo.getAppId(),
|
TokenBean tokenBean = corePlatformUniqueService.login(new DoLoginInfo(wxUserInfo.getAppId(),
|
||||||
wxUserInfo.getOpenid(), "wxmp", JSON.toJSONString(wxUserInfo)));
|
wxUserInfo.getOpenid(), "wxmp", JSON.toJSONString(wxUserInfo)));
|
||||||
tieshengLoginConfigurer.onLoginRedirect(tokenBean, dto.getTo(), dto.getExtra(), response);
|
corePlatformUniqueService.redirect(tokenBean, dto.getTo(), dto.getExtra(), response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ public class LoginController {
|
|||||||
public ApiResp<WxminiLoginVo> wxminiIndex(@PathVariable String service, String code) {
|
public ApiResp<WxminiLoginVo> wxminiIndex(@PathVariable String service, String code) {
|
||||||
String openid = platformWxminiConfig.jscode2session(service, code);
|
String openid = platformWxminiConfig.jscode2session(service, code);
|
||||||
WxConfigBean configBean = platformWxminiConfig.getConfigBean(service);
|
WxConfigBean configBean = platformWxminiConfig.getConfigBean(service);
|
||||||
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo(configBean.getAppId(),
|
TokenBean tokenBean = corePlatformUniqueService.login(new DoLoginInfo(configBean.getAppId(),
|
||||||
openid, "wxmini", "{}"));
|
openid, "wxmini", "{}"));
|
||||||
|
|
||||||
WxminiLoginVo loginVo = new WxminiLoginVo();
|
WxminiLoginVo loginVo = new WxminiLoginVo();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.tiesheng.core.mapper;
|
package com.tiesheng.login.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.tiesheng.core.pojos.dao.CoreLogLogin;
|
import com.tiesheng.login.pojos.dao.CoreLogLogin;
|
||||||
|
|
||||||
public interface CoreLogLoginMapper extends BaseMapper<CoreLogLogin> {
|
public interface CoreLogLoginMapper extends BaseMapper<CoreLogLogin> {
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.tiesheng.core.mapper;
|
package com.tiesheng.login.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.tiesheng.core.pojos.dao.CorePlatformUnique;
|
import com.tiesheng.login.pojos.dao.CorePlatformUnique;
|
||||||
|
|
||||||
public interface CorePlatformUniqueMapper extends BaseMapper<CorePlatformUnique> {
|
public interface CorePlatformUniqueMapper extends BaseMapper<CorePlatformUnique> {
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.tiesheng.core.pojos;
|
package com.tiesheng.login.pojos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前token的数据
|
* 当前token的数据
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.tiesheng.core.pojos.dao;
|
package com.tiesheng.login.pojos.dao;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.tiesheng.core.pojos.DaoBase;
|
import com.tiesheng.util.pojos.DaoBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日志-登录
|
* 日志-登录
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
package com.tiesheng.core.pojos.dao;
|
package com.tiesheng.login.pojos.dao;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.tiesheng.core.pojos.DaoBase;
|
import com.tiesheng.util.pojos.DaoBase;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 平台-唯一值
|
* 平台-唯一值
|
||||||
@@ -131,4 +128,4 @@ public class CorePlatformUnique extends DaoBase {
|
|||||||
public void setInfo(String info) {
|
public void setInfo(String info) {
|
||||||
this.info = info;
|
this.info = info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
package com.tiesheng.login.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.extra.servlet.ServletUtil;
|
||||||
|
import com.tiesheng.login.mapper.CoreLogLoginMapper;
|
||||||
|
import com.tiesheng.login.mapper.CorePlatformUniqueMapper;
|
||||||
|
import com.tiesheng.login.pojos.DoLoginInfo;
|
||||||
|
import com.tiesheng.login.pojos.RequestUserInfo;
|
||||||
|
import com.tiesheng.login.pojos.dao.CoreLogLogin;
|
||||||
|
import com.tiesheng.login.pojos.dao.CorePlatformUnique;
|
||||||
|
import com.tiesheng.util.ServletKit;
|
||||||
|
import com.tiesheng.util.config.Ip2regionConfig;
|
||||||
|
import com.tiesheng.util.pojos.TokenBean;
|
||||||
|
import com.tiesheng.util.service.TsServiceBase;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hao
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CorePlatformUniqueService extends TsServiceBase<CorePlatformUniqueMapper, CorePlatformUnique> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
CoreLogLoginMapper coreLogLoginMapper;
|
||||||
|
@Resource
|
||||||
|
Ip2regionConfig ip2regionConfig;
|
||||||
|
@Resource
|
||||||
|
TsLoginConfigurer tsLoginConfigurer;
|
||||||
|
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public TokenBean login(DoLoginInfo loginInfo) {
|
||||||
|
|
||||||
|
CorePlatformUnique platformUnique = getOneByColumn("unique_id", loginInfo.getUnique());
|
||||||
|
if (platformUnique == null) {
|
||||||
|
platformUnique = new CorePlatformUnique();
|
||||||
|
platformUnique.setAppId(loginInfo.getAppId());
|
||||||
|
platformUnique.setUniqueId(loginInfo.getUnique());
|
||||||
|
}
|
||||||
|
platformUnique.setPlatform(loginInfo.getPlatform());
|
||||||
|
platformUnique.setInfo(loginInfo.getInfo());
|
||||||
|
saveOrUpdate(platformUnique);
|
||||||
|
|
||||||
|
String oldUserId = platformUnique.getUserId();
|
||||||
|
TokenBean tokenBean = tsLoginConfigurer.login(platformUnique);
|
||||||
|
if (tokenBean != null) {
|
||||||
|
|
||||||
|
// 添加登录日志
|
||||||
|
addLoginLog(platformUnique, tokenBean);
|
||||||
|
|
||||||
|
// 更新唯一值
|
||||||
|
if (!StrUtil.isEmpty(tokenBean.getId()) &&
|
||||||
|
!Objects.equals(oldUserId, tokenBean.getId())) {
|
||||||
|
platformUnique.setUserId(tokenBean.getId());
|
||||||
|
saveOrUpdate(platformUnique);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tokenBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 授权登录回调
|
||||||
|
*
|
||||||
|
* @param bean
|
||||||
|
*/
|
||||||
|
public void redirect(TokenBean bean, String to, String extra, HttpServletResponse response) {
|
||||||
|
tsLoginConfigurer.redirect(bean, to, extra, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 签名错误的时候
|
||||||
|
*/
|
||||||
|
public void onSignError(HttpServletResponse response) {
|
||||||
|
tsLoginConfigurer.onSignError(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// 登录日志
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加登录日志
|
||||||
|
*
|
||||||
|
* @param platformUnique
|
||||||
|
* @param tokenBean
|
||||||
|
*/
|
||||||
|
public void addLoginLog(CorePlatformUnique platformUnique, TokenBean tokenBean) {
|
||||||
|
|
||||||
|
HttpServletRequest request = ServletKit.getRequest();
|
||||||
|
String ip = ServletUtil.getClientIP(request);
|
||||||
|
|
||||||
|
CoreLogLogin login = new CoreLogLogin();
|
||||||
|
login.setUserId(tokenBean.getId());
|
||||||
|
login.setPlatform(platformUnique.getPlatform());
|
||||||
|
|
||||||
|
RequestUserInfo requestUserInfo = tsLoginConfigurer.getCachedUserInfo(tokenBean);
|
||||||
|
login.setUserName(requestUserInfo.getName());
|
||||||
|
|
||||||
|
login.setIp(ip);
|
||||||
|
login.setAddress(ip2regionConfig.search(login.getIp()));
|
||||||
|
coreLogLoginMapper.insert(login);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package com.tiesheng.login.service;
|
|
||||||
|
|
||||||
import com.tiesheng.login.config.token.bean.TokenBean;
|
|
||||||
import com.tiesheng.login.pojos.DoLoginInfo;
|
|
||||||
import com.tiesheng.util.ServletKit;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author hao
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public interface TieshengLoginConfigurer {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 执行登录
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
TokenBean doLogin(DoLoginInfo loginInfo);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 授权登录回调
|
|
||||||
*
|
|
||||||
* @param bean
|
|
||||||
*/
|
|
||||||
void onLoginRedirect(TokenBean bean, String to, String extra, HttpServletResponse response);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 签名错误的时候
|
|
||||||
*/
|
|
||||||
void onSignError(HttpServletResponse response);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package com.tiesheng.login.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.extra.servlet.ServletUtil;
|
||||||
|
import com.tiesheng.login.pojos.RequestUserInfo;
|
||||||
|
import com.tiesheng.login.pojos.dao.CorePlatformUnique;
|
||||||
|
import com.tiesheng.util.config.TsTokenConfig;
|
||||||
|
import com.tiesheng.util.pojos.TokenBean;
|
||||||
|
import com.tiesheng.util.service.TsCacheService;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hao
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public interface TsLoginConfigurer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行登录
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
TokenBean login(CorePlatformUnique platformUnique);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 授权登录回调
|
||||||
|
*
|
||||||
|
* @param bean
|
||||||
|
*/
|
||||||
|
void redirect(TokenBean bean, String to, String extra, HttpServletResponse response);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 签名错误的时候
|
||||||
|
*/
|
||||||
|
default void onSignError(HttpServletResponse response) {
|
||||||
|
ServletUtil.write(response, "404", "text");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前用户的信息
|
||||||
|
*
|
||||||
|
* @param tokenBean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
default RequestUserInfo getCachedUserInfo(TokenBean tokenBean) {
|
||||||
|
String key = StrUtil.format(TsTokenConfig.CACHE_REQUEST_LOGIN_KEY, tokenBean.getId());
|
||||||
|
RequestUserInfo obj = TsCacheService.of().getObj(key, RequestUserInfo.class, -1);
|
||||||
|
if (obj == null) {
|
||||||
|
obj = getCurrentUserName(tokenBean);
|
||||||
|
}
|
||||||
|
if (obj != null) {
|
||||||
|
TsCacheService.of().putObj(key, obj, 30 * 60);
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前用户的姓名
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
RequestUserInfo getCurrentUserName(TokenBean userId);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package com.tiesheng.login.service.impl;
|
|
||||||
|
|
||||||
import com.tiesheng.login.config.token.bean.TokenBean;
|
|
||||||
import com.tiesheng.login.pojos.DoLoginInfo;
|
|
||||||
import com.tiesheng.login.service.TieshengLoginConfigurer;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author hao
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
@ConditionalOnMissingBean(value = TieshengLoginConfigurer.class, ignored = DefaultLoginConfigurer.class)
|
|
||||||
public class DefaultLoginConfigurer implements TieshengLoginConfigurer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TokenBean doLogin(DoLoginInfo loginInfo) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoginRedirect(TokenBean bean, String to, String extra, HttpServletResponse response) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSignError(HttpServletResponse response) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,24 @@
|
|||||||
SET NAMES utf8mb4;
|
SET NAMES utf8mb4;
|
||||||
SET FOREIGN_KEY_CHECKS = 0;
|
SET FOREIGN_KEY_CHECKS = 0;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for core_log_login
|
||||||
|
-- ----------------------------
|
||||||
|
CREATE TABLE `core_log_login`
|
||||||
|
(
|
||||||
|
`id` varchar(50) NOT NULL,
|
||||||
|
`create_time` datetime NOT NULL,
|
||||||
|
`update_time` datetime NOT NULL,
|
||||||
|
`is_deleted` int(6) NOT NULL DEFAULT '0',
|
||||||
|
`user_id` varchar(50) DEFAULT NULL COMMENT '用户id',
|
||||||
|
`user_name` varchar(255) DEFAULT NULL COMMENT '用户姓名',
|
||||||
|
`platform` varchar(50) DEFAULT NULL COMMENT '登录方式',
|
||||||
|
`ip` varchar(100) DEFAULT NULL COMMENT 'ip',
|
||||||
|
`address` varchar(255) DEFAULT NULL COMMENT 'ip地址',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE = InnoDB
|
||||||
|
DEFAULT CHARSET = utf8mb4 COMMENT ='日志-登录';
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for core_platform_unique
|
-- Table structure for core_platform_unique
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.tiesheng.core.mapper.CoreLogLoginMapper">
|
<mapper namespace="com.tiesheng.login.mapper.CoreLogLoginMapper">
|
||||||
<resultMap id="BaseResultMap" type="com.tiesheng.core.pojos.dao.CoreLogLogin">
|
<resultMap id="BaseResultMap" type="com.tiesheng.login.pojos.dao.CoreLogLogin">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
<!--@Table core_log_login-->
|
<!--@Table core_log_login-->
|
||||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.tiesheng.core.mapper.CorePlatformUniqueMapper">
|
<mapper namespace="com.tiesheng.login.mapper.CorePlatformUniqueMapper">
|
||||||
<resultMap id="BaseResultMap" type="com.tiesheng.core.pojos.dao.CorePlatformUnique">
|
<resultMap id="BaseResultMap" type="com.tiesheng.login.pojos.dao.CorePlatformUnique">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
<!--@Table core_platform_unique-->
|
<!--@Table core_platform_unique-->
|
||||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||||
@@ -18,4 +18,4 @@
|
|||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
id, create_time, update_time, is_deleted, user_id, app_id, unique_id, platform, info
|
id, create_time, update_time, is_deleted, user_id, app_id, unique_id, platform, info
|
||||||
</sql>
|
</sql>
|
||||||
</mapper>
|
</mapper>
|
||||||