Compare commits

...

62 Commits

Author SHA1 Message Date
曾文豪
70178b7f0d publish zjut-1.1.6
All checks were successful
/ local-deploy (push) Successful in 22s
2025-12-30 09:30:14 +08:00
曾文豪
ca96685022 publish 1.1.6
All checks were successful
/ local-deploy (push) Successful in 20s
2025-05-27 13:20:03 +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
曾文豪
ea24bf3479 perf(encrypt):加解密调整 2023-07-05 14:11:01 +08:00
曾文豪
90e504e7fd fix:验签接口调整 2023-07-05 13:58:01 +08:00
曾文豪
5db42f5bc8 publish 1.0.12 2023-07-05 13:55:14 +08:00
曾文豪
37d84e2f36 docs: 文档调整 2023-06-30 10:24:13 +08:00
曾文豪
f59d56be9e docs: 文档调整 2023-06-28 13:04:11 +08:00
曾文豪
7f4871fe19 publish 1.0.10 2023-06-28 13:03:03 +08:00
曾文豪
34e3cb2f09 docs: 文档调整 2023-06-14 09:44:11 +08:00
曾文豪
7c1abb9b97 docs: 文档调整 2023-06-14 09:39:38 +08:00
曾文豪
a649bdae7c publish 1.0.9 2023-06-14 09:32:50 +08:00
曾文豪
7b6eccb0d5 feat: 登录接口增加timestamp、sign字段,用于验证本次是否通过 2023-06-14 09:27:01 +08:00
67 changed files with 995 additions and 273 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,30 +0,0 @@
stages:
- 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:
stage: deploy
tags:
- hzkepai
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,48 +1,48 @@
## 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解析异常
- feat(web): 增加uploadFileCustomize方法允许自定义文件存放情况
- feat(database): 增加db/data目录存放初始化数据的sql
- perf(login): 增加默认值防止token解析异常
## 1.0.6
### 新增
> 1新增 **OperationIgnore** 注解,可以指定接口忽略操作日志的收集。
> 2**OperationLog** 增加 desensitize 属性,用来脱敏指定的字段。
- feat(web):新增 **OperationIgnore** 注解,可以指定接口忽略操作日志的收集。
- feat(web)**OperationLog** 增加 desensitize 属性,用来脱敏指定的字段。
## 1.0.2
### 调整
> 1增加数据库定时备份
> 2增加过期备份的删除操作默认过期时间为7天
> 3调整阿里云短信类方便扩展其他方法。
> 4消息发送接口该body类型为 **JSONObject**
> 5调整消息发送接口和方法不兼容旧版本
- feat(database):增加数据库定时备份;
- feat(database)增加过期备份的删除操作默认过期时间为7天
- perf(message):调整阿里云短信类,方便扩展其他方法。
- perf(message)消息发送接口该body类型为 **JSONObject**
- perf(message):调整消息发送接口和方法(不兼容旧版本)
## 1.0.1
### 调整
fastjson增加配置 **DisableCircularReferenceDetect**,禁用相同的对象写成引用的形式。
- perf(web)fastjson增加配置 **DisableCircularReferenceDetect**,禁用相同的对象写成引用的形式。
## 1.0.0
### 升级
> 1hutool依赖升级:5.8.11 -> 5.8.16
> 2fastjson依赖升级1.2.78 -> 1.2.83
> 3mybatis-plus依赖升级3.5.1 -> 3.5.3
### 调整
> 1**TieshengWebConfigurer** 增加 **configSystemCheck** 方法,可根据情况校验系统配置参数。
- 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** 方法,可根据情况校验系统配置参数。
从该版本开始,仓库地址改为:

33
pom.xml
View File

@@ -6,7 +6,7 @@
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.8</version>
<version>zjut-1.1.6</version>
<packaging>pom</packaging>
<name>springboot-parent</name>
<description>杭州铁晟科技有限公司基础依赖</description>
@@ -57,55 +57,55 @@
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-database</artifactId>
<version>1.0.8</version>
<version>zjut-1.1.6</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-login</artifactId>
<version>1.0.8</version>
<version>zjut-1.1.6</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-web</artifactId>
<version>1.0.8</version>
<version>zjut-1.1.6</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-util</artifactId>
<version>1.0.8</version>
<version>zjut-1.1.6</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-platform</artifactId>
<version>1.0.8</version>
<version>zjut-1.1.6</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-message</artifactId>
<version>1.0.8</version>
<version>zjut-1.1.6</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-encrypt</artifactId>
<version>1.0.8</version>
<version>zjut-1.1.6</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-annotation</artifactId>
<version>1.0.8</version>
<version>zjut-1.1.6</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-poi</artifactId>
<version>1.0.8</version>
<version>zjut-1.1.6</version>
</dependency>
<dependency>
@@ -125,18 +125,25 @@
<pluginRepositories>
<pluginRepository>
<id>kepai-repo-plugin</id>
<url>http://git.kepai365.com/tiesheng/repository/raw/master</url>
<id>gitea</id>
<url>https://git.tieshengkeji.com/api/packages/tieshengkeji/maven</url>
</pluginRepository>
</pluginRepositories>
<distributionManagement>
<repository>
<id>gitea</id>
<url>https://git.tieshengkeji.com/api/packages/tieshengkeji/maven</url>
</repository>
</distributionManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.tiesheng.springboot-plugin</groupId>
<artifactId>tiesheng-maven-plugin</artifactId>
<version>0.0.6</version>
<version>1.0.0</version>
<executions>
<execution>
<goals>

View File

@@ -6,11 +6,11 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.8</version>
<version>zjut-1.1.6</version>
</parent>
<artifactId>springboot-ademo</artifactId>
<version>1.0.0</version>
<version>zjut-1.1.6</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>

View File

@@ -3,7 +3,6 @@ package com.tiesheng.demo;
import com.tiesheng.core.EnableTieshengWeb;
import com.tiesheng.demo.config.DemoWebConfigurer;
import com.tiesheng.encrypt.EnableEncryptConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.transaction.annotation.EnableTransactionManagement;

View File

