Compare commits

..

1 Commits

Author SHA1 Message Date
曾文豪
ca96685022 publish 1.1.6
All checks were successful
/ local-deploy (push) Successful in 20s
2025-05-27 13:20:03 +08:00
214 changed files with 1701 additions and 2789 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -0,0 +1,25 @@
## 工作流触发时机
on:
push:
tags:
- '*'
jobs:
## 任务名称
local-deploy:
## 任务执行的服务器
runs-on: tiesheng-local
## 任务步骤
steps:
## 检出代码(固定配置)
- name: Check out repository code
uses: https://git.tieshengkeji.com/actions/checkout@v4
## maven打包
- name: Maven deploy
run: |
mvn deploy

View File

@@ -1,17 +0,0 @@
stages:
- deploy
deploy-jar:
stage: deploy
tags:
- zengos
rules:
- if: $CI_COMMIT_TAG
script:
- mvn clean deploy -Dmaven.test.skip -DaltDeploymentRepository=master::default::file:$TAG_REPO_FOLDER
- cd $TAG_REPO_FOLDER
- git checkout master
- git pull
- git add .
- git commit -m "deploy $CI_PROJECT_NAME $CI_COMMIT_TAG"
- git push origin master

View File

@@ -1,7 +1,94 @@
## 2.0.0.rc4 ## 1.1.0
- perfTsTokenConfig不在提供静态方法 - featglobalConfig增加ext属性。
- perf移除TsTokenAspect由TokenWebMvcConfigurer替代并实现TokenBean参数注入 - 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**

View File

@@ -1,94 +0,0 @@
## 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**

38
pom.xml
View File

@@ -6,7 +6,7 @@
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.0.rc10</version> <version>1.1.6</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>springboot-parent</name> <name>springboot-parent</name>
<description>杭州铁晟科技有限公司基础依赖</description> <description>杭州铁晟科技有限公司基础依赖</description>
@@ -28,7 +28,6 @@
<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>
@@ -58,61 +57,55 @@
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-database</artifactId> <artifactId>springboot-database</artifactId>
<version>2.0.0.rc10</version> <version>1.1.6</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-login</artifactId> <artifactId>springboot-login</artifactId>
<version>2.0.0.rc10</version> <version>1.1.6</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-web</artifactId> <artifactId>springboot-web</artifactId>
<version>2.0.0.rc10</version> <version>1.1.6</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-util</artifactId> <artifactId>springboot-util</artifactId>
<version>2.0.0.rc10</version> <version>1.1.6</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-platform</artifactId> <artifactId>springboot-platform</artifactId>
<version>2.0.0.rc10</version> <version>1.1.6</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-message</artifactId> <artifactId>springboot-message</artifactId>
<version>2.0.0.rc10</version> <version>1.1.6</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-encrypt</artifactId> <artifactId>springboot-encrypt</artifactId>
<version>2.0.0.rc10</version> <version>1.1.6</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>2.0.0.rc10</version> <version>1.1.6</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-poi</artifactId> <artifactId>springboot-poi</artifactId>
<version>2.0.0.rc10</version> <version>1.1.6</version>
</dependency> </dependency>
<dependency> <dependency>
@@ -132,11 +125,18 @@
<pluginRepositories> <pluginRepositories>
<pluginRepository> <pluginRepository>
<id>kepai-repo-plugin</id> <id>gitea</id>
<url>http://git.kepai365.com/tiesheng/repository/raw/master</url> <url>https://git.tieshengkeji.com/api/packages/tieshengkeji/maven</url>
</pluginRepository> </pluginRepository>
</pluginRepositories> </pluginRepositories>
<distributionManagement>
<repository>
<id>gitea</id>
<url>https://git.tieshengkeji.com/api/packages/tieshengkeji/maven</url>
</repository>
</distributionManagement>
<build> <build>
<pluginManagement> <pluginManagement>
<plugins> <plugins>

Binary file not shown.

View File

@@ -6,11 +6,11 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.0.rc10</version> <version>1.1.6</version>
</parent> </parent>
<artifactId>springboot-ademo</artifactId> <artifactId>springboot-ademo</artifactId>
<version>2.0.0.rc10</version> <version>1.1.6</version>
<properties> <properties>
<maven.compiler.source>8</maven.compiler.source> <maven.compiler.source>8</maven.compiler.source>
@@ -26,22 +26,11 @@
<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>

View File

