Compare commits

..

77 Commits

Author SHA1 Message Date
曾文豪
6127cd50a9 publish 2.0.0.rc10 2024-07-29 09:53:44 +08:00
曾文豪
19f4d0395e publish 2.0.0.rc9 2024-07-29 09:42:53 +08:00
曾文豪
d52edbb23c perf:钉钉对接调整 2024-07-26 16:12:29 +08:00
曾文豪
6c6d713c01 publish 2.0.0.rc8 2024-07-25 17:35:51 +08:00
曾文豪
8ea34c3ee0 perf:移除TimedCacheService、TimedCacheHelper,新增TsCacheService,同时实现了内存缓存、Redis缓存 2024-07-25 17:35:01 +08:00
曾文豪
d357fa7c85 publish 2.0.0.rc7 2024-07-12 11:17:04 +08:00
曾文豪
6332d1486b publish 2.0.0.rc6 2024-07-12 11:16:46 +08:00
曾文豪
e709050ba3 publish 2.0.0.rc6 2024-07-11 16:03:07 +08:00
曾文豪
59926aa2f4 publish 2.0.0.rc5 2024-07-11 15:37:03 +08:00
曾文豪
5da83bb477 publish 2.0.0.rc4 2024-07-11 15:21:59 +08:00
曾文豪
fb1f7c4e37 perf:移除matching-strategy属性 2024-07-04 16:22:46 +08:00
曾文豪
f831f4faf0 publish 2.0.0.rc3 2024-07-03 14:01:53 +08:00
曾文豪
d7016b418e perf:操作日志执行批量插入 2024-07-03 13:57:10 +08:00
曾文豪
fd92109e2e fix:角色列表和角色授权bug 2024-07-03 13:31:23 +08:00
曾文豪
c9679eeeac publish 2.0.0.rc2 2024-06-28 10:57:08 +08:00
曾文豪
08a3c52f34 publish 2.0.0.rc1 2024-06-26 10:22:33 +08:00
曾文豪
5a25006189 fix:修复授权过期的bug 2024-06-26 10:19:30 +08:00
曾文豪
093d39a108 feat:web模块包名调整 2024-06-26 10:13:42 +08:00
曾文豪
c0ded4356f feat:移除功能点 2024-06-26 10:11:19 +08:00
曾文豪
8f7d543c8b feat:移除job类的接口、方法 2024-06-26 10:08:29 +08:00
曾文豪
67bb6041c6 feat:sql导入 2024-06-26 10:00:47 +08:00
曾文豪
78cb8dafeb perf:调整获取自己的功能点 2024-06-26 09:03:36 +08:00
曾文豪
d77eb50a5b feat:提交角色授权 2024-06-25 23:23:50 +08:00
曾文豪
aee4fa86f6 feat;增加角色模块 2024-06-25 18:51:29 +08:00
曾文豪
a10b57f6fc feat;增加角色模块 2024-06-25 18:46:13 +08:00
曾文豪
d2229e0028 feat;增加角色模块 2024-06-25 18:32:08 +08:00
曾文豪
80cd48b97c feat;增加角色模块 2024-06-24 19:15:47 +08:00
曾文豪
0e6bee4714 publish 1.1.5 2024-06-19 13:54:11 +08:00
曾文豪
ae67cc53ec Merge branch 'new_characterUtils' into 'master'
优化移除特殊字符方法

See merge request tiesheng/tiesheng!5
2024-06-19 05:53:24 +00:00
‘毛文春’
419cb06ff6 feat:新增字符串处理工具类 2024-06-19 13:53:01 +08:00
曾文豪
384ac928e3 publish 1.1.4 2024-06-19 13:46:50 +08:00
曾文豪
130cd45de2 Merge branch 'new_CharacterUtil' into 'master'
新增字符串处理工具类