@@ -31,9 +31,6 @@ public class DemoWebConfigurer implements TieshengWebConfigurer {
TokenBean tokenBean = null;
if (!StrUtil.isEmpty(platformUnique.getUserId())) {
tokenBean = new TokenBean(platformUnique.getUserId(), "", globalConfig.getService());
} else {
// 获取用户信息判断是否可登录
}
return tokenBean;

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

@@ -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

@@ -58,7 +58,6 @@ public class TestController {
@RequestMapping("/index")
public ApiResp<String> index() {
dbBackupConfig.dbBackup();
return ApiResp.respOK("hello world");
}
@@ -94,7 +93,7 @@ public class TestController {
public ApiResp<MessageReqResp> sendMessage() {
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);
}

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

@@ -25,4 +25,5 @@ tiesheng:
aliyun:
access-key-id: LTAI5tJtbgBCnTY5eS4SmrTf
access-key-secret: JIHqpRUFffCHhXaJEVvWN31WcexWqG
sign-name: 阿里云短信测试
encrypt:
body: true

View File

@@ -9,6 +9,7 @@ spring:
servlet:
multipart:
max-file-size: 20MB
max-request-size: 20MB
web:
resources:
static-locations: classpath:/static/,file:static/
@@ -24,3 +25,4 @@ tiesheng:
token:
ignore-paths:
- /test/index

View File

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

View File

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

View File

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

View File

@@ -1,21 +0,0 @@
package com.tiesheng.encrypt;
import com.tiesheng.encrypt.config.DecryptRequestBodyAdvice;
import com.tiesheng.encrypt.config.EncryptResponseBodyAdvice;
import org.springframework.context.annotation.Import;
import java.lang.annotation.*;
/**
* @author hao
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@Documented
@Import({
DecryptRequestBodyAdvice.class,
EncryptResponseBodyAdvice.class,
})
public @interface EnableEncryptConfig {
}

View File

@@ -0,0 +1,10 @@
package com.tiesheng.encrypt;
import org.springframework.context.annotation.ComponentScan;
@ComponentScan({
"com.tiesheng.encrypt.**.*",
})
public class EncryptAutoConfigurer {
}

View File

@@ -37,7 +37,7 @@ public class EncryptResponseBodyAdvice implements ResponseBodyAdvice<ApiResp> {
try {
Object data = body.getData();
if (data == null || !body.successful()) {
if (data == null || !body.successful() || !encryptConfig.isBody()) {
return body;
}

View File

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

View File

@@ -27,6 +27,7 @@ public class TsTokenConfig {
private String encryptKey = "%kIp9frQCu";
private Integer expireHours = 48;
private String[] ignorePaths;
private boolean validLoginSign = true;
/**
@@ -148,4 +149,12 @@ public class TsTokenConfig {
public void setIgnorePaths(String[] ignorePaths) {
this.ignorePaths = ignorePaths;
}
public boolean isValidLoginSign() {
return validLoginSign;
}
public void setValidLoginSign(boolean validLoginSign) {
this.validLoginSign = validLoginSign;
}
}

View File

@@ -6,6 +6,7 @@ import cn.hutool.core.util.URLUtil;
import com.alibaba.fastjson.JSON;
import com.tiesheng.annotation.operation.OperationIgnore;
import com.tiesheng.annotation.token.TokenIgnore;
import com.tiesheng.login.config.token.TsTokenConfig;
import com.tiesheng.login.config.token.bean.TokenBean;
import com.tiesheng.login.pojos.CodeExtraDTO;
import com.tiesheng.login.pojos.DoLoginInfo;
@@ -15,6 +16,7 @@ import com.tiesheng.login.service.TieshengLoginConfigurer;
import com.tiesheng.platform.config.ding.PlatformDingConfig;
import com.tiesheng.platform.config.ding.bean.DingJsapiSignature;
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.wxmp.PlatformWxmpConfig;
import com.tiesheng.platform.config.wxmp.bean.WxConfigBean;
@@ -50,6 +52,8 @@ public class LoginController {
TieshengLoginConfigurer tieshengLoginConfigurer;
@Autowired
GlobalConfig globalConfig;
@Autowired
TsTokenConfig tsTokenConfig;
/**
@@ -60,6 +64,11 @@ public class LoginController {
@GetMapping("/unique/redirect")
@OperationIgnore
public void uniqueIndex(UniqueIndexDTO dto, HttpServletResponse response) {
if (tsTokenConfig.isValidLoginSign() && !dto.validSign()) {
tieshengLoginConfigurer.onSignError(response);
return;
}
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo("web_unique_redirect",
dto.getNo(), dto.getPlatform(), dto.getInfo()));
tieshengLoginConfigurer.onLoginRedirect(tokenBean, dto.getTo(), dto.getExtra(), response);
@@ -77,7 +86,7 @@ public class LoginController {
public ApiResp<String> uniqueIndex(@RequestBody UniqueIndexDTO dto) {
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo("web_unique_index",
dto.getNo(), dto.getPlatform(), dto.getInfo()));
if (tokenBean == null) {
if (tokenBean == null || StrUtil.isEmpty(tokenBean.getId())) {
throw new ApiException("登录失败");
}
return ApiResp.respOK(tokenBean.toToken());
@@ -105,6 +114,7 @@ public class LoginController {
map.put("corpId", platformDingConfig.getConfigBean(service).getCorpId());
map.put("service", service);
map.put("extra", extra);
map.put("context", globalConfig.getContextPath());
String query = URLUtil.buildQuery(map, Charset.defaultCharset());
String configUrl = globalConfig.buildPath("/ding/index.html?" + query);
try {
@@ -122,8 +132,8 @@ public class LoginController {
@RequestMapping("/ding/oauth2/{service}")
@OperationIgnore
public void dingOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) {
String ddUserId = platformDingConfig.getUserIdByCode(service, dto.getCode());
DingUserInfo dingUserInfo = platformDingConfig.topapiV2UserGet(service, ddUserId);
DingUserSimple userSimple = platformDingConfig.getUserIdByCode(service, dto.getCode());
DingUserInfo dingUserInfo = platformDingConfig.topapiV2UserGet(service, userSimple.getUserid());
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo(dingUserInfo.getAppId(),
dingUserInfo.getUserid(), "ding", JSON.toJSONString(dingUserInfo)));
tieshengLoginConfigurer.onLoginRedirect(tokenBean, dto.getTo(), dto.getExtra(), response);

View File

@@ -1,6 +1,10 @@
package com.tiesheng.login.pojos;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import java.util.Objects;
public class UniqueIndexDTO extends LoginToInfo {
@@ -8,6 +12,26 @@ public class UniqueIndexDTO extends LoginToInfo {
private String extra;
private String info;
private String platform = "web";
private Long timestamp;
private String sign;
/**
* 验证签名是否正确
*/
public boolean validSign() {
if (StrUtil.isEmpty(getNo()) || getTimestamp() == null) {
return false;
}
if ((DateUtil.currentSeconds() - getTimestamp()) > 10) {
return false;
}
String mySign = getNo() + getTimestamp();
for (int i = 0; i < 11; i++) {
mySign = SecureUtil.md5(mySign);
}
return Objects.equals(sign, mySign);
}
///////////////////////////////////////////////////////////////////////////
// setter\getter
@@ -47,4 +71,20 @@ public class UniqueIndexDTO extends LoginToInfo {
public void setPlatform(String platform) {
this.platform = platform;
}
public Long getTimestamp() {
return timestamp;
}
public void setTimestamp(Long timestamp) {
this.timestamp = timestamp;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
}

View File

@@ -2,6 +2,7 @@ package com.tiesheng.login.service;
import com.tiesheng.login.config.token.bean.TokenBean;
import com.tiesheng.login.pojos.DoLoginInfo;
import com.tiesheng.util.ServletKit;
import org.springframework.context.annotation.Configuration;
import javax.servlet.http.HttpServletResponse;
@@ -28,4 +29,9 @@ public interface TieshengLoginConfigurer {
void onLoginRedirect(TokenBean bean, String to, String extra, HttpServletResponse response);
/**
* 签名错误的时候
*/
void onSignError(HttpServletResponse response);
}

View File

@@ -24,4 +24,9 @@ public class DefaultLoginConfigurer implements TieshengLoginConfigurer {
public void onLoginRedirect(TokenBean bean, String to, String extra, HttpServletResponse response) {
}
@Override
public void onSignError(HttpServletResponse response) {
}
}

View File

@@ -24,10 +24,10 @@
corpId: getQueryString("corpId"),
onSuccess: function (result) {
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) {
window.location.href = "./error.html?message=" + JSON.stringify(err);
window.location.replace("./error.html?message=" + JSON.stringify(err));
}
})

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.8</version>
<version>zjut-1.1.6</version>
</parent>
<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;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.tiesheng.message.pojos.AliyunTempParam;
import com.tiesheng.message.pojos.MessageReqResp;
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.context.annotation.Configuration;
@@ -36,7 +40,9 @@ public class AliyunSmsSender implements TieshengMessageSender {
private String accessKeyId;
private String accessKeySecret;
private String signName;
@Autowired(required = false)
AliyunSmsHandler aliyunSmsHandler;
/**
* 特殊字符替换
@@ -94,7 +100,16 @@ public class AliyunSmsSender implements TieshengMessageSender {
String signature = specialUrlEncode(digest);
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 templateCode 短信模板
* @param params 模板参数
* @param tempParam 短信模板
* @return
*/
public MessageReqResp sendSms(String phoneNumbers, String templateCode, JSONObject params) {
public MessageReqResp sendSms(String phoneNumbers, AliyunTempParam tempParam) {
MessageReqResp reqResp = new MessageReqResp("阿里云短信");
reqResp.setTarget(phoneNumbers);
reqResp.setResult(1);
reqResp.setContent(JSONUtil.createObj()
.putOpt("PhoneNumbers", phoneNumbers)
.putOpt("SignName", getSignName())
.putOpt("TemplateCode", templateCode)
.putOpt("TemplateParam", params)
.putOpt("SignName", tempParam.getSignName())
.putOpt("TemplateCode", tempParam.getTemplateCode())
.putOpt("TemplateParam", tempParam.getTemplateParam())
.toString());
// 业务API参数
ConcurrentHashMap<String, String> queryMap = new ConcurrentHashMap<>();
queryMap.put("PhoneNumbers", phoneNumbers);
queryMap.put("SignName", getSignName());
queryMap.put("TemplateCode", templateCode);
if (params != null) {
queryMap.put("TemplateParam", params.toString());
queryMap.put("SignName", tempParam.getSignName());
queryMap.put("TemplateCode", tempParam.getTemplateCode());
if (tempParam.getTemplateParam() != null) {
queryMap.put("TemplateParam", tempParam.getTemplateParam().toString());
}
reqResp.setRespBody(request("SendSms", queryMap));
@@ -139,7 +153,21 @@ public class AliyunSmsSender implements TieshengMessageSender {
@Override
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
@@ -149,7 +177,7 @@ public class AliyunSmsSender implements TieshengMessageSender {
@Override
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;
}
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;
}
}

View File

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

View File

@@ -4,7 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
@@ -48,6 +48,40 @@ public class PlatformDingConfig {
return bean;
}
/**
* 发送get请求
* 会自动增加accessToken在url上面
*
* @param service
* @return
*/
public <T> DingResponse<T> doRequest(String service, String url, JSONObject body, TypeReference<DingResponse<T>> typeReference) {
if (StrUtil.contains(url, "?")) {
url = url + "&access_token=" + getAccessToken(service);
} else {
url = url + "?access_token=" + getAccessToken(service);
}
HttpResponse execute;
if (body == null) {
execute = HttpUtil.createGet(url).execute();
} else {
execute = HttpUtil.createPost(url).body(body.toString()).execute();
}
if (execute.isOk()) {
DingResponse<T> bean = JSONUtil.toBean(execute.body(), typeReference, true);
if (!bean.isOk()) {
LogFactory.get().info(bean.getErrmsg());
}
return bean;
}
return null;
}
///////////////////////////////////////////////////////////////////////////
// 逻辑方法
///////////////////////////////////////////////////////////////////////////
@@ -88,14 +122,15 @@ public class PlatformDingConfig {
DingConfigBean dingConfigBean = getConfigBean(service);
String jsapiTicket = TimedCacheHelper.getTimedCache().get(CACHE_JSAPI_TICKET + dingConfigBean.getAppKey(), false);
if (StrUtil.isEmpty(jsapiTicket)) {
String response = HttpUtil.get("https://oapi.dingtalk.com/get_jsapi_ticket?access_token=" + getAccessToken(service));
LogFactory.get().info("getJsapiTicket: " + response);
JSONObject respJson = JSONUtil.parseObj(response);
if (!Objects.equals(respJson.getStr("errcode"), "0")) {
throw new ApiException(respJson.getStr("errmsg"));
DingResponse<String> respJson = doRequest(service, "https://oapi.dingtalk.com/get_jsapi_ticket", null,
new TypeReference<DingResponse<String>>() {
});
if (!respJson.isOk()) {
throw new ApiException(respJson.getErrmsg());
}
jsapiTicket = respJson.getStr("ticket");
TimedCacheHelper.getTimedCache().put(CACHE_JSAPI_TICKET + dingConfigBean.getAppKey(), jsapiTicket, respJson.getLong("expires_in"));
jsapiTicket = respJson.getTicket();
TimedCacheHelper.getTimedCache().put(CACHE_JSAPI_TICKET + dingConfigBean.getAppKey(),
jsapiTicket, respJson.getExpiresIn());
}
return jsapiTicket;
}
@@ -124,10 +159,11 @@ public class PlatformDingConfig {
* @return
* @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) {
String response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/user/getuserinfo?access_token=" + getAccessToken(service))
.body(JSONUtil.createObj().putOpt("code", code).toString()).execute().body();
return JSONUtil.parseObj(response).getJSONObject("result").getStr("userid");
public DingUserSimple getUserIdByCode(String service, String code) {
DingResponse<DingUserSimple> resp = doRequest(service, "https://oapi.dingtalk.com/topapi/v2/user/getuserinfo",
JSONUtil.createObj().putOpt("code", code), new TypeReference<DingResponse<DingUserSimple>>() {
});
return resp.getResult();
}
@@ -141,13 +177,12 @@ public class PlatformDingConfig {
*/
public DingUserInfo topapiV2UserGet(String service, String ddUserId) {
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
userInfo.setJobNumber(resultJson.getStr("job_number"));
userInfo.setJobNumber(userInfo.getJobNumber());
userInfo.setAppId(dingConfigBean.getAppKey());
return userInfo;
}
@@ -164,15 +199,10 @@ public class PlatformDingConfig {
if (StrUtil.isEmpty(token)) {
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()) {
result.setResult(new ArrayList<>());
}
return result.getResult();
return doRequest(service, "https://oapi.dingtalk.com/topapi/v2/department/listsub",
JSONUtil.createObj().putOpt("dept_id", deptId), new TypeReference<DingResponse<List<DingDeptVo>>>() {
}).getResult();
}
@@ -188,19 +218,16 @@ public class PlatformDingConfig {
return DingUserListVo.fail();
}
String response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/user/list?access_token=" + token)
.body(JSONUtil.createObj().putOpt("dept_id", deptId).putOpt("cursor", cursor).putOpt("size", 100).toString())
.execute().body();
DingResponse<DingUserListVo> result = JSONUtil.toBean(response, new TypeReference<DingResponse<DingUserListVo>>() {
}.getType(), true);
if (!result.isOk()) {
result.setResult(DingUserListVo.fail());
}
return result.getResult();
return doRequest(service, "https://oapi.dingtalk.com/topapi/v2/user/list",
JSONUtil.createObj().putOpt("dept_id", deptId).putOpt("cursor", cursor).putOpt("size", 100),
new TypeReference<DingResponse<DingUserListVo>>() {
}).getResult();
}
/**
* 同步钉钉的通讯录
* <br />
* PS如果需要钉钉用户手机号需要开通权限企业员工手机号信息
*
* @param deptVo 为null时从第一级获取
* @param consumer 回调
@@ -239,18 +266,19 @@ public class PlatformDingConfig {
* @param content
* @param actionUrl
* @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)) {
return;
return null;
}
DingConfigBean configBean = getConfigBean(service);
JSONObject actionCard = new JSONObject();
actionCard.set("title", title);
actionCard.set("markdown", "### " + title + "\n" + content);
actionCard.set("markdown", markdown);
actionCard.set("single_title", "点击查看");
actionCard.set("single_url", actionUrl);
@@ -258,17 +286,18 @@ public class PlatformDingConfig {
msg.set("msgtype", "action_card");
msg.set("action_card", actionCard);
HashMap<String, Object> body = new HashMap<>(10);
body.put("agent_id", configBean.getAgentId());
body.put("userid_list", CollUtil.join(userIds, ","));
body.put("msg", msg);
String resp = HttpUtil.post("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2?access_token=" + getAccessToken(service),
JSONUtil.toJsonStr(body));
JSONObject body = new JSONObject();
body.putOpt("agent_id", configBean.getAgentId());
body.putOpt("userid_list", CollUtil.join(userIds, ","));
body.putOpt("msg", msg);
return doRequest(service, "https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2", body,
new TypeReference<DingResponse<String>>() {
});
}
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
public Map<String, DingConfigBean> getConfigs() {
return configs;

View File

@@ -6,6 +6,8 @@ public class DingResponse<T> {
private String errcode;
private String errmsg;
private String ticket;
private Long expiresIn;
private T result;
///////////////////////////////////////////////////////////////////////////
@@ -43,4 +45,20 @@ public class DingResponse<T> {
public void setResult(T result) {
this.result = result;
}
public String getTicket() {
return ticket;
}
public void setTicket(String ticket) {
this.ticket = ticket;
}
public Long getExpiresIn() {
return expiresIn;
}
public void setExpiresIn(Long expiresIn) {
this.expiresIn = expiresIn;
}
}

View File

@@ -6,10 +6,8 @@ import java.util.List;
/**
* @author hao
*/
public class DingUserInfo {
public class DingUserInfo extends DingUserSimple {
private String name;
private String userid;
private String avatar;
private String mobile;
private String email;
@@ -17,7 +15,6 @@ public class DingUserInfo {
private String nickname;
private String title;
private String remark;
private String unionid;
private String appId;
private List<String> deptIdList;
private boolean leader;
@@ -34,30 +31,6 @@ public class DingUserInfo {
// 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() {
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.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.tiesheng.platform.config.wxmp.bean.WxConfigBean;
@@ -50,12 +51,13 @@ public class PlatformWxminiConfig {
*/
public String jscode2session(String service, String code) {
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()
+ "&secret=" + configBean.getAppSecret()
+ "&js_code=" + code + "&grant_type=authorization_code").execute().body();
JSONObject object = JSONUtil.parseObj(body);
return object.getStr("openid");
+ "&js_code=" + code + "&grant_type=authorization_code").execute()) {
JSONObject object = JSONUtil.parseObj(response.body());
return object.getStr("openid");
}
}
/**
@@ -65,11 +67,12 @@ public class PlatformWxminiConfig {
*/
public String getAccessToken(String 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()
+ "&secret=" + configBean.getAppSecret()).execute().body();
JSONObject object = JSONUtil.parseObj(body);
return object.getStr("access_token");
+ "&secret=" + configBean.getAppSecret()).execute()) {
JSONObject object = JSONUtil.parseObj(response.body());
return object.getStr("access_token");
}
}

View File

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

BIN
springboot-util/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.8</version>
<version>zjut-1.1.6</version>
</parent>
<artifactId>springboot-util</artifactId>

BIN
springboot-util/src/main/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -26,7 +26,8 @@ public class ServletKit extends ServletUtil {
* @return
*/
public static String getClientIP() {
return getClientIP(getRequest());
HttpServletRequest request = getRequest();
return getClientIP(request);
}

View File

@@ -23,16 +23,26 @@ public class EncryptConfig {
/**
* 加解密对象
*/
private final SM4 sm4;
private static SM4 sm4;
/**
* 加密密钥
*/
private String key = "WmdUzPJXbngVNiaSsQrihg==";
private String key = "Z1mn6fKe6ubnm5762KR3Cg==";
private Integer saltSize = 8;
private boolean body = false;
public EncryptConfig() {
sm4 = SmUtil.sm4(Base64.decode(getKey()));
/**
* 获取SM4对象
*
* @return
*/
private SM4 getSm4() {
if (sm4 == null) {
sm4 = SmUtil.sm4(Base64.decode(getKey()));
}
return sm4;
}
/**
@@ -45,7 +55,7 @@ public class EncryptConfig {
if (StrUtil.isEmpty(content)) {
return "";
}
return sm4.encryptBase64(content);
return getSm4().encryptBase64(content);
}
@@ -57,7 +67,7 @@ public class EncryptConfig {
*/
public String decrypt(String base64) {
try {
return sm4.decryptStr(base64);
return getSm4().decryptStr(base64);
} catch (Exception ignore) {
}
return base64;
@@ -72,7 +82,7 @@ public class EncryptConfig {
* @return
*/
public String passwdCreate(String inputPasswd, String salt) {
if (StrUtil.isEmpty(salt)) {
if (StrUtil.isEmpty(salt) || StrUtil.length(salt) != getSaltSize()) {
salt = RandomUtil.randomString(saltSize);
}
if (!passwdComplexity(inputPasswd)) {
@@ -116,7 +126,8 @@ public class EncryptConfig {
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
/// ////////////////////////////////////////////////////////////////////////
public String getKey() {
return key;
@@ -133,4 +144,12 @@ public class EncryptConfig {
public void setSaltSize(Integer saltSize) {
this.saltSize = saltSize;
}
public boolean isBody() {
return body;
}
public void setBody(boolean body) {
this.body = body;
}
}

View File

@@ -4,8 +4,9 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.comparator.VersionComparator;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil;
import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.json.JSONUtil;
import cn.hutool.http.HttpGlobalConfig;
import cn.hutool.log.LogFactory;
import com.tiesheng.util.exception.ApiException;
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -13,10 +14,12 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
@@ -31,10 +34,37 @@ public class GlobalConfig {
private String version;
private String uploadDir = System.getProperty("user.dir");
/**
* 其他属性
*/
private HashMap<String, String> ext;
@PostConstruct
public void init() {
// 默认10s的超时时间
HttpGlobalConfig.setTimeout(10 * 1000);
// 最多重定向3次
HttpGlobalConfig.setMaxRedirectCount(3);
}
///////////////////////////////////////////////////////////////////////////
// 逻辑方法
///////////////////////////////////////////////////////////////////////////
/**
* 获取扩展属性内容
*
* @param extkey
* @return
*/
public String getExtValue(String extkey) {
if (getExt() == null) {
return "";
}
return getExt().get(extkey);
}
public String getContextPath() {
String context = SpringUtil.getProperty("server.servlet.context-path");
if (StrUtil.isEmpty(context)) {
@@ -87,7 +117,8 @@ public class GlobalConfig {
if (FileUtil.exist(folder)) {
File[] files = FileUtil.ls(folder);
for (File file : files) {
versions.add(StrUtil.subAfter(file.getAbsolutePath(), htmlDir, true));
String normalize = FileUtil.normalize(file.getAbsolutePath());
versions.add(StrUtil.subAfter(normalize, htmlDir, true));
}
}
@@ -138,4 +169,12 @@ public class GlobalConfig {
public void setVersion(String version) {
this.version = version;
}
public HashMap<String, String> getExt() {
return ext;
}
public void setExt(HashMap<String, String> ext) {
this.ext = ext;
}
}

View File

@@ -179,7 +179,7 @@ public class Searcher {
this.ioCount = 0;
// locate the segment index block based on the vector index
int sPtr = 0, ePtr = 0;
int sPtr, ePtr;
int il0 = (int) ((ip >> 24) & 0xFF);
int il1 = (int) ((ip >> 16) & 0xFF);
int idx = il0 * VectorIndexCols * VectorIndexSize + il1 * VectorIndexSize;

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.8</version>
<version>zjut-1.1.6</version>
</parent>
<artifactId>springboot-web</artifactId>
@@ -85,7 +85,7 @@
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-encrypt</artifactId>
</dependency>
</dependency><dependency><groupId>org.apache.xmlbeans</groupId><artifactId>xmlbeans</artifactId><version>3.1.0</version><scope>compile</scope></dependency>
</dependencies>

View File

@@ -2,6 +2,7 @@ package com.tiesheng.core;
import com.tiesheng.core.service.TieshengWebConfigurer;
import com.tiesheng.database.DatabaseAutoConfigurer;
import com.tiesheng.encrypt.EncryptAutoConfigurer;
import com.tiesheng.login.LoginAutoConfigurer;
import com.tiesheng.message.MessageAutoConfigurer;
import com.tiesheng.util.UtilAutoConfigurer;
@@ -20,7 +21,8 @@ import java.lang.annotation.*;
MessageAutoConfigurer.class,
CoreAutoConfigurer.class,
LoginAutoConfigurer.class,
DatabaseAutoConfigurer.class
DatabaseAutoConfigurer.class,
EncryptAutoConfigurer.class
})
public @interface EnableTieshengWeb {

View File

@@ -19,7 +19,11 @@ public class MybatisTimeMetaHandler implements MetaObjectHandler {
@Override
public void insertFill(MetaObject metaObject) {
// 其中方法参数中第一个是前面自动填充所对应的字段,第二个是要自动填充的值。第三个是指定实体类的对象
this.setFieldValByName("createTime", DateUtil.date(), metaObject);
Object createTime = getFieldValByName("createTime", metaObject);
if (createTime == null) {
createTime = DateUtil.date();
}
this.setFieldValByName("createTime", createTime, metaObject);
this.setFieldValByName("updateTime", DateUtil.date(), metaObject);
}

View File

@@ -0,0 +1,34 @@
package com.tiesheng.core.config.template;
import com.tiesheng.core.pojos.dto.TemplateDealDTO;
import org.springframework.stereotype.Service;
@Service
public class TieshengTemplateHandler implements ToolTemplateHandler {
@Override
public String handler(TemplateDealDTO dto) {
return "";
}
@Override
public String getTemplateUrl() {
return "";
}
@Override
public Object getParms(Object params) {
return "";
}
@Override
public String getAction() {
return "";
}
@Override
public int getSort() {
return 0;
}
}

View File

@@ -0,0 +1,54 @@
package com.tiesheng.core.config.template;
import cn.hutool.core.util.StrUtil;
import com.tiesheng.core.pojos.dto.TemplateDealDTO;
import org.springframework.stereotype.Service;
@Service
public interface ToolTemplateHandler {
/**
* 处理对象
*
* @param dto
* @return
*/
String handler(TemplateDealDTO dto);
/**
* 获取模版地址
*
* @return
*/
String getTemplateUrl();
Object getParms(Object params);
/**
* 动作说明(唯一)
*
* @return
*/
String getAction();
/**
* 排序如果action相同只会使用sort大的来处理
*
* @return
*/
int getSort();
/**
* 获取模版ID
*
* @return
*/
default String getTeamplateId() {
return StrUtil.format("{}_{}", getAction(), getSort());
}
}

View File

@@ -3,6 +3,7 @@ package com.tiesheng.core.controller;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tiesheng.annotation.token.TokenIgnore;
import com.tiesheng.core.pojos.dao.CoreLogLogin;
import com.tiesheng.core.pojos.dao.CoreLogMessage;
import com.tiesheng.core.pojos.dao.CoreLogOperation;
@@ -40,11 +41,11 @@ public class LogController {
QueryWrapper<CoreLogOperation> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("is_deleted", 0);
dto.likeColumns(queryWrapper, "user_name", "title", "subject", "params");
dto.likeColumns(queryWrapper, "user_name", "title", "subject");
queryWrapper.orderByDesc("create_time");
Page<CoreLogOperation> page = dto.pageObj();
coreLogService.page(page, queryWrapper);
coreLogService.getBaseMapper().page(page, queryWrapper);
return ApiResp.respOK(page.getRecords(), page.getTotal());
}

View File

@@ -2,20 +2,26 @@ package com.tiesheng.core.controller;
import cn.hutool.captcha.LineCaptcha;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.tiesheng.annotation.token.TokenIgnore;
import com.tiesheng.core.pojos.dto.ChunkCheckDTO;
import com.tiesheng.core.pojos.dto.ChunkMergeDTO;
import com.tiesheng.core.pojos.dto.ChunkStartDTO;
import com.tiesheng.core.pojos.dto.ImageCodeDTO;
import com.tiesheng.core.config.template.ToolTemplateHandler;
import com.tiesheng.core.pojos.dto.*;
import com.tiesheng.core.pojos.vo.TemplateInfoVO;
import com.tiesheng.core.pojos.vo.PicVerifyVo;
import com.tiesheng.core.service.FileUploadService;
import com.tiesheng.core.service.TimedCacheService;
import com.tiesheng.util.exception.ApiException;
import com.tiesheng.util.pojos.ApiResp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 工具类
*
@@ -29,6 +35,8 @@ public class ToolController {
TimedCacheService timedCacheService;
@Autowired
FileUploadService fileUploadService;
@Autowired
List<ToolTemplateHandler> templateHandlerList;
/**
@@ -117,4 +125,40 @@ public class ToolController {
}
@TokenIgnore
@GetMapping("/template/info")
public ApiResp<TemplateInfoVO> templateInfo(TemplateInfoDTO dto) {
List<ToolTemplateHandler> collect = templateHandlerList.stream()
.filter(it -> Objects.equals(it.getAction(), dto.getAction()))
.sorted((it, it2) -> it2.getSort() - it.getSort())
.collect(Collectors.toList());
if (CollUtil.isEmpty(collect)) {
throw new ApiException("没有找到对应的模版");
}
ToolTemplateHandler toolTemplateHandler = collect.get(0);
TemplateInfoVO template = new TemplateInfoVO();
template.setTemplateUrl(toolTemplateHandler.getTemplateUrl());
template.setParams(toolTemplateHandler.getParms(dto.getParams()));
template.setTemplateId(toolTemplateHandler.getTeamplateId());
return ApiResp.respOK(template);
}
@TokenIgnore
@PostMapping("/template/deal")
public ApiResp<String> templateDeal(@RequestBody TemplateDealDTO dto) {
List<ToolTemplateHandler> collect = templateHandlerList.stream().
filter(it -> Objects.equals(it.getTeamplateId(), dto.getTemplateId()))
.collect(Collectors.toList());
if (CollUtil.isEmpty(collect)) {
throw new ApiException("模版ID不存在");
}
return ApiResp.respOK(collect.get(0).handler(dto));
}
}

View File

@@ -1,8 +1,23 @@
package com.tiesheng.core.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tiesheng.core.pojos.dao.CoreLogOperation;
import org.apache.ibatis.annotations.Param;
public interface CoreLogOperationMapper extends BaseMapper<CoreLogOperation> {
/**
* 获取日志列表
*
* @param page
* @param queryWrapper
* @return
*/
Page<CoreLogOperation> page(IPage<CoreLogOperation> page, @Param("ew") QueryWrapper<CoreLogOperation> queryWrapper);
}

View File

@@ -9,6 +9,12 @@ import java.util.Date;
public class DaoBase {
public static final String ID = "id";
public static final String CREATE_TIME = "create_time";
public static final String UPDATE_TIME = "update_time";
public static final String IS_DELETED = "is_deleted";
public static final String LIMIT_1 = "limit 1";
@TableId(value = "id", type = IdType.ASSIGN_ID)
private String id;

View File

@@ -0,0 +1,40 @@
package com.tiesheng.core.pojos.dto;
import javax.validation.constraints.NotEmpty;
public class TemplateDealDTO {
@NotEmpty(message = "模版ID")
private String templateId;
@NotEmpty(message = "文件路径必填")
private String file;
private Object params;
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
public String getTemplateId() {
return templateId;
}
public void setTemplateId(String templateId) {
this.templateId = templateId;
}
public String getFile() {
return file;
}
public void setFile(String file) {
this.file = file;
}
public Object getParams() {
return params;
}
public void setParams(Object params) {
this.params = params;
}
}

View File

@@ -0,0 +1,28 @@
package com.tiesheng.core.pojos.dto;
public class TemplateInfoDTO {
private String action;
private Object params;
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public Object getParams() {
return params;
}
public void setParams(Object params) {
this.params = params;
}
}

View File

@@ -0,0 +1,37 @@
package com.tiesheng.core.pojos.vo;
public class TemplateInfoVO {
private String templateId;
private String templateUrl;
private Object params;
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
public String getTemplateId() {
return templateId;
}
public void setTemplateId(String templateId) {
this.templateId = templateId;
}
public String getTemplateUrl() {
return templateUrl;
}
public void setTemplateUrl(String templateUrl) {
this.templateUrl = templateUrl;
}
public Object getParams() {
return params;
}
public void setParams(Object params) {
this.params = params;
}
}

View File

@@ -28,6 +28,28 @@ public class CoreConfigService extends TsServiceBase<CoreConfigSystemMapper, Cor
}
/**
* 获取(或创建)一个文本类型的配置
*
* @param configKey
* @param defaultValue
* @return
*/
public CoreConfigSystem getTextOrCreate(String configKey, String defaultValue) {
CoreConfigSystem oneByColumn = getOneByColumn("config_key", configKey);
if (oneByColumn == null) {
oneByColumn = new CoreConfigSystem();
oneByColumn.setId(configKey);
oneByColumn.setConfigKey(configKey);
oneByColumn.setConfigVal(defaultValue);
oneByColumn.setRemark(defaultValue);
oneByColumn.setConfigType(0);
save(oneByColumn);
}
return oneByColumn;
}
/**
* 刷新功能点
*

View File

@@ -11,6 +11,7 @@ import com.tiesheng.core.pojos.dao.CoreJobUser;
import com.tiesheng.util.pojos.IdName;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
@@ -35,6 +36,7 @@ public class CoreJobService extends TsServiceBase<CoreJobMapper, CoreJob> {
* @param remark
* @param isSystem
*/
@Transactional(rollbackFor = Exception.class)
public void refresh(String id, String name, String remark, Integer isSystem) {
CoreJob coreJob = new CoreJob();
coreJob.setId(id);

View File

@@ -96,6 +96,7 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
coreLogProcess.setProcess(coreLogProcess.getProcess() + it.size());
coreLogProcess.setSuccessNum(coreLogProcess.getSuccessNum() + accept);
coreLogProcess.setFailNum(coreLogProcess.getFailNum() + it.size() - accept);
coreLogProcess.setError(JSONUtil.toJsonStr(errorList));
coreLogProcessMapper.updateById(coreLogProcess);
});
@@ -139,6 +140,7 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
lastCount = consumer.accept(pageNum, pageSize);
coreLogProcess.setTotal(coreLogProcess.getTotal() + lastCount);
coreLogProcess.setProcess(coreLogProcess.getTotal());
coreLogProcess.setError(JSONUtil.toJsonStr(errorList));
coreLogProcess.setSuccessNum(coreLogProcess.getSuccessNum() + lastCount);
} catch (Exception e) {
errorList.add(e);

View File

@@ -28,10 +28,38 @@ public class CoreMessageService {
CoreLogMessageMapper coreLogMessageMapper;
/**
* 插入数据
*
* @param reqResp
*/
private void insertMessageLog(MessageReqResp reqResp) {
if (reqResp == null) {
return;
}
coreLogMessageMapper.insert(BeanUtil.copyProperties(reqResp, CoreLogMessage.class));
}
/**
* 发送所有消息
*
* @param userIds
* @param body
*/
public void all(List<String> userIds, JSONObject body) {
messageSenderList.stream().filter(TieshengMessageSender::support)
.forEach(sender -> {
for (String user : userIds) {
insertMessageLog(sender.send(user, body));
}
});
}
/**
* 发送消息
*
* @param title
* @param channels
* @param body
* @param channels 消息通道如果为all时表示发送全部通道
*/
@@ -41,12 +69,8 @@ public class CoreMessageService {
}
messageSenderList.stream().filter(TieshengMessageSender::support)
.forEach(sender -> {
channels.stream().filter(it -> Objects.equals(it.getChannel(), sender.getChannel())).forEach(it -> {
MessageReqResp reqResp = sender.send(it.getUser(), body);
coreLogMessageMapper.insert(BeanUtil.copyProperties(reqResp, CoreLogMessage.class));
});
});
.forEach(sender -> channels.stream().filter(it -> Objects.equals(it.getChannel(), sender.getChannel()))
.forEach(it -> insertMessageLog(sender.send(it.getUser(), body))));
}
@@ -54,7 +78,6 @@ public class CoreMessageService {
* 发送消息
*
* @param userChannel
* @param title
* @param body
*/
public MessageReqResp send(UserChannel userChannel, JSONObject body) {
@@ -67,7 +90,7 @@ public class CoreMessageService {
sender -> Objects.equals(sender.getChannel(), userChannel.getChannel()) && sender.support());
if (messageSender != null) {
MessageReqResp reqResp = messageSender.send(userChannel.getUser(), body);
coreLogMessageMapper.insert(BeanUtil.copyProperties(reqResp, CoreLogMessage.class));
insertMessageLog(reqResp);
return reqResp;
}
return null;

View File

@@ -1,6 +1,6 @@
package com.tiesheng.core.service;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import cn.hutool.core.util.StrUtil;
import com.tiesheng.core.mapper.CorePlatformUniqueMapper;
import com.tiesheng.core.pojos.dao.CorePlatformUnique;
import com.tiesheng.login.config.token.bean.TokenBean;
@@ -8,8 +8,10 @@ import com.tiesheng.login.pojos.DoLoginInfo;
import com.tiesheng.login.service.TieshengLoginConfigurer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.util.Objects;
/**
* @author hao
@@ -23,6 +25,7 @@ public class CorePlatformUniqueService extends TsServiceBase<CorePlatformUniqueM
CoreLogService coreLogService;
@Override
@Transactional(rollbackFor = Exception.class)
public TokenBean doLogin(DoLoginInfo loginInfo) {
CorePlatformUnique platformUnique = getOneByColumn("unique_id", loginInfo.getUnique());
@@ -35,11 +38,22 @@ public class CorePlatformUniqueService extends TsServiceBase<CorePlatformUniqueM
platformUnique.setInfo(loginInfo.getInfo());
saveOrUpdate(platformUnique);
String oldUserId = platformUnique.getUserId();
TokenBean tokenBean = tieshengWebConfigurer.login(platformUnique);
if (tokenBean != null) {
// 添加登录日志
coreLogService.addLoginLog(platformUnique, tokenBean);
// 更新唯一值
if (!StrUtil.isEmpty(tokenBean.getId()) &&
!Objects.equals(oldUserId, tokenBean.getId())) {
platformUnique.setUserId(tokenBean.getId());
saveOrUpdate(platformUnique);
}
}
return tokenBean;
}
@@ -48,19 +62,9 @@ public class CorePlatformUniqueService extends TsServiceBase<CorePlatformUniqueM
tieshengWebConfigurer.redirect(bean, to, extra, response);
}
/**
* 更新用户id
*
* @param uniqueId
* @param userId
* @return
*/
public boolean updateUserId(String uniqueId, String userId) {
return update(new UpdateWrapper<CorePlatformUnique>().eq("unique_id", uniqueId)
.set("user_id", userId)
.set("is_deleted", 0)
);
@Override
public void onSignError(HttpServletResponse response) {
tieshengWebConfigurer.onSignError(response);
}

View File

@@ -14,6 +14,7 @@ import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
/**
@@ -159,12 +160,7 @@ public class FileUploadService {
//将文件数组转成list并排序
List<File> chunkFileList = new ArrayList<>(Arrays.asList(chunkFiles));
//排序
chunkFileList.sort((o1, o2) -> {
if (Integer.parseInt(o1.getName()) > Integer.parseInt(o2.getName())) {
return 1;
}
return -1;
});
chunkFileList.sort(Comparator.comparingInt(o -> Integer.parseInt(o.getName())));
return chunkFileList;
}

View File

@@ -5,6 +5,7 @@ import com.tiesheng.core.pojos.RequestUserInfo;
import com.tiesheng.core.pojos.dao.CoreConfigSystem;
import com.tiesheng.core.pojos.dao.CorePlatformUnique;
import com.tiesheng.login.config.token.bean.TokenBean;
import com.tiesheng.util.ServletKit;
import com.tiesheng.util.exception.ApiRespEnum;
import com.tiesheng.util.pojos.ApiResp;
import org.springframework.web.multipart.MultipartFile;
@@ -91,5 +92,11 @@ public interface TieshengWebConfigurer {
*/
void redirect(TokenBean bean, String to, String extra, HttpServletResponse response);
/**
* 签名错误的时候
*/
default void onSignError(HttpServletResponse response) {
ServletKit.write(response, "404", "text");
}
}

View File

@@ -0,0 +1,44 @@
package com.tiesheng.core.util;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import java.util.Map;
public class CharacterUtils {
/**
* 移除特殊字符
*
* @param o 类
*/
public static void removeSymbol(Object o) {
removeSymbol(o, "\n|\r|\t| ");
}
/**
* 移除特殊字符
*
* @param o 类
* @param searchStr 规则
*/
public static void removeSymbol(Object o, String searchStr) {
JSONObject object = JSONUtil.parseObj(o, false);
for (Map.Entry<String, Object> entry : object) {
if (ObjectUtil.isEmpty(entry.getValue()) || StrUtil.equals("null", String.valueOf(entry.getValue()))) {
entry.setValue("");
continue;
}
if (StrUtil.isNotEmpty(entry.getKey())) {
entry.setValue(StrUtil.trim(StrUtil.replace(entry.getValue().toString(), searchStr, "")));
}
}
BeanUtil.copyProperties(object, o);
}
}

View File

@@ -84,7 +84,7 @@ CREATE TABLE `core_log_operation`
`user_name` varchar(255) DEFAULT NULL COMMENT '用户名称',
`title` varchar(255) DEFAULT NULL COMMENT '标题',
`subject` varchar(500) DEFAULT NULL COMMENT '小标题',
`params` text COMMENT '其他参数',
`params` longtext COMMENT '其他参数',
PRIMARY KEY (`id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 COMMENT ='日志-操作';

View File

@@ -19,4 +19,9 @@
id, create_time, update_time, is_deleted, user_id, user_name, title, subject, params
</sql>
<select id="page" resultMap="BaseResultMap">
select id,create_time,update_time,is_deleted,user_name,user_id,title,subject from core_log_operation
${ew.customSqlSegment}
</select>
</mapper>