@@ -1,7 +1,7 @@
package com.tiesheng.demo; package com.tiesheng.demo;
import com.tiesheng.web.EnableTieshengWeb; import com.tiesheng.core.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,6 +13,7 @@ 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.web.pojos.RequestUserInfo; import com.tiesheng.core.pojos.RequestUserInfo;
import com.tiesheng.web.pojos.dao.CorePlatformUnique; import com.tiesheng.core.pojos.dao.CorePlatformUnique;
import com.tiesheng.web.service.TieshengWebConfigurer; import com.tiesheng.core.service.TieshengWebConfigurer;
import com.tiesheng.util.pojos.TokenBean; import com.tiesheng.login.config.token.bean.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;
@@ -40,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, "static/mobile"); to = StrUtil.emptyToDefault(to, "mobile");
bean.setEnvironmentType(to); bean.setEnvironmentType(to);
if (Objects.equals(bean.getEnvironmentType(), "static/mobile")) { if (Objects.equals(bean.getEnvironmentType(), "mobile")) {
globalConfig.redirect("static/mobile", "/?token=" + bean.toToken(), response); globalConfig.redirect("mobile", "/?token=" + bean.toToken(), response);
} }
} }

View File

@@ -0,0 +1,43 @@
//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);
// }
//}

View File

@@ -1,7 +1,8 @@
package com.tiesheng.demo.config; package com.tiesheng.demo.config;
import com.tiesheng.web.service.CoreConfigService; import com.tiesheng.core.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;
@@ -13,11 +14,19 @@ 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

@@ -0,0 +1,29 @@
//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);
// }
//}

View File