See merge request tiesheng/tiesheng!4
2024-06-19 05:45:11 +00:00
‘毛文春’
6840faa9d8 feat:新增字符串处理工具类 2024-06-19 13:44:53 +08:00
曾文豪
b6caecf140 publish 1.1.3 2024-06-11 16:11:14 +08:00
曾文豪
fdcb1614cc test:测试一下接口 2024-04-22 14:22:43 +08:00
曾文豪
88bc553213 publish 1.1.2 2024-04-17 13:56:38 +08:00
曾文豪
5942c4cea4 publish 1.1.1 2024-04-17 13:46:51 +08:00
曾文豪
ef34146563 publish 1.1.0 2024-04-16 20:00:41 +08:00
曾文豪
1c8bc648ea Revert "publish 1.0.24-test2"
This reverts commit b4334f4a5b.
2024-04-15 13:57:07 +08:00
曾文豪
144ca50fea Revert "publish 1.0.24-test3"
This reverts commit 1d2cabb048.
2024-04-15 13:56:55 +08:00
曾文豪
1d2cabb048 publish 1.0.24-test3 2024-04-15 13:36:50 +08:00
曾文豪
b4334f4a5b publish 1.0.24-test2 2024-04-15 13:09:00 +08:00
曾文豪
ce44e4a05a Revert "publish 1.0.24-test"
This reverts commit a7024f7a8d.
2024-04-15 12:34:59 +08:00
曾文豪
a7024f7a8d publish 1.0.24-test 2024-04-15 12:31:15 +08:00
曾文豪
c2fe494ed9 publish 1.0.24 2024-04-13 10:51:03 +08:00
曾文豪
07de3f6ba7 feat:获取系统配置增加一个方法 2024-04-13 10:50:37 +08:00
曾文豪
1c521e5378 fix:修复token是否有效的判定条件 2024-04-13 10:45:57 +08:00
曾文豪
e98e98d659 publish 1.0.23 2024-02-28 09:36:58 +08:00
曾文豪
75d052bd0c perf:钉钉工作通知的内容完全自定义 2024-02-28 09:36:21 +08:00
曾文豪
3758826987 perf:更新一个文案 2024-02-23 16:17:17 +08:00
曾文豪
8a4cf8e439 publish 1.0.22 2024-01-31 17:34:25 +08:00
曾文豪
09203ac78d publish 1.0.21 2024-01-31 17:06:54 +08:00
曾文豪
ef5861327c publish 1.0.20 2024-01-24 13:42:17 +08:00
曾文豪
23faaa8f67 publish 1.0.19 2024-01-11 11:29:45 +08:00
曾文豪
341c82e0bc perf:创建时间可以自行设置 2024-01-11 11:29:03 +08:00
曾文豪
d2d53523a8 publish 1.0.18 2024-01-09 17:51:27 +08:00
曾文豪
fc00bad49a publish 1.0.17 2023-12-27 15:46:16 +08:00
曾文豪
6dd4e19e39 publish 1.0.16 2023-12-06 16:43:31 +08:00
曾文豪
4373ec7c0e publish 1.0.15 2023-11-20 16:23:18 +08:00
曾文豪
5cc135d8e2 fix:兼容windows服务器的路径问题 2023-11-20 16:22:49 +08:00
曾文豪
69a9681b48 publish 1.0.14 2023-08-22 09:29:12 +08:00
曾文豪
6c39dc24bd chore:更新ci 2023-08-22 09:28:06 +08:00
曾文豪
952341918a publish 1.0.13 2023-08-21 15:29:18 +08:00
曾文豪
5dde3e3e9f publish 1.1.0 2023-08-21 15:21:54 +08:00
曾文豪
c5c7afd7f6 feat:globalConfig增加ext属性 2023-08-21 15:11:47 +08:00
曾文豪
ceb13dc78d perf:删除其他代码 2023-08-14 15:48:55 +08:00
曾文豪
0fabc7aae9 perf:优化部分代码 2023-08-14 15:43:48 +08:00
曾文豪
28a2fa0262 perf:增加网络请求超时、重定向的配置 2023-08-10 18:10:49 +08:00
曾文豪
cc3ab52885 perf:过程中保存错误日志,而不是在最后保存,方式错误日志丢失 2023-08-10 18:07:27 +08:00
曾文豪
027587ae02 perf:更新数据库对比插件 2023-08-10 17:55:09 +08:00
曾文豪
353851a0aa perf:/operation/page接口需要鉴权 2023-07-19 10:39:45 +08:00
曾文豪
1db6d88e4e feat(web):增加DaoBase的常量 2023-07-11 10:05:53 +08:00
曾文豪
7e69138ef7 feat(web):增加DaoBase的常量 2023-07-11 10:05:27 +08:00
曾文豪
ea211b1bfc chore:更新日志 2023-07-11 09:03:16 +08:00
曾文豪
101270e881 perf(web):操作日志优化
1,不再返回params字段
2,params字段有text改为longtext
2023-07-11 08:58:48 +08:00
曾文豪
a658298363 perf:优化slat长度的校验 2023-07-10 09:44:07 +08:00
曾文豪
65beecc330 docs: 文档调整 2023-07-05 14:14:33 +08:00
224 changed files with 3475 additions and 1743 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -1,23 +1,10 @@
stages: stages:
- deploy - deploy
- package
build-jar:
stage: deploy
tags:
- hzkepai
rules:
- if: $CI_COMMIT_BRANCH == "master"
script:
- mvn clean package -Dmaven.test.skip=true
- systemctl stop tieshengboot-ademo
- cp springboot-ademo/target/*.jar /usr/local/nginx/html/demo.tmp.kepai365.ltd/
- systemctl start tieshengboot-ademo
deploy-jar: deploy-jar:
stage: deploy stage: deploy
tags: tags:
- hzkepai - zengos
rules: rules:
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
script: script:

View File

@@ -1,84 +1,7 @@
## 1.0.10 ## 2.0.0.rc4
- feat(login):登录接口增加验签步骤,可通过**validLoginSign**属性开启或关闭(默认)。 - perfTsTokenConfig不在提供静态方法
- perf(login):可重写**onSignError**方法自定义验签错误的跳转。 - perf移除TsTokenAspect由TokenWebMvcConfigurer替代并实现TokenBean参数注入
- 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**

29
pom.xml
View File

@@ -6,7 +6,7 @@
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>1.0.12</version> <version>2.0.0.rc10</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.0.12</version> <version>2.0.0.rc10</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-login</artifactId> <artifactId>springboot-login</artifactId>
<version>1.0.12</version> <version>2.0.0.rc10</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-web</artifactId> <artifactId>springboot-web</artifactId>
<version>1.0.12</version> <version>2.0.0.rc10</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-util</artifactId> <artifactId>springboot-util</artifactId>
<version>1.0.12</version> <version>2.0.0.rc10</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-platform</artifactId> <artifactId>springboot-platform</artifactId>
<version>1.0.12</version> <version>2.0.0.rc10</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-message</artifactId> <artifactId>springboot-message</artifactId>
<version>1.0.12</version> <version>2.0.0.rc10</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-encrypt</artifactId> <artifactId>springboot-encrypt</artifactId>
<version>1.0.12</version> <version>2.0.0.rc10</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-role</artifactId>
<version>2.0.0.rc10</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-annotation</artifactId> <artifactId>springboot-annotation</artifactId>
<version>1.0.12</version> <version>2.0.0.rc10</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-poi</artifactId> <artifactId>springboot-poi</artifactId>
<version>1.0.12</version> <version>2.0.0.rc10</version>
</dependency> </dependency>
<dependency> <dependency>
@@ -136,7 +143,7 @@
<plugin> <plugin>
<groupId>com.tiesheng.springboot-plugin</groupId> <groupId>com.tiesheng.springboot-plugin</groupId>
<artifactId>tiesheng-maven-plugin</artifactId> <artifactId>tiesheng-maven-plugin</artifactId>
<version>0.0.6</version> <version>1.0.0</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>

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>1.0.12</version> <version>2.0.0.rc10</version>
</parent> </parent>
<artifactId>springboot-ademo</artifactId> <artifactId>springboot-ademo</artifactId>
<version>1.1.0</version> <version>2.0.0.rc10</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>

Binary file not shown.

Binary file not shown.

View 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) {

View File

@@ -1,10 +1,10 @@
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.web.pojos.RequestUserInfo;
import com.tiesheng.core.pojos.dao.CorePlatformUnique; import com.tiesheng.web.pojos.dao.CorePlatformUnique;
import com.tiesheng.core.service.TieshengWebConfigurer; import com.tiesheng.web.service.TieshengWebConfigurer;
import com.tiesheng.login.config.token.bean.TokenBean; import com.tiesheng.util.pojos.TokenBean;
import com.tiesheng.util.config.GlobalConfig; import com.tiesheng.util.config.GlobalConfig;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -31,9 +31,6 @@ public class DemoWebConfigurer implements TieshengWebConfigurer {
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(), "", globalConfig.getService());
} else {
// 获取用户信息判断是否可登录
} }
return tokenBean; return tokenBean;
@@ -43,11 +40,11 @@ public class DemoWebConfigurer implements TieshengWebConfigurer {
public void redirect(TokenBean bean, String to, String extra, HttpServletResponse response) { public void redirect(TokenBean bean, String to, String extra, HttpServletResponse response) {
// 默认跳转到mobile // 默认跳转到mobile
to = StrUtil.emptyToDefault(to, "mobile"); to = StrUtil.emptyToDefault(to, "static/mobile");
bean.setEnvironmentType(to); bean.setEnvironmentType(to);
if (Objects.equals(bean.getEnvironmentType(), "mobile")) { if (Objects.equals(bean.getEnvironmentType(), "static/mobile")) {
globalConfig.redirect("mobile", "/?token=" + bean.toToken(), response); globalConfig.redirect("static/mobile", "/?token=" + bean.toToken(), response);
} }
} }

View File

@@ -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);
} }
} }

View File

@@ -8,27 +8,28 @@ import cn.hutool.poi.excel.ExcelUtil;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener; import com.alibaba.excel.read.listener.ReadListener;
import com.tiesheng.annotation.operation.OperationLog;
import com.tiesheng.annotation.token.TokenIgnore; import com.tiesheng.annotation.token.TokenIgnore;
import com.tiesheng.core.service.CoreLogService;
import com.tiesheng.core.service.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.message.pojos.MessageReqResp; import com.tiesheng.message.pojos.MessageReqResp;
import com.tiesheng.message.pojos.UserChannel; 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.service.CoreMessageService;
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.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;
@@ -54,12 +55,14 @@ public class TestController {
CoreLogService coreLogService; CoreLogService coreLogService;
@Autowired @Autowired
DbBackupConfig dbBackupConfig; DbBackupConfig dbBackupConfig;
@Autowired
TsCacheService tsCacheService;
@RequestMapping("/index") @RequestMapping("/index")
public ApiResp<String> index() { @TokenIgnore
dbBackupConfig.dbBackup(); public void index(HttpServletResponse response) {
return ApiResp.respOK("hello world"); globalConfig.redirect("mobile", "/test", response);
} }
@RequestMapping("/redirect") @RequestMapping("/redirect")
@@ -94,15 +97,20 @@ public class TestController {
public ApiResp<MessageReqResp> sendMessage() { public ApiResp<MessageReqResp> sendMessage() {
MessageReqResp reqResp = coreMessageService.send(new UserChannel("13567116463", "sms"), MessageReqResp reqResp = coreMessageService.send(new UserChannel("13567116463", "sms"),
JSONUtil.createObj().putOpt("code", "123456").putOpt("template_code", "SMS_154950909")); JSONUtil.createObj().putOpt("action", "sms-visitor-invite"));
return ApiResp.respOK(reqResp); return ApiResp.respOK(reqResp);
} }
@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);
// 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"));

View File

@@ -0,0 +1,32 @@
package com.tiesheng.demo.service;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.tiesheng.message.config.aliyun.AliyunSmsHandler;
import com.tiesheng.message.pojos.AliyunTempParam;
import org.springframework.stereotype.Service;
import java.util.Objects;
@Service
public class DemoSmsHandler implements AliyunSmsHandler {
@Override
public AliyunTempParam handler(JSONObject obj) {
String action = obj.getStr("action");
AliyunTempParam param = new AliyunTempParam();
param.setSignName("智慧校园");
if (Objects.equals(action, "sms-visitor-invite")) {
param.setTemplateCode("SMS_276125463");
param.setTemplateParam(JSONUtil.createObj()
.putOpt("date", DateUtil.today())
);
}
return param;
}
}

View File

@@ -7,6 +7,8 @@ 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:
wxmp: wxmp:
@@ -19,10 +21,12 @@ tiesheng:
test-map: test-map:
"1111": "1111":
id: "1111" id: "1111"
role-id: "student_bks"
global: global:
version: 2 version: 2
host: http://localhost:8100 host: http://localhost:8100
aliyun: aliyun:
access-key-id: LTAI5tJtbgBCnTY5eS4SmrTf access-key-id: LTAI5tJtbgBCnTY5eS4SmrTf
access-key-secret: JIHqpRUFffCHhXaJEVvWN31WcexWqG access-key-secret: JIHqpRUFffCHhXaJEVvWN31WcexWqG
sign-name: 阿里云短信测试 encrypt:
body: false

View File

@@ -9,18 +9,13 @@ spring:
servlet: servlet:
multipart: multipart:
max-file-size: 20MB max-file-size: 20MB
max-request-size: 20MB
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

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
springboot-annotation/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>1.0.12</version> <version>2.0.0.rc10</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>1.0.12</version> <version>2.0.0.rc10</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>1.0.12</version> <version>2.0.0.rc10</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>1.0.12</version> <version>2.0.0.rc10</version>
</parent> </parent>
<artifactId>springboot-login</artifactId> <artifactId>springboot-login</artifactId>

View File

@@ -0,0 +1,110 @@
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.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;
@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验证
tsTokenConfig.validToken(request, true);
return true;
}
});
}
}

View File

@@ -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);
}
}

View File

@@ -6,8 +6,8 @@ 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.util.config.TsTokenConfig;
import com.tiesheng.login.config.token.bean.TokenBean; import com.tiesheng.util.pojos.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;
@@ -16,6 +16,7 @@ import com.tiesheng.login.service.TieshengLoginConfigurer;
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;
import com.tiesheng.platform.config.ding.bean.DingUserSimple;
import com.tiesheng.platform.config.wxmini.PlatformWxminiConfig; import com.tiesheng.platform.config.wxmini.PlatformWxminiConfig;
import com.tiesheng.platform.config.wxmp.PlatformWxmpConfig; import com.tiesheng.platform.config.wxmp.PlatformWxmpConfig;
import com.tiesheng.platform.config.wxmp.bean.WxConfigBean; import com.tiesheng.platform.config.wxmp.bean.WxConfigBean;
@@ -85,7 +86,7 @@ public class LoginController {
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 = tieshengLoginConfigurer.doLogin(new DoLoginInfo("web_unique_index",
dto.getNo(), dto.getPlatform(), dto.getInfo())); dto.getNo(), dto.getPlatform(), dto.getInfo()));
if (tokenBean == null) { if (tokenBean == null || StrUtil.isEmpty(tokenBean.getId())) {
throw new ApiException("登录失败"); throw new ApiException("登录失败");
} }
return ApiResp.respOK(tokenBean.toToken()); return ApiResp.respOK(tokenBean.toToken());
@@ -113,6 +114,7 @@ public class LoginController {
map.put("corpId", platformDingConfig.getConfigBean(service).getCorpId()); map.put("corpId", platformDingConfig.getConfigBean(service).getCorpId());
map.put("service", service); map.put("service", service);
map.put("extra", extra); map.put("extra", extra);
map.put("context", globalConfig.getContextPath());
String query = URLUtil.buildQuery(map, Charset.defaultCharset()); String query = URLUtil.buildQuery(map, Charset.defaultCharset());
String configUrl = globalConfig.buildPath("/ding/index.html?" + query); String configUrl = globalConfig.buildPath("/ding/index.html?" + query);
try { try {
@@ -130,8 +132,8 @@ public class LoginController {
@RequestMapping("/ding/oauth2/{service}") @RequestMapping("/ding/oauth2/{service}")
@OperationIgnore @OperationIgnore
public void dingOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) { public void dingOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) {
String ddUserId = platformDingConfig.getUserIdByCode(service, dto.getCode()); DingUserSimple userSimple = platformDingConfig.getUserIdByCode(service, dto.getCode());
DingUserInfo dingUserInfo = platformDingConfig.topapiV2UserGet(service, ddUserId); DingUserInfo dingUserInfo = platformDingConfig.topapiV2UserGet(service, userSimple.getUserid());
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo(dingUserInfo.getAppId(), TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo(dingUserInfo.getAppId(),
dingUserInfo.getUserid(), "ding", JSON.toJSONString(dingUserInfo))); dingUserInfo.getUserid(), "ding", JSON.toJSONString(dingUserInfo)));
tieshengLoginConfigurer.onLoginRedirect(tokenBean, dto.getTo(), dto.getExtra(), response); tieshengLoginConfigurer.onLoginRedirect(tokenBean, dto.getTo(), dto.getExtra(), response);

View File

@@ -1,8 +1,7 @@
package com.tiesheng.login.service; package com.tiesheng.login.service;
import com.tiesheng.login.config.token.bean.TokenBean; import com.tiesheng.util.pojos.TokenBean;
import com.tiesheng.login.pojos.DoLoginInfo; import com.tiesheng.login.pojos.DoLoginInfo;
import com.tiesheng.util.ServletKit;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;

View File

@@ -1,6 +1,6 @@
package com.tiesheng.login.service.impl; package com.tiesheng.login.service.impl;
import com.tiesheng.login.config.token.bean.TokenBean; import com.tiesheng.util.pojos.TokenBean;
import com.tiesheng.login.pojos.DoLoginInfo; import com.tiesheng.login.pojos.DoLoginInfo;
import com.tiesheng.login.service.TieshengLoginConfigurer; import com.tiesheng.login.service.TieshengLoginConfigurer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;

View File

@@ -24,10 +24,10 @@
corpId: getQueryString("corpId"), corpId: getQueryString("corpId"),
onSuccess: function (result) { onSuccess: function (result) {
let search = window.location.search + "&code=" + result.code; let search = window.location.search + "&code=" + result.code;
window.location.href = "/login/ding/oauth2/" + getQueryString("service") + search; window.location.replace(getQueryString("context") + "/login/ding/oauth2/" + getQueryString("service") + search);
}, },
onFail: function (err) { onFail: function (err) {
window.location.href = "./error.html?message=" + JSON.stringify(err); window.location.replace("./error.html?message=" + JSON.stringify(err));
} }
}) })

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>1.0.12</version> <version>2.0.0.rc10</version>
</parent> </parent>
<artifactId>springboot-message</artifactId> <artifactId>springboot-message</artifactId>

View File

@@ -0,0 +1,16 @@
package com.tiesheng.message.config.aliyun;
import cn.hutool.json.JSONObject;
import com.tiesheng.message.pojos.AliyunTempParam;
public interface AliyunSmsHandler {
/**
* 数据处理
*
* @param obj
*/
AliyunTempParam handler(JSONObject obj);
}

View File

@@ -1,14 +1,18 @@
package com.tiesheng.message.config.aliyun; package com.tiesheng.message.config.aliyun;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil; import cn.hutool.crypto.SecureUtil;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.tiesheng.message.pojos.AliyunTempParam;
import com.tiesheng.message.pojos.MessageReqResp; import com.tiesheng.message.pojos.MessageReqResp;
import com.tiesheng.message.service.TieshengMessageSender; import com.tiesheng.message.service.TieshengMessageSender;
import com.tiesheng.util.exception.ApiException;
import org.springframework.beans.factory.annotation.Autowired;
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;
@@ -36,7 +40,9 @@ public class AliyunSmsSender implements TieshengMessageSender {
private String accessKeyId; private String accessKeyId;
private String accessKeySecret; private String accessKeySecret;
private String signName;
@Autowired(required = false)
AliyunSmsHandler aliyunSmsHandler;
/** /**
* 特殊字符替换 * 特殊字符替换
@@ -94,7 +100,16 @@ public class AliyunSmsSender implements TieshengMessageSender {
String signature = specialUrlEncode(digest); String signature = specialUrlEncode(digest);
queryMap.put("Signature", signature); queryMap.put("Signature", signature);
return HttpUtil.get(ENDPOINT + "?Signature=" + signature + sortQueryStringTmp, 10 * 1000); String respBody = "";
try {
respBody = HttpUtil.get(ENDPOINT + "?Signature=" + signature + sortQueryStringTmp, 10 * 1000);
} catch (Exception e) {
respBody = JSONUtil.createObj()
.putOpt("Code", "Error")
.putOpt("Message", "消息通道异常")
.toString();
}
return respBody;
} }
@@ -102,29 +117,28 @@ public class AliyunSmsSender implements TieshengMessageSender {
* 创建发送请求 * 创建发送请求
* *
* @param phoneNumbers 手机号,多个用,隔开 * @param phoneNumbers 手机号,多个用,隔开
* @param templateCode 短信模板 * @param tempParam 短信模板
* @param params 模板参数
* @return * @return
*/ */
public MessageReqResp sendSms(String phoneNumbers, String templateCode, JSONObject params) { public MessageReqResp sendSms(String phoneNumbers, AliyunTempParam tempParam) {
MessageReqResp reqResp = new MessageReqResp("阿里云短信"); MessageReqResp reqResp = new MessageReqResp("阿里云短信");
reqResp.setTarget(phoneNumbers); reqResp.setTarget(phoneNumbers);
reqResp.setResult(1); reqResp.setResult(1);
reqResp.setContent(JSONUtil.createObj() reqResp.setContent(JSONUtil.createObj()
.putOpt("PhoneNumbers", phoneNumbers) .putOpt("PhoneNumbers", phoneNumbers)
.putOpt("SignName", getSignName()) .putOpt("SignName", tempParam.getSignName())
.putOpt("TemplateCode", templateCode) .putOpt("TemplateCode", tempParam.getTemplateCode())
.putOpt("TemplateParam", params) .putOpt("TemplateParam", tempParam.getTemplateParam())
.toString()); .toString());
// 业务API参数 // 业务API参数
ConcurrentHashMap<String, String> queryMap = new ConcurrentHashMap<>(); ConcurrentHashMap<String, String> queryMap = new ConcurrentHashMap<>();
queryMap.put("PhoneNumbers", phoneNumbers); queryMap.put("PhoneNumbers", phoneNumbers);
queryMap.put("SignName", getSignName()); queryMap.put("SignName", tempParam.getSignName());
queryMap.put("TemplateCode", templateCode); queryMap.put("TemplateCode", tempParam.getTemplateCode());
if (params != null) { if (tempParam.getTemplateParam() != null) {
queryMap.put("TemplateParam", params.toString()); queryMap.put("TemplateParam", tempParam.getTemplateParam().toString());
} }
reqResp.setRespBody(request("SendSms", queryMap)); reqResp.setRespBody(request("SendSms", queryMap));
@@ -139,7 +153,21 @@ public class AliyunSmsSender implements TieshengMessageSender {
@Override @Override
public MessageReqResp send(String user, JSONObject body) { public MessageReqResp send(String user, JSONObject body) {
return sendSms(user, body.getStr("template_code"), body); boolean mobile = Validator.isMobile(user);
if (!mobile) {
return null;
}
if (aliyunSmsHandler == null) {
throw new ApiException("未注册短信参数处理器");
}
AliyunTempParam tempParam = aliyunSmsHandler.handler(body);
if (tempParam == null) {
throw new ApiException("未配置短信参数处理器");
}
return sendSms(user, tempParam);
} }
@Override @Override
@@ -149,7 +177,7 @@ public class AliyunSmsSender implements TieshengMessageSender {
@Override @Override
public boolean support() { public boolean support() {
return StrUtil.isAllNotEmpty(accessKeyId, accessKeySecret, signName); return StrUtil.isAllNotEmpty(accessKeyId, accessKeySecret);
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@@ -172,12 +200,5 @@ public class AliyunSmsSender implements TieshengMessageSender {
this.accessKeySecret = accessKeySecret; this.accessKeySecret = accessKeySecret;
} }
public String getSignName() {
return signName;
}
public void setSignName(String signName) {
this.signName = signName;
}
} }

View File

@@ -0,0 +1,38 @@
package com.tiesheng.message.pojos;
import cn.hutool.json.JSONObject;
public class AliyunTempParam {
private String signName;
private String templateCode;
private JSONObject templateParam;
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
public String getSignName() {
return signName;
}
public void setSignName(String signName) {
this.signName = signName;
}
public String getTemplateCode() {
return templateCode;
}
public void setTemplateCode(String templateCode) {
this.templateCode = templateCode;
}
public JSONObject getTemplateParam() {
return templateParam;
}
public void setTemplateParam(JSONObject templateParam) {
this.templateParam = templateParam;
}
}

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

View File

@@ -5,17 +5,21 @@ import cn.hutool.core.lang.TypeReference;
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.http.HttpRequest; import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.hutool.log.LogFactory; import cn.hutool.log.LogFactory;
import com.tiesheng.platform.config.ding.bean.*; import com.tiesheng.platform.config.ding.bean.*;
import com.tiesheng.util.TimedCacheHelper;
import com.tiesheng.util.exception.ApiException; import com.tiesheng.util.exception.ApiException;
import com.tiesheng.util.service.TsCacheService;
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 java.util.*; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
/** /**
@@ -48,6 +52,46 @@ public class PlatformDingConfig {
return bean; return bean;
} }
/**
* 发送get请求
* 会自动增加accessToken在url上面
*
* @param service
* @return
*/
public <T> DingResponse<T> doRequest(String service, String url, JSONObject body, TypeReference<DingResponse<T>> typeReference) {
String accessToken = getAccessToken(service);
if (StrUtil.contains(url, "?")) {
url = url + "&access_token=" + accessToken;
} else {
url = url + "?access_token=" + accessToken;
}
HttpRequest request;
if (body == null) {
request = HttpUtil.createGet(url);
} else {
request = HttpUtil.createPost(url).body(body.toString());
}
request.header("x-acs-dingtalk-access-token", accessToken);
HttpResponse execute = request.execute();
if (execute.isOk()) {
String rawBody = execute.body();
DingResponse<T> bean = JSONUtil.toBean(rawBody, typeReference, true);
if (!bean.isOk()) {
LogFactory.get().info(bean.getErrmsg());
}
bean.setRawBody(rawBody);
return bean;
}
return null;
}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// 逻辑方法 // 逻辑方法
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@@ -60,7 +104,7 @@ public class PlatformDingConfig {
*/ */
private String getAccessToken(String service) { private String getAccessToken(String service) {
DingConfigBean dingConfigBean = getConfigBean(service); DingConfigBean dingConfigBean = getConfigBean(service);
String accessToken = TimedCacheHelper.getTimedCache().get(CACHE_ACCESS_TOKEN + dingConfigBean.getAppKey(), false); String accessToken = TsCacheService.of().get(CACHE_ACCESS_TOKEN + dingConfigBean.getAppKey(), -1);
if (!StrUtil.isEmpty(accessToken)) { if (!StrUtil.isEmpty(accessToken)) {
return accessToken; return accessToken;
} }
@@ -72,7 +116,8 @@ public class PlatformDingConfig {
String response = HttpUtil.get("https://oapi.dingtalk.com/gettoken", query); String response = HttpUtil.get("https://oapi.dingtalk.com/gettoken", query);
JSONObject respJson = JSONUtil.parseObj(response); JSONObject respJson = JSONUtil.parseObj(response);
accessToken = respJson.getStr("access_token"); accessToken = respJson.getStr("access_token");
TimedCacheHelper.getTimedCache().put(CACHE_ACCESS_TOKEN + dingConfigBean.getAppKey(), accessToken, respJson.getLong("expires_in")); TsCacheService.of().put(CACHE_ACCESS_TOKEN + dingConfigBean.getAppKey(),
accessToken, respJson.getLong("expires_in"));
return accessToken; return accessToken;
} }
@@ -86,16 +131,18 @@ public class PlatformDingConfig {
*/ */
private String getJsapiTicket(String service) { private String getJsapiTicket(String service) {
DingConfigBean dingConfigBean = getConfigBean(service); DingConfigBean dingConfigBean = getConfigBean(service);
String jsapiTicket = TimedCacheHelper.getTimedCache().get(CACHE_JSAPI_TICKET + dingConfigBean.getAppKey(), false); String jsapiTicket = TsCacheService.of().get(CACHE_JSAPI_TICKET + dingConfigBean.getAppKey(), -1);
if (StrUtil.isEmpty(jsapiTicket)) { if (StrUtil.isEmpty(jsapiTicket)) {
String response = HttpUtil.get("https://oapi.dingtalk.com/get_jsapi_ticket?access_token=" + getAccessToken(service)); DingResponse<String> respJson = doRequest(service, "https://oapi.dingtalk.com/get_jsapi_ticket", null,
LogFactory.get().info("getJsapiTicket: " + response); new TypeReference<DingResponse<String>>() {
JSONObject respJson = JSONUtil.parseObj(response); });
if (!Objects.equals(respJson.getStr("errcode"), "0")) { if (!respJson.isOk()) {
throw new ApiException(respJson.getStr("errmsg")); throw new ApiException(respJson.getErrmsg());
} }
jsapiTicket = respJson.getStr("ticket");
TimedCacheHelper.getTimedCache().put(CACHE_JSAPI_TICKET + dingConfigBean.getAppKey(), jsapiTicket, respJson.getLong("expires_in")); jsapiTicket = respJson.getRawValue("ticket", String.class);
TsCacheService.of().put(CACHE_JSAPI_TICKET + dingConfigBean.getAppKey(),
jsapiTicket, respJson.getExpiresIn());
} }
return jsapiTicket; return jsapiTicket;
} }
@@ -124,10 +171,11 @@ public class PlatformDingConfig {
* @return * @return
* @see <a href="https://open.dingtalk.com/document/isvapp-server/obtain-the-userid-of-a-user-by-using-the-log-free"></a> * @see <a href="https://open.dingtalk.com/document/isvapp-server/obtain-the-userid-of-a-user-by-using-the-log-free"></a>
*/ */
public String getUserIdByCode(String service, String code) { public DingUserSimple getUserIdByCode(String service, String code) {
String response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/user/getuserinfo?access_token=" + getAccessToken(service)) DingResponse<DingUserSimple> resp = doRequest(service, "https://oapi.dingtalk.com/topapi/v2/user/getuserinfo",
.body(JSONUtil.createObj().putOpt("code", code).toString()).execute().body(); JSONUtil.createObj().putOpt("code", code), new TypeReference<DingResponse<DingUserSimple>>() {
return JSONUtil.parseObj(response).getJSONObject("result").getStr("userid"); });
return resp.getResult();
} }
@@ -141,13 +189,12 @@ public class PlatformDingConfig {
*/ */
public DingUserInfo topapiV2UserGet(String service, String ddUserId) { public DingUserInfo topapiV2UserGet(String service, String ddUserId) {
DingConfigBean dingConfigBean = getConfigBean(service); DingConfigBean dingConfigBean = getConfigBean(service);
String response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/user/get?access_token=" + getAccessToken(service))
.body(JSONUtil.createObj().putOpt("userid", ddUserId).toString()).execute().body();
JSONObject resultJson = JSONUtil.parseObj(response).getJSONObject("result");
DingUserInfo userInfo = JSONUtil.toBean(resultJson, DingUserInfo.class);
DingUserInfo userInfo = doRequest(service, "https://oapi.dingtalk.com/topapi/v2/user/get",
JSONUtil.createObj().putOpt("userid", ddUserId), new TypeReference<DingResponse<DingUserInfo>>() {
}).getResult();
// 设置一下job_number // 设置一下job_number
userInfo.setJobNumber(resultJson.getStr("job_number")); userInfo.setJobNumber(userInfo.getJobNumber());
userInfo.setAppId(dingConfigBean.getAppKey()); userInfo.setAppId(dingConfigBean.getAppKey());
return userInfo; return userInfo;
} }
@@ -164,15 +211,10 @@ public class PlatformDingConfig {
if (StrUtil.isEmpty(token)) { if (StrUtil.isEmpty(token)) {
return new ArrayList<>(); return new ArrayList<>();
} }
String response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/department/listsub?access_token=" + token)
.body(JSONUtil.createObj().putOpt("dept_id", deptId).toString()).execute().body();
DingResponse<List<DingDeptVo>> result = JSONUtil.toBean(response, new TypeReference<DingResponse<List<DingDeptVo>>>() {
}.getType(), true);
if (!result.isOk()) { return doRequest(service, "https://oapi.dingtalk.com/topapi/v2/department/listsub",
result.setResult(new ArrayList<>()); JSONUtil.createObj().putOpt("dept_id", deptId), new TypeReference<DingResponse<List<DingDeptVo>>>() {
} }).getResult();
return result.getResult();
} }
@@ -188,19 +230,16 @@ public class PlatformDingConfig {
return DingUserListVo.fail(); return DingUserListVo.fail();
} }
String response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/user/list?access_token=" + token) return doRequest(service, "https://oapi.dingtalk.com/topapi/v2/user/list",
.body(JSONUtil.createObj().putOpt("dept_id", deptId).putOpt("cursor", cursor).putOpt("size", 100).toString()) JSONUtil.createObj().putOpt("dept_id", deptId).putOpt("cursor", cursor).putOpt("size", 100),
.execute().body(); new TypeReference<DingResponse<DingUserListVo>>() {
DingResponse<DingUserListVo> result = JSONUtil.toBean(response, new TypeReference<DingResponse<DingUserListVo>>() { }).getResult();
}.getType(), true);
if (!result.isOk()) {
result.setResult(DingUserListVo.fail());
}
return result.getResult();
} }
/** /**
* 同步钉钉的通讯录 * 同步钉钉的通讯录
* <br />
* PS如果需要钉钉用户手机号需要开通权限企业员工手机号信息
* *
* @param deptVo 为null时从第一级获取 * @param deptVo 为null时从第一级获取
* @param consumer 回调 * @param consumer 回调
@@ -236,39 +275,45 @@ public class PlatformDingConfig {
* 发送工作通知 * 发送工作通知
* *
* @param service * @param service
* @param content * @param title
* @param markdown
* @param actionUrl * @param actionUrl
* @param userIds * @param userIds
* @return
*/ */
public void messageNotification(String service, String title, String content, String actionUrl, List<String> userIds) { public DingResponse<String> messageNotification(String service, String title, String markdown, String actionUrl, List<String> userIds) {
if (CollUtil.isEmpty(userIds)) { if (CollUtil.isEmpty(userIds)) {
return; return null;
} }
DingConfigBean configBean = getConfigBean(service); DingConfigBean configBean = getConfigBean(service);
JSONObject actionCard = new JSONObject(); JSONObject actionCard = new JSONObject();
actionCard.set("title", title); actionCard.set("title", title);
actionCard.set("markdown", "### " + title + "\n" + content); actionCard.set("markdown", markdown);
actionCard.set("single_title", "点击查看");
actionCard.set("single_url", actionUrl); if (StrUtil.isNotEmpty(actionUrl)) {
actionCard.set("single_title", "点击查看");
actionCard.set("single_url", actionUrl);
}
JSONObject msg = new JSONObject(); JSONObject msg = new JSONObject();
msg.set("msgtype", "action_card"); msg.set("msgtype", "action_card");
msg.set("action_card", actionCard); msg.set("action_card", actionCard);
HashMap<String, Object> body = new HashMap<>(10); JSONObject body = new JSONObject();
body.put("agent_id", configBean.getAgentId()); body.putOpt("agent_id", configBean.getAgentId());
body.put("userid_list", CollUtil.join(userIds, ",")); body.putOpt("userid_list", CollUtil.join(userIds, ","));
body.put("msg", msg); body.putOpt("msg", msg);
String resp = HttpUtil.post("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2?access_token=" + getAccessToken(service), return doRequest(service, "https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2", body,
JSONUtil.toJsonStr(body)); new TypeReference<DingResponse<String>>() {
});
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// setter\getter // setter\getter
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
public Map<String, DingConfigBean> getConfigs() { public Map<String, DingConfigBean> getConfigs() {
return configs; return configs;

View File

@@ -1,12 +1,16 @@
package com.tiesheng.platform.config.ding.bean; package com.tiesheng.platform.config.ding.bean;
import cn.hutool.json.JSONUtil;
import java.util.Objects; import java.util.Objects;
public class DingResponse<T> { public class DingResponse<T> {
private String errcode; private String errcode;
private String errmsg; private String errmsg;
private Long expiresIn;
private T result; private T result;
private String rawBody;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// 逻辑方法 // 逻辑方法
@@ -16,6 +20,17 @@ public class DingResponse<T> {
return Objects.equals(errcode, "0"); return Objects.equals(errcode, "0");
} }
/**
* 从原始数据中获取值
*
* @param path
* @return
*/
public T getRawValue(String path, Class<T> tClass) {
return JSONUtil.parse(getRawBody()).getByPath(path, tClass);
}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// setter\getter // setter\getter
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@@ -43,4 +58,20 @@ public class DingResponse<T> {
public void setResult(T result) { public void setResult(T result) {
this.result = result; this.result = result;
} }
public Long getExpiresIn() {
return expiresIn;
}
public void setExpiresIn(Long expiresIn) {
this.expiresIn = expiresIn;
}
public String getRawBody() {
return rawBody;
}
public void setRawBody(String rawBody) {
this.rawBody = rawBody;
}
} }

View File

@@ -6,10 +6,8 @@ import java.util.List;
/** /**
* @author hao * @author hao
*/ */
public class DingUserInfo { public class DingUserInfo extends DingUserSimple {
private String name;
private String userid;
private String avatar; private String avatar;
private String mobile; private String mobile;
private String email; private String email;
@@ -17,7 +15,6 @@ public class DingUserInfo {
private String nickname; private String nickname;
private String title; private String title;
private String remark; private String remark;
private String unionid;
private String appId; private String appId;
private List<String> deptIdList; private List<String> deptIdList;
private boolean leader; private boolean leader;
@@ -34,30 +31,6 @@ public class DingUserInfo {
// setter\getter // setter\getter
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUnionid() {
return unionid;
}
public void setUnionid(String unionid) {
this.unionid = unionid;
}
public String getUserid() {
return userid;
}
public void setUserid(String userid) {
this.userid = userid;
}
public String getAvatar() { public String getAvatar() {
return avatar; return avatar;
} }

View File

@@ -0,0 +1,32 @@
package com.tiesheng.platform.config.ding.bean;
public class DingUserSimple {
private String unionid;
private String name;
private String userid;
public String getUnionid() {
return unionid;
}
public void setUnionid(String unionid) {
this.unionid = unionid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUserid() {
return userid;
}
public void setUserid(String userid) {
this.userid = userid;
}
}

View File

@@ -3,6 +3,7 @@ package com.tiesheng.platform.config.wxmini;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.tiesheng.platform.config.wxmp.bean.WxConfigBean; import com.tiesheng.platform.config.wxmp.bean.WxConfigBean;
@@ -50,12 +51,13 @@ public class PlatformWxminiConfig {
*/ */
public String jscode2session(String service, String code) { public String jscode2session(String service, String code) {
WxConfigBean configBean = getConfigBean(service); WxConfigBean configBean = getConfigBean(service);
String body = HttpRequest.get("https://api.weixin.qq.com/sns/jscode2session" try (HttpResponse response = HttpRequest.get("https://api.weixin.qq.com/sns/jscode2session"
+ "?appid=" + configBean.getAppId() + "?appid=" + configBean.getAppId()
+ "&secret=" + configBean.getAppSecret() + "&secret=" + configBean.getAppSecret()
+ "&js_code=" + code + "&grant_type=authorization_code").execute().body(); + "&js_code=" + code + "&grant_type=authorization_code").execute()) {
JSONObject object = JSONUtil.parseObj(body); JSONObject object = JSONUtil.parseObj(response.body());
return object.getStr("openid"); return object.getStr("openid");
}
} }
/** /**
@@ -65,11 +67,12 @@ public class PlatformWxminiConfig {
*/ */
public String getAccessToken(String service) { public String getAccessToken(String service) {
WxConfigBean configBean = getConfigBean(service); WxConfigBean configBean = getConfigBean(service);
String body = HttpRequest.get("https://api.weixin.qq.com/cgi-bin/token" try (HttpResponse response = HttpRequest.get("https://api.weixin.qq.com/cgi-bin/token"
+ "?grant_type=client_credential&appid=" + configBean.getAppId() + "?grant_type=client_credential&appid=" + configBean.getAppId()
+ "&secret=" + configBean.getAppSecret()).execute().body(); + "&secret=" + configBean.getAppSecret()).execute()) {
JSONObject object = JSONUtil.parseObj(body); JSONObject object = JSONUtil.parseObj(response.body());
return object.getStr("access_token"); return object.getStr("access_token");
}
} }

View File

@@ -12,8 +12,8 @@ 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.WxOAuth2AccessToken; import com.tiesheng.platform.config.wxmp.bean.WxOAuth2AccessToken;
import com.tiesheng.platform.config.wxmp.bean.WxUserInfo; import com.tiesheng.platform.config.wxmp.bean.WxUserInfo;
import com.tiesheng.util.TimedCacheHelper;
import com.tiesheng.util.exception.ApiException; import com.tiesheng.util.exception.ApiException;
import com.tiesheng.util.service.TsCacheService;
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;
@@ -63,17 +63,17 @@ public class PlatformWxmpConfig {
*/ */
private String getAccessToken(String service) { private String getAccessToken(String service) {
WxConfigBean configBean = getConfigBean(service); WxConfigBean configBean = getConfigBean(service);
String accessToken = TimedCacheHelper.getTimedCache().get(CACHE_ACCESS_TOKEN + configBean.getAppId(), false); String accessToken = TsCacheService.of().get(CACHE_ACCESS_TOKEN + configBean.getAppId(), -1);
if (StrUtil.isEmpty(accessToken)) { if (StrUtil.isEmpty(accessToken)) {
Map<String, Object> query = new HashMap<>(10); Map<String, Object> query = new HashMap<>(10);
query.put("grant_type", "client_credential"); query.put("grant_type", "client_credential");
query.put("appid", configBean.getAppId()); query.put("appid", configBean.getAppId());
query.put("secret", configBean.getAppSecret()); query.put("secret", configBean.getAppSecret());
String response = HttpUtil.get("https://api.weixin.qq.com/cgi-bin/token", query); String response = HttpUtil.get("https://api.weixin.qq.com/cgi-bin/token", query);
LogFactory.get().info("getAccessToken: " + response);
JSONObject respJson = JSONUtil.parseObj(response); JSONObject respJson = JSONUtil.parseObj(response);
accessToken = respJson.getStr("access_token"); accessToken = respJson.getStr("access_token");
TimedCacheHelper.getTimedCache().put(CACHE_ACCESS_TOKEN + configBean.getAppId(), accessToken, respJson.getLong("expires_in")); TsCacheService.of().put(CACHE_ACCESS_TOKEN + configBean.getAppId(), accessToken,
respJson.getLong("expires_in"));
} }
return accessToken; return accessToken;
} }
@@ -86,7 +86,7 @@ public class PlatformWxmpConfig {
*/ */
private String getJsapiTicket(String service) { private String getJsapiTicket(String service) {
WxConfigBean configBean = getConfigBean(service); WxConfigBean configBean = getConfigBean(service);
String jsapiTicket = TimedCacheHelper.getTimedCache().get(CACHE_JSAPI_TICKET + configBean.getAppId(), false); String jsapiTicket = TsCacheService.of().get(CACHE_JSAPI_TICKET + configBean.getAppId(), -1);
if (StrUtil.isEmpty(jsapiTicket)) { if (StrUtil.isEmpty(jsapiTicket)) {
Map<String, Object> query = new HashMap<>(10); Map<String, Object> query = new HashMap<>(10);
query.put("access_token", getAccessToken(service)); query.put("access_token", getAccessToken(service));
@@ -95,7 +95,8 @@ public class PlatformWxmpConfig {
LogFactory.get().info("getJsapiTicket: " + response); LogFactory.get().info("getJsapiTicket: " + response);
JSONObject respJson = JSONUtil.parseObj(response); JSONObject respJson = JSONUtil.parseObj(response);
jsapiTicket = respJson.getStr("ticket"); jsapiTicket = respJson.getStr("ticket");
TimedCacheHelper.getTimedCache().put(CACHE_JSAPI_TICKET + configBean.getAppId(), jsapiTicket, respJson.getLong("expires_in")); TsCacheService.of().put(CACHE_JSAPI_TICKET + configBean.getAppId(), jsapiTicket,
respJson.getLong("expires_in"));
} }
return jsapiTicket; return jsapiTicket;
} }

BIN
springboot-poi/.DS_Store vendored Normal file

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More