@@ -8,28 +8,27 @@ 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.GetMapping; import org.springframework.web.bind.annotation.*;
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;
@@ -55,14 +54,11 @@ public class TestController {
CoreLogService coreLogService; CoreLogService coreLogService;
@Autowired @Autowired
DbBackupConfig dbBackupConfig; DbBackupConfig dbBackupConfig;
@Autowired
TsCacheService tsCacheService;
@RequestMapping("/index") @RequestMapping("/index")
@TokenIgnore public ApiResp<String> index() {
public void index(HttpServletResponse response) { return ApiResp.respOK("hello world");
globalConfig.redirect("mobile", "/test", response);
} }
@RequestMapping("/redirect") @RequestMapping("/redirect")
@@ -104,13 +100,8 @@ public class TestController {
@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

@@ -7,8 +7,6 @@ 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:
@@ -21,7 +19,6 @@ 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
@@ -29,4 +26,4 @@ tiesheng:
access-key-id: LTAI5tJtbgBCnTY5eS4SmrTf access-key-id: LTAI5tJtbgBCnTY5eS4SmrTf
access-key-secret: JIHqpRUFffCHhXaJEVvWN31WcexWqG access-key-secret: JIHqpRUFffCHhXaJEVvWN31WcexWqG
encrypt: encrypt:
body: false body: true

View File

@@ -13,9 +13,16 @@ 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

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

View File

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

View File

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

Binary file not shown.

View File

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

Binary file not shown.

View File

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

View File

@@ -1,110 +0,0 @@
package com.tiesheng.login.config;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.tiesheng.annotation.token.TokenIgnore;
import com.tiesheng.util.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

@@ -0,0 +1,87 @@
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

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

View File

@@ -1,10 +1,10 @@
package com.tiesheng.util.pojos; package com.tiesheng.login.config.token.bean;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.jwt.JWT; import cn.hutool.jwt.JWT;
import com.tiesheng.util.config.TsTokenConfig; import com.tiesheng.login.config.token.TsTokenConfig;
/** /**
* @author hao * @author hao
@@ -14,7 +14,6 @@ public class TokenBean {
private String id; private String id;
private String environmentType; private String environmentType;
private String service; private String service;
private String roleId;
private String extra; private String extra;
public TokenBean() { public TokenBean() {
@@ -24,7 +23,6 @@ public class TokenBean {
this.id = id; this.id = id;
this.environmentType = environmentType; this.environmentType = environmentType;
this.service = service; this.service = service;
this.roleId = "";
this.extra = ""; this.extra = "";
} }
@@ -39,7 +37,6 @@ public class TokenBean {
.setPayload("id", getId()) .setPayload("id", getId())
.setPayload("environmentType", StrUtil.emptyToDefault(getEnvironmentType(), "")) .setPayload("environmentType", StrUtil.emptyToDefault(getEnvironmentType(), ""))
.setPayload("service", StrUtil.emptyToDefault(getService(), "")) .setPayload("service", StrUtil.emptyToDefault(getService(), ""))
.setPayload("roleId", StrUtil.emptyToDefault(getRoleId(), ""))
.setPayload("extra", StrUtil.emptyToDefault(getExtra(), "")) .setPayload("extra", StrUtil.emptyToDefault(getExtra(), ""))
.setKey(tsTokenConfig.getEncryptKey().getBytes()) .setKey(tsTokenConfig.getEncryptKey().getBytes())
.sign(); .sign();
@@ -80,12 +77,4 @@ public class TokenBean {
public void setExtra(String extra) { public void setExtra(String extra) {
this.extra = extra; this.extra = extra;
} }
public String getRoleId() {
return roleId;
}
public void setRoleId(String roleId) {
this.roleId = roleId;
}
} }

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.util.config.TsTokenConfig; import com.tiesheng.login.config.token.TsTokenConfig;
import com.tiesheng.util.pojos.TokenBean; 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;

View File

@@ -23,7 +23,7 @@ public class UniqueIndexDTO extends LoginToInfo {
if (StrUtil.isEmpty(getNo()) || getTimestamp() == null) { if (StrUtil.isEmpty(getNo()) || getTimestamp() == null) {
return false; return false;
} }
if ((DateUtil.currentSeconds() - getTimestamp()) > 60) { if ((DateUtil.currentSeconds() - getTimestamp()) > 10) {
return false; return false;
} }
String mySign = getNo() + getTimestamp(); String mySign = getNo() + getTimestamp();

View File

@@ -1,7 +1,8 @@
package com.tiesheng.login.service; package com.tiesheng.login.service;
import com.tiesheng.util.pojos.TokenBean; import com.tiesheng.login.config.token.bean.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.util.pojos.TokenBean; import com.tiesheng.login.config.token.bean.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;

Binary file not shown.

View File

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

Binary file not shown.

View File

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

View File

@@ -4,22 +4,18 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.TypeReference; 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.HttpResponse; 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.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
/** /**
@@ -61,30 +57,24 @@ public class PlatformDingConfig {
* @return * @return
*/ */
public <T> DingResponse<T> doRequest(String service, String url, JSONObject body, TypeReference<DingResponse<T>> typeReference) { public <T> DingResponse<T> doRequest(String service, String url, JSONObject body, TypeReference<DingResponse<T>> typeReference) {
String accessToken = getAccessToken(service);
if (StrUtil.contains(url, "?")) { if (StrUtil.contains(url, "?")) {
url = url + "&access_token=" + accessToken; url = url + "&access_token=" + getAccessToken(service);
} else { } else {
url = url + "?access_token=" + accessToken; url = url + "?access_token=" + getAccessToken(service);
} }
HttpRequest request; HttpResponse execute;
if (body == null) { if (body == null) {
request = HttpUtil.createGet(url); execute = HttpUtil.createGet(url).execute();
} else { } else {
request = HttpUtil.createPost(url).body(body.toString()); execute = HttpUtil.createPost(url).body(body.toString()).execute();
} }
request.header("x-acs-dingtalk-access-token", accessToken);
HttpResponse execute = request.execute();
if (execute.isOk()) { if (execute.isOk()) {
String rawBody = execute.body(); DingResponse<T> bean = JSONUtil.toBean(execute.body(), typeReference, true);
DingResponse<T> bean = JSONUtil.toBean(rawBody, typeReference, true);
if (!bean.isOk()) { if (!bean.isOk()) {
LogFactory.get().info(bean.getErrmsg()); LogFactory.get().info(bean.getErrmsg());
} }
bean.setRawBody(rawBody);
return bean; return bean;
} }
@@ -104,7 +94,7 @@ public class PlatformDingConfig {
*/ */
private String getAccessToken(String service) { private String getAccessToken(String service) {
DingConfigBean dingConfigBean = getConfigBean(service); DingConfigBean dingConfigBean = getConfigBean(service);
String accessToken = TsCacheService.of().get(CACHE_ACCESS_TOKEN + dingConfigBean.getAppKey(), -1); String accessToken = TimedCacheHelper.getTimedCache().get(CACHE_ACCESS_TOKEN + dingConfigBean.getAppKey(), false);
if (!StrUtil.isEmpty(accessToken)) { if (!StrUtil.isEmpty(accessToken)) {
return accessToken; return accessToken;
} }
@@ -116,8 +106,7 @@ 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");
TsCacheService.of().put(CACHE_ACCESS_TOKEN + dingConfigBean.getAppKey(), TimedCacheHelper.getTimedCache().put(CACHE_ACCESS_TOKEN + dingConfigBean.getAppKey(), accessToken, respJson.getLong("expires_in"));
accessToken, respJson.getLong("expires_in"));
return accessToken; return accessToken;
} }
@@ -131,7 +120,7 @@ public class PlatformDingConfig {
*/ */
private String getJsapiTicket(String service) { private String getJsapiTicket(String service) {
DingConfigBean dingConfigBean = getConfigBean(service); DingConfigBean dingConfigBean = getConfigBean(service);
String jsapiTicket = TsCacheService.of().get(CACHE_JSAPI_TICKET + dingConfigBean.getAppKey(), -1); String jsapiTicket = TimedCacheHelper.getTimedCache().get(CACHE_JSAPI_TICKET + dingConfigBean.getAppKey(), false);
if (StrUtil.isEmpty(jsapiTicket)) { if (StrUtil.isEmpty(jsapiTicket)) {
DingResponse<String> respJson = doRequest(service, "https://oapi.dingtalk.com/get_jsapi_ticket", null, DingResponse<String> respJson = doRequest(service, "https://oapi.dingtalk.com/get_jsapi_ticket", null,
new TypeReference<DingResponse<String>>() { new TypeReference<DingResponse<String>>() {
@@ -139,9 +128,8 @@ public class PlatformDingConfig {
if (!respJson.isOk()) { if (!respJson.isOk()) {
throw new ApiException(respJson.getErrmsg()); throw new ApiException(respJson.getErrmsg());
} }
jsapiTicket = respJson.getTicket();
jsapiTicket = respJson.getRawValue("ticket", String.class); TimedCacheHelper.getTimedCache().put(CACHE_JSAPI_TICKET + dingConfigBean.getAppKey(),
TsCacheService.of().put(CACHE_JSAPI_TICKET + dingConfigBean.getAppKey(),
jsapiTicket, respJson.getExpiresIn()); jsapiTicket, respJson.getExpiresIn());
} }
return jsapiTicket; return jsapiTicket;
@@ -275,8 +263,7 @@ public class PlatformDingConfig {
* 发送工作通知 * 发送工作通知
* *
* @param service * @param service
* @param title * @param content
* @param markdown
* @param actionUrl * @param actionUrl
* @param userIds * @param userIds
* @return * @return
@@ -292,11 +279,8 @@ public class PlatformDingConfig {
JSONObject actionCard = new JSONObject(); JSONObject actionCard = new JSONObject();
actionCard.set("title", title); actionCard.set("title", title);
actionCard.set("markdown", markdown); actionCard.set("markdown", markdown);
actionCard.set("single_title", "点击查看");
if (StrUtil.isNotEmpty(actionUrl)) { actionCard.set("single_url", 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");

View File

@@ -1,16 +1,14 @@
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 String ticket;
private Long expiresIn; private Long expiresIn;
private T result; private T result;
private String rawBody;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// 逻辑方法 // 逻辑方法
@@ -20,17 +18,6 @@ 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
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@@ -59,6 +46,14 @@ public class DingResponse<T> {
this.result = result; this.result = result;
} }
public String getTicket() {
return ticket;
}
public void setTicket(String ticket) {
this.ticket = ticket;
}
public Long getExpiresIn() { public Long getExpiresIn() {
return expiresIn; return expiresIn;
} }
@@ -66,12 +61,4 @@ public class DingResponse<T> {
public void setExpiresIn(Long expiresIn) { public void setExpiresIn(Long expiresIn) {
this.expiresIn = expiresIn; this.expiresIn = expiresIn;
} }
public String getRawBody() {
return rawBody;
}
public void setRawBody(String rawBody) {
this.rawBody = rawBody;
}
} }

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 = TsCacheService.of().get(CACHE_ACCESS_TOKEN + configBean.getAppId(), -1); String accessToken = TimedCacheHelper.getTimedCache().get(CACHE_ACCESS_TOKEN + configBean.getAppId(), false);
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");
TsCacheService.of().put(CACHE_ACCESS_TOKEN + configBean.getAppId(), accessToken, TimedCacheHelper.getTimedCache().put(CACHE_ACCESS_TOKEN + configBean.getAppId(), accessToken, respJson.getLong("expires_in"));
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 = TsCacheService.of().get(CACHE_JSAPI_TICKET + configBean.getAppId(), -1); String jsapiTicket = TimedCacheHelper.getTimedCache().get(CACHE_JSAPI_TICKET + configBean.getAppId(), false);
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,8 +95,7 @@ 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");
TsCacheService.of().put(CACHE_JSAPI_TICKET + configBean.getAppId(), jsapiTicket, TimedCacheHelper.getTimedCache().put(CACHE_JSAPI_TICKET + configBean.getAppId(), jsapiTicket, respJson.getLong("expires_in"));
respJson.getLong("expires_in"));
} }
return jsapiTicket; return jsapiTicket;
} }

Binary file not shown.

View File

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

Binary file not shown.

View File

@@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.0.rc10</version>
</parent>
<artifactId>springboot-role</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-util</artifactId>
</dependency>
</dependencies>
</project>

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