Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86384a1f23 | ||
|
|
d63b6ab094 | ||
|
|
020d1d99e1 | ||
|
|
32fb562775 | ||
|
|
af50468743 | ||
|
|
cab794ecc4 | ||
|
|
0c511940aa | ||
|
|
60dea50e43 | ||
|
|
cbfeb09a22 | ||
|
|
ef97488ea0 | ||
|
|
8873053c06 | ||
|
|
a65ea27485 | ||
|
|
4343601da1 | ||
|
|
f07e6d99e3 | ||
|
|
fc4b3139aa | ||
|
|
fe9d107eef | ||
|
|
0094bf2e69 | ||
|
|
c0fb149558 | ||
|
|
eb55969063 | ||
|
|
488c53def0 | ||
|
|
c02e67f85f | ||
|
|
9f62986a1e | ||
|
|
07136a6679 | ||
|
|
c3edb50e80 | ||
|
|
aee1861630 | ||
|
|
4196b2531d | ||
|
|
dfaeacae92 | ||
|
|
b304c48dd1 | ||
|
|
d045534be6 | ||
|
|
56b923f5db | ||
|
|
f3e8231814 | ||
|
|
2ca04e654f | ||
|
|
149f4ab061 |
32
CHANGELOG.md
Normal file
32
CHANGELOG.md
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
## 0.8.3
|
||||||
|
|
||||||
|
### 调整
|
||||||
|
|
||||||
|
> 1,优化返回数据加密;
|
||||||
|
> 2,上传文件接口调整,统一为**application/json**格式;
|
||||||
|
|
||||||
|
## 0.8.0
|
||||||
|
|
||||||
|
### 调整
|
||||||
|
|
||||||
|
> 1,移除**PasswordUtil**类,新增**EncryptConfig**配置;
|
||||||
|
> 2,默认启用网络请求的加解密,前端请配合接口使用。
|
||||||
|
|
||||||
|
## 0.7.4
|
||||||
|
|
||||||
|
### 新增
|
||||||
|
|
||||||
|
> 现在操作日志默认收集(不包括GET请求):使用方法名称和接口作为参数存储。如果存在OperationLog注解,则使用注解的内容。
|
||||||
|
|
||||||
|
## 0.7.3
|
||||||
|
|
||||||
|
### 增加
|
||||||
|
|
||||||
|
> 1,TsTokenConfig增加新的属性**ignorePaths**,用于通过路径忽略token;
|
||||||
|
> 2,PasswordUtils增加密码复杂度校验方法;
|
||||||
|
> 3,PasswordUtils.verifyPassword增加登录次数限制:10分钟内不能错误6次;
|
||||||
|
>
|
||||||
|
|
||||||
|
### 调整
|
||||||
|
|
||||||
|
> 1,TsTokenConfig中的**ignores**属性调整为**testMap**;
|
||||||
4
README.md
Normal file
4
README.md
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
## 杭州铁晟科技有限公司基础项目
|
||||||
|
|
||||||
|
更新日志可点击查看[changelog](./CHANGELOG.md ':include')
|
||||||
|
|
||||||
20
pom.xml
20
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.8.7</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>springboot-parent</name>
|
<name>springboot-parent</name>
|
||||||
<description>杭州铁晟科技有限公司基础依赖</description>
|
<description>杭州铁晟科技有限公司基础依赖</description>
|
||||||
@@ -57,55 +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>0.7.0</version>
|
<version>0.8.7</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>0.7.0</version>
|
<version>0.8.7</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>0.7.0</version>
|
<version>0.8.7</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>0.7.0</version>
|
<version>0.8.7</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>0.7.0</version>
|
<version>0.8.7</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>0.7.0</version>
|
<version>0.8.7</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>0.7.0</version>
|
<version>0.8.7</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>0.7.0</version>
|
<version>0.8.7</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>0.7.0</version>
|
<version>0.8.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -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>0.7.0</version>
|
<version>0.8.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-ademo</artifactId>
|
<artifactId>springboot-ademo</artifactId>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.tiesheng.demo;
|
|||||||
|
|
||||||
import com.tiesheng.core.EnableTieshengWeb;
|
import com.tiesheng.core.EnableTieshengWeb;
|
||||||
import com.tiesheng.demo.config.DemoWebConfigurer;
|
import com.tiesheng.demo.config.DemoWebConfigurer;
|
||||||
|
import com.tiesheng.encrypt.EnableEncryptConfig;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
@@ -13,6 +14,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) {
|
||||||
|
|||||||
@@ -20,7 +20,10 @@ public class DemoWebConfigurer implements TieshengWebConfigurer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RequestUserInfo getCurrentUserName(TokenBean tokenBean) {
|
public RequestUserInfo getCurrentUserName(TokenBean tokenBean) {
|
||||||
return null;
|
RequestUserInfo info = new RequestUserInfo();
|
||||||
|
info.setId("1");
|
||||||
|
info.setName("test");
|
||||||
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.tiesheng.login.config.token.TsTokenConfig;
|
|||||||
import com.tiesheng.login.config.token.bean.TokenBean;
|
import com.tiesheng.login.config.token.bean.TokenBean;
|
||||||
import com.tiesheng.message.config.aliyun.AliyunSmsConfig;
|
import com.tiesheng.message.config.aliyun.AliyunSmsConfig;
|
||||||
import com.tiesheng.message.pojos.MessageReqResp;
|
import com.tiesheng.message.pojos.MessageReqResp;
|
||||||
|
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.pojos.ApiResp;
|
import com.tiesheng.util.pojos.ApiResp;
|
||||||
@@ -35,10 +36,11 @@ public class TestController {
|
|||||||
TsTokenConfig tsTokenConfig;
|
TsTokenConfig tsTokenConfig;
|
||||||
@Autowired
|
@Autowired
|
||||||
Ip2regionConfig ip2regionConfig;
|
Ip2regionConfig ip2regionConfig;
|
||||||
|
@Autowired
|
||||||
|
EncryptConfig encryptConfig;
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping("/index")
|
@RequestMapping("/index")
|
||||||
@TokenIgnore
|
|
||||||
public ApiResp<String> index() {
|
public ApiResp<String> index() {
|
||||||
|
|
||||||
TokenBean tokenBean = new TokenBean("11", "", "fdfd");
|
TokenBean tokenBean = new TokenBean("11", "", "fdfd");
|
||||||
@@ -50,13 +52,12 @@ public class TestController {
|
|||||||
@RequestMapping("/redirect")
|
@RequestMapping("/redirect")
|
||||||
@TokenIgnore
|
@TokenIgnore
|
||||||
public void redirect(HttpServletResponse response) {
|
public void redirect(HttpServletResponse response) {
|
||||||
tsTokenConfig.validToken("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NzYwMDY4NzUsImlkIjoiMSIsImVudmlyb25tZW50VHlwZSI6Im1vYmlsZSIsInNlcnZpY2UiOiJjb250ZXN0LXJlc2VydmUiLCJleHRyYSI6IiJ9.nsfxEFpCNHC7eNCS5DJXdu1VDdnHrTjSfgrozND70Lc", true);
|
// tsTokenConfig.validToken("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NzYwMDY4NzUsImlkIjoiMSIsImVudmlyb25tZW50VHlwZSI6Im1vYmlsZSIsInNlcnZpY2UiOiJjb250ZXN0LXJlc2VydmUiLCJleHRyYSI6IiJ9.nsfxEFpCNHC7eNCS5DJXdu1VDdnHrTjSfgrozND70Lc", true);
|
||||||
// globalConfig.redirect("mobile", "/test", response);
|
// globalConfig.redirect("mobile", "/test", response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping("/send")
|
@RequestMapping("/send")
|
||||||
@TokenIgnore
|
|
||||||
public ApiResp<MessageReqResp> sendMessage() {
|
public ApiResp<MessageReqResp> sendMessage() {
|
||||||
MessageReqResp reqResp = aliyunSmsConfig.sendSms("13567116463", "SMS_154950909",
|
MessageReqResp reqResp = aliyunSmsConfig.sendSms("13567116463", "SMS_154950909",
|
||||||
JSONUtil.createObj().putOpt("code", "123456"));
|
JSONUtil.createObj().putOpt("code", "123456"));
|
||||||
@@ -65,7 +66,6 @@ public class TestController {
|
|||||||
|
|
||||||
|
|
||||||
@RequestMapping("/export")
|
@RequestMapping("/export")
|
||||||
@TokenIgnore
|
|
||||||
public ApiResp<String> export() {
|
public ApiResp<String> export() {
|
||||||
|
|
||||||
// List<TestFile> list = new ArrayList<>();
|
// List<TestFile> list = new ArrayList<>();
|
||||||
@@ -100,8 +100,22 @@ public class TestController {
|
|||||||
@TokenIgnore
|
@TokenIgnore
|
||||||
public ApiResp<List<TestFile>> desensitize() {
|
public ApiResp<List<TestFile>> desensitize() {
|
||||||
TestFile file = new TestFile("11111");
|
TestFile file = new TestFile("11111");
|
||||||
|
file.setTest("111111");
|
||||||
TestFile file1 = new TestFile("22222");
|
TestFile file1 = new TestFile("22222");
|
||||||
|
file1.setTest("22222");
|
||||||
return ApiResp.respOK(CollUtil.newArrayList(file, file1));
|
return ApiResp.respOK(CollUtil.newArrayList(file, file1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping("passwd")
|
||||||
|
@TokenIgnore
|
||||||
|
public ApiResp<String> passwd() {
|
||||||
|
|
||||||
|
String passwdCreate = encryptConfig.passwdCreate("12345Zeng!", "");
|
||||||
|
LogFactory.get().info(passwdCreate);
|
||||||
|
encryptConfig.passwdVerify("12345Zeng!", passwdCreate);
|
||||||
|
|
||||||
|
return ApiResp.respOK("");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,21 @@
|
|||||||
package com.tiesheng.demo.pojos;
|
package com.tiesheng.demo.pojos;
|
||||||
|
|
||||||
import com.tiesheng.annotation.desensitize.Desensitize;
|
|
||||||
import com.tiesheng.poi.pojos.PoiWriteBase;
|
import com.tiesheng.poi.pojos.PoiWriteBase;
|
||||||
|
|
||||||
public class TestFile implements PoiWriteBase {
|
|
||||||
|
|
||||||
|
public class TestFile extends TestParent implements PoiWriteBase {
|
||||||
|
|
||||||
@Desensitize()
|
private String name;
|
||||||
private String test;
|
|
||||||
|
|
||||||
public TestFile(String test) {
|
public TestFile(String name) {
|
||||||
this.test = test;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
public String getName() {
|
||||||
// setter、getter
|
return name;
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
public String getTest() {
|
|
||||||
return test;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTest(String test) {
|
public void setName(String name) {
|
||||||
this.test = test;
|
this.name = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.tiesheng.demo.pojos;
|
||||||
|
|
||||||
|
import com.tiesheng.annotation.desensitize.Desensitize;
|
||||||
|
import com.tiesheng.poi.pojos.PoiWriteBase;
|
||||||
|
|
||||||
|
|
||||||
|
public class TestParent implements PoiWriteBase {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@Desensitize()
|
||||||
|
private String test;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// setter、getter
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTest() {
|
||||||
|
return test;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTest(String test) {
|
||||||
|
this.test = test;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,7 +16,7 @@ platform:
|
|||||||
|
|
||||||
tiesheng:
|
tiesheng:
|
||||||
token:
|
token:
|
||||||
ignores:
|
test-map:
|
||||||
"1111":
|
"1111":
|
||||||
id: "1111"
|
id: "1111"
|
||||||
global:
|
global:
|
||||||
|
|||||||
@@ -20,3 +20,7 @@ spring:
|
|||||||
logging:
|
logging:
|
||||||
file:
|
file:
|
||||||
name: runtime/logs/tiesheng.log
|
name: runtime/logs/tiesheng.log
|
||||||
|
tiesheng:
|
||||||
|
token:
|
||||||
|
ignore-paths:
|
||||||
|
- /test/index
|
||||||
|
|||||||
@@ -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>0.7.0</version>
|
<version>0.8.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-annotation</artifactId>
|
<artifactId>springboot-annotation</artifactId>
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
package com.tiesheng.annotation.encrypt;
|
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author hao
|
|
||||||
*/
|
|
||||||
@Target({ElementType.TYPE})
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Documented
|
|
||||||
public @interface EncryptedRespBody {
|
|
||||||
}
|
|
||||||
@@ -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>0.7.0</version>
|
<version>0.8.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-database</artifactId>
|
<artifactId>springboot-database</artifactId>
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ package com.tiesheng.database.service;
|
|||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.lang.func.VoidFunc1;
|
import cn.hutool.core.lang.func.VoidFunc1;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.db.Db;
|
import cn.hutool.db.Db;
|
||||||
import cn.hutool.db.Entity;
|
import cn.hutool.db.Entity;
|
||||||
|
import cn.hutool.log.LogFactory;
|
||||||
import com.tiesheng.database.config.DbMigrationConfig;
|
import com.tiesheng.database.config.DbMigrationConfig;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.web.servlet.ServletContextInitializer;
|
import org.springframework.boot.web.servlet.ServletContextInitializer;
|
||||||
@@ -20,7 +20,10 @@ import javax.servlet.ServletContext;
|
|||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.zip.Checksum;
|
import java.util.zip.Checksum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,14 +64,16 @@ public class DbMigrationInitializer implements ServletContextInitializer {
|
|||||||
dbMigrationConfig.checkDbExists(coreDb);
|
dbMigrationConfig.checkDbExists(coreDb);
|
||||||
|
|
||||||
PathMatchingResourcePatternResolver patternResolver = new PathMatchingResourcePatternResolver();
|
PathMatchingResourcePatternResolver patternResolver = new PathMatchingResourcePatternResolver();
|
||||||
|
List<Resource> resourceList = new ArrayList<>();
|
||||||
for (String location : dbMigrationConfig.getLocations()) {
|
for (String location : dbMigrationConfig.getLocations()) {
|
||||||
Resource[] resources = patternResolver.getResources(location);
|
Resource[] resources = patternResolver.getResources(location);
|
||||||
if (ArrayUtil.isEmpty(resources)) {
|
resourceList.addAll(Arrays.asList(resources));
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
for (Resource resource : resources) {
|
// 排序后执行sql
|
||||||
migrationByResource(resource, coreDb);
|
resourceList.sort((o1, o2) -> StrUtil.compare(o1.getFilename(), o2.getFilename(), true));
|
||||||
}
|
for (Resource resource : resourceList) {
|
||||||
|
migrationByResource(resource, coreDb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,6 +94,8 @@ public class DbMigrationInitializer implements ServletContextInitializer {
|
|||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
AtomicReference<Integer> success= new AtomicReference<>(0);
|
||||||
|
AtomicReference<Integer> fail= new AtomicReference<>(0);
|
||||||
db.tx((VoidFunc1<Db>) parameter -> {
|
db.tx((VoidFunc1<Db>) parameter -> {
|
||||||
List<String> split = StrUtil.split(readUtf8, ";");
|
List<String> split = StrUtil.split(readUtf8, ";");
|
||||||
for (String sql : split) {
|
for (String sql : split) {
|
||||||
@@ -101,11 +108,13 @@ public class DbMigrationInitializer implements ServletContextInitializer {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
parameter.execute(sql);
|
parameter.execute(sql);
|
||||||
|
success.getAndSet(success.get() + 1);
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
|
fail.getAndSet(fail.get() + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
LogFactory.get().info("执行sql文件{},成功数:{},失败数:{}。",filename,success.get(),fail.get());
|
||||||
entity.set("checksum", checksum.getValue());
|
entity.set("checksum", checksum.getValue());
|
||||||
entity.set("update_time", DateUtil.date());
|
entity.set("update_time", DateUtil.date());
|
||||||
db.update(entity, Entity.create(dbMigrationConfig.getTable()).set("id", entity.get("id")));
|
db.update(entity, Entity.create(dbMigrationConfig.getTable()).set("id", entity.get("id")));
|
||||||
|
|||||||
@@ -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>0.7.0</version>
|
<version>0.8.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-encrypt</artifactId>
|
<artifactId>springboot-encrypt</artifactId>
|
||||||
@@ -18,11 +18,6 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>org.bouncycastle</groupId>
|
|
||||||
<artifactId>bcprov-jdk15to18</artifactId>
|
|
||||||
<version>1.68</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
|||||||
@@ -1,20 +1,21 @@
|
|||||||
package com.tiesheng.encrypt;
|
package com.tiesheng.encrypt;
|
||||||
|
|
||||||
|
|
||||||
import com.tiesheng.encrypt.config.EncryptConfig;
|
import com.tiesheng.encrypt.config.DecryptRequestBodyAdvice;
|
||||||
import com.tiesheng.encrypt.config.EncryptRequestBodyAdvice;
|
|
||||||
import com.tiesheng.encrypt.config.EncryptResponseBodyAdvice;
|
import com.tiesheng.encrypt.config.EncryptResponseBodyAdvice;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hao
|
* @author hao
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@ComponentScan(basePackageClasses = {
|
@Target({ElementType.TYPE})
|
||||||
EncryptConfig.class,
|
@Documented
|
||||||
EncryptRequestBodyAdvice.class,
|
@Import({
|
||||||
|
DecryptRequestBodyAdvice.class,
|
||||||
EncryptResponseBodyAdvice.class,
|
EncryptResponseBodyAdvice.class,
|
||||||
})
|
})
|
||||||
public class EnableEncryptConfig {
|
public @interface EnableEncryptConfig {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,8 @@ package com.tiesheng.encrypt.config;
|
|||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.crypto.ECKeyUtil;
|
|
||||||
import cn.hutool.crypto.SmUtil;
|
|
||||||
import cn.hutool.crypto.asymmetric.KeyType;
|
|
||||||
import cn.hutool.crypto.asymmetric.SM2;
|
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import org.bouncycastle.crypto.params.ECPrivateKeyParameters;
|
import com.tiesheng.util.config.EncryptConfig;
|
||||||
import org.bouncycastle.crypto.params.ECPublicKeyParameters;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.core.MethodParameter;
|
import org.springframework.core.MethodParameter;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
@@ -26,7 +21,7 @@ import java.nio.charset.Charset;
|
|||||||
* @author hao
|
* @author hao
|
||||||
*/
|
*/
|
||||||
@ControllerAdvice
|
@ControllerAdvice
|
||||||
public class EncryptRequestBodyAdvice implements RequestBodyAdvice {
|
public class DecryptRequestBodyAdvice implements RequestBodyAdvice {
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -42,12 +37,8 @@ public class EncryptRequestBodyAdvice implements RequestBodyAdvice {
|
|||||||
public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, Type targetType,
|
public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, Type targetType,
|
||||||
Class<? extends HttpMessageConverter<?>> converterType) {
|
Class<? extends HttpMessageConverter<?>> converterType) {
|
||||||
|
|
||||||
if (!encryptConfig.isEnable()) {
|
|
||||||
return inputMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return new DecryptHttpInputMessage(inputMessage, encryptConfig.getPrivateQ());
|
return new DecryptHttpInputMessage(inputMessage, encryptConfig);
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,16 +63,12 @@ public class EncryptRequestBodyAdvice implements RequestBodyAdvice {
|
|||||||
private HttpHeaders headers;
|
private HttpHeaders headers;
|
||||||
private InputStream body;
|
private InputStream body;
|
||||||
|
|
||||||
DecryptHttpInputMessage(HttpInputMessage inputMessage, String privateQ) throws Exception {
|
DecryptHttpInputMessage(HttpInputMessage inputMessage, EncryptConfig encryptConfig) throws Exception {
|
||||||
this.headers = inputMessage.getHeaders();
|
this.headers = inputMessage.getHeaders();
|
||||||
String bodyStr = IoUtil.read(inputMessage.getBody(), CharsetUtil.CHARSET_UTF_8);
|
String bodyStr = IoUtil.read(inputMessage.getBody(), CharsetUtil.CHARSET_UTF_8);
|
||||||
String encryptData = JSONUtil.parseObj(bodyStr).getStr("encryptData");
|
String encryptData = JSONUtil.parseObj(bodyStr).getStr("encryptData");
|
||||||
if (!StrUtil.isEmpty(encryptData)) {
|
if (!StrUtil.isEmpty(encryptData)) {
|
||||||
// 部分语言加密之后缺少04前缀,如果解密失败,可尝试增加04
|
String decrypt = encryptConfig.decrypt(encryptData);
|
||||||
ECPrivateKeyParameters privateKeyParameters = ECKeyUtil.toSm2PrivateParams(privateQ);
|
|
||||||
ECPublicKeyParameters publicKeyParameters = ECKeyUtil.getPublicParams(privateKeyParameters);
|
|
||||||
SM2 sm2 = SmUtil.sm2(privateKeyParameters, publicKeyParameters);
|
|
||||||
String decrypt = sm2.decryptStr(encryptData, KeyType.PrivateKey);
|
|
||||||
this.body = IoUtil.toStream(decrypt, Charset.defaultCharset());
|
this.body = IoUtil.toStream(decrypt, Charset.defaultCharset());
|
||||||
} else {
|
} else {
|
||||||
this.body = IoUtil.toStream(bodyStr, Charset.defaultCharset());
|
this.body = IoUtil.toStream(bodyStr, Charset.defaultCharset());
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
package com.tiesheng.encrypt.config;
|
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author hao
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
@ConfigurationProperties(prefix = "tiesheng.encrypt")
|
|
||||||
public class EncryptConfig {
|
|
||||||
|
|
||||||
public String publicD;
|
|
||||||
public String privateQ;
|
|
||||||
private boolean enable = false;
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
// setter\getter
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
public boolean isEnable() {
|
|
||||||
return enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnable(boolean enable) {
|
|
||||||
this.enable = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPublicD() {
|
|
||||||
return publicD;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPublicD(String publicD) {
|
|
||||||
this.publicD = publicD;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPrivateQ() {
|
|
||||||
return privateQ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPrivateQ(String privateQ) {
|
|
||||||
this.privateQ = privateQ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +1,10 @@
|
|||||||
package com.tiesheng.encrypt.config;
|
package com.tiesheng.encrypt.config;
|
||||||
|
|
||||||
import cn.hutool.core.annotation.AnnotationUtil;
|
import cn.hutool.core.annotation.AnnotationUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import cn.hutool.crypto.ECKeyUtil;
|
|
||||||
import cn.hutool.crypto.SmUtil;
|
|
||||||
import cn.hutool.crypto.asymmetric.KeyType;
|
|
||||||
import cn.hutool.crypto.asymmetric.SM2;
|
|
||||||
import cn.hutool.json.JSONObject;
|
|
||||||
import cn.hutool.json.JSONUtil;
|
|
||||||
import cn.hutool.log.LogFactory;
|
import cn.hutool.log.LogFactory;
|
||||||
import com.tiesheng.annotation.encrypt.EncryptedRespBody;
|
import com.tiesheng.util.CommonUtil;
|
||||||
import org.bouncycastle.crypto.params.ECPrivateKeyParameters;
|
import com.tiesheng.util.config.EncryptConfig;
|
||||||
import org.bouncycastle.crypto.params.ECPublicKeyParameters;
|
import com.tiesheng.util.pojos.ApiResp;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.core.MethodParameter;
|
import org.springframework.core.MethodParameter;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
@@ -19,6 +12,7 @@ import org.springframework.http.converter.HttpMessageConverter;
|
|||||||
import org.springframework.http.server.ServerHttpRequest;
|
import org.springframework.http.server.ServerHttpRequest;
|
||||||
import org.springframework.http.server.ServerHttpResponse;
|
import org.springframework.http.server.ServerHttpResponse;
|
||||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
|
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
|
||||||
|
|
||||||
|
|
||||||
@@ -26,50 +20,30 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
|
|||||||
* @author hao
|
* @author hao
|
||||||
*/
|
*/
|
||||||
@ControllerAdvice
|
@ControllerAdvice
|
||||||
public class EncryptResponseBodyAdvice implements ResponseBodyAdvice<Object> {
|
public class EncryptResponseBodyAdvice implements ResponseBodyAdvice<ApiResp> {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
EncryptConfig encryptConfig;
|
EncryptConfig encryptConfig;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) {
|
public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) {
|
||||||
return true;
|
return AnnotationUtil.getAnnotation(returnType.getContainingClass(), RestController.class) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Class<? extends
|
public ApiResp beforeBodyWrite(ApiResp body, MethodParameter returnType, MediaType selectedContentType, Class<? extends
|
||||||
HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
|
HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
|
||||||
|
|
||||||
if (!encryptConfig.isEnable()) {
|
|
||||||
return body;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean encrypt = AnnotationUtil.getAnnotation(returnType.getContainingClass(), EncryptedRespBody.class) != null;
|
|
||||||
if (!encrypt) {
|
|
||||||
return body;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String content = JSONUtil.toJsonStr(body);
|
Object data = body.getData();
|
||||||
String respData = JSONUtil.parseObj(content).getStr("data");
|
if (data == null || !body.successful()) {
|
||||||
|
|
||||||
if (StrUtil.isEmpty(respData)) {
|
|
||||||
// 无需加密
|
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject resp = JSONUtil.parseObj(content);
|
body.setEncrypt(true);
|
||||||
resp.set("encrypted", true);
|
body.setData(encryptConfig.encrypt(CommonUtil.writeJsonString(data)));
|
||||||
if (resp.getInt("code") == 200) {
|
return body;
|
||||||
// 用公钥进行加密
|
|
||||||
ECPrivateKeyParameters privateKeyParameters = ECKeyUtil.toSm2PrivateParams(encryptConfig.getPrivateQ());
|
|
||||||
ECPublicKeyParameters publicKeyParameters = ECKeyUtil.getPublicParams(privateKeyParameters);
|
|
||||||
SM2 sm2 = SmUtil.sm2(privateKeyParameters, publicKeyParameters);
|
|
||||||
String decrypt = sm2.encryptHex(respData, KeyType.PublicKey);
|
|
||||||
resp.set("data", decrypt.substring(2));
|
|
||||||
}
|
|
||||||
return resp;
|
|
||||||
} catch (Exception var17) {
|
} catch (Exception var17) {
|
||||||
LogFactory.get().info("加密数据异常", var17);
|
LogFactory.get().info("加密数据异常", var17);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>0.7.0</version>
|
<version>0.8.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-login</artifactId>
|
<artifactId>springboot-login</artifactId>
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package com.tiesheng.login.config.token;
|
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.annotation.token.TokenIgnore;
|
||||||
|
import com.tiesheng.util.ServletKit;
|
||||||
import org.aspectj.lang.JoinPoint;
|
import org.aspectj.lang.JoinPoint;
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
import org.aspectj.lang.annotation.Before;
|
import org.aspectj.lang.annotation.Before;
|
||||||
@@ -46,13 +49,28 @@ public class TsTokenAspect {
|
|||||||
@Before("methodArgs()")
|
@Before("methodArgs()")
|
||||||
public void before(JoinPoint joinPoint) {
|
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();
|
Object aThis = joinPoint.getTarget();
|
||||||
TokenIgnore annotation = aThis.getClass().getAnnotation(TokenIgnore.class);
|
TokenIgnore annotation = aThis.getClass().getAnnotation(TokenIgnore.class);
|
||||||
if (annotation != null) {
|
if (annotation != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 过滤不要需要验证的接口
|
|
||||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||||
Method method = signature.getMethod();
|
Method method = signature.getMethod();
|
||||||
TokenIgnore apiTokenIgnore = method.getAnnotation(TokenIgnore.class);
|
TokenIgnore apiTokenIgnore = method.getAnnotation(TokenIgnore.class);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.tiesheng.login.config.token;
|
package com.tiesheng.login.config.token;
|
||||||
|
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
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;
|
||||||
@@ -24,9 +23,10 @@ import java.util.Map;
|
|||||||
@ConfigurationProperties("tiesheng.token")
|
@ConfigurationProperties("tiesheng.token")
|
||||||
public class TsTokenConfig {
|
public class TsTokenConfig {
|
||||||
|
|
||||||
private Map<String, TokenBean> ignores = 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;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,11 +57,11 @@ public class TsTokenConfig {
|
|||||||
* @param token
|
* @param token
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public TokenBean isIgnored(String token) {
|
public TokenBean isTestToken(String token) {
|
||||||
if (ignores == null) {
|
if (testMap == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return ignores.get(token);
|
return testMap.get(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ public class TsTokenConfig {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public TokenBean validToken(String token, boolean thrExp) {
|
public TokenBean validToken(String token, boolean thrExp) {
|
||||||
TokenBean tokenBean = isIgnored(token);
|
TokenBean tokenBean = isTestToken(token);
|
||||||
if (tokenBean != null) {
|
if (tokenBean != null) {
|
||||||
return tokenBean;
|
return tokenBean;
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,8 @@ public class TsTokenConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tokenBean == null && thrExp) {
|
if (tokenBean == null && thrExp) {
|
||||||
throw new ApiException(StrUtil.isEmpty(token) ? "请先登录" : "登录过期,请重新登陆");
|
throw new ApiException(StrUtil.isEmpty(token) ? 110 : 112,
|
||||||
|
StrUtil.isEmpty(token) ? "请先登录" : "登录过期,请重新登陆");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tokenBean == null) {
|
if (tokenBean == null) {
|
||||||
@@ -116,12 +117,12 @@ public class TsTokenConfig {
|
|||||||
// setter\getter
|
// setter\getter
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public Map<String, TokenBean> getIgnores() {
|
public Map<String, TokenBean> getTestMap() {
|
||||||
return ignores;
|
return testMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIgnores(Map<String, TokenBean> ignores) {
|
public void setTestMap(Map<String, TokenBean> testMap) {
|
||||||
this.ignores = ignores;
|
this.testMap = testMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEncryptKey() {
|
public String getEncryptKey() {
|
||||||
@@ -139,4 +140,12 @@ public class TsTokenConfig {
|
|||||||
public void setExpireHours(Integer expireHours) {
|
public void setExpireHours(Integer expireHours) {
|
||||||
this.expireHours = expireHours;
|
this.expireHours = expireHours;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String[] getIgnorePaths() {
|
||||||
|
return ignorePaths;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIgnorePaths(String[] ignorePaths) {
|
||||||
|
this.ignorePaths = ignorePaths;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/login")
|
@RequestMapping("/login")
|
||||||
|
@TokenIgnore
|
||||||
public class LoginController {
|
public class LoginController {
|
||||||
|
|
||||||
|
|
||||||
@@ -56,7 +57,6 @@ public class LoginController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("/unique/redirect")
|
@GetMapping("/unique/redirect")
|
||||||
@TokenIgnore
|
|
||||||
public void uniqueIndex(UniqueIndexDTO dto, HttpServletResponse response) {
|
public void uniqueIndex(UniqueIndexDTO dto, HttpServletResponse response) {
|
||||||
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo("unique_index_web",
|
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo("unique_index_web",
|
||||||
dto.getNo(), "web", dto.getTo(), dto.getInfo()));
|
dto.getNo(), "web", dto.getTo(), dto.getInfo()));
|
||||||
@@ -71,7 +71,6 @@ public class LoginController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/unique/index")
|
@PostMapping("/unique/index")
|
||||||
@TokenIgnore
|
|
||||||
public ApiResp<String> uniqueIndex(@RequestBody UniqueIndexDTO dto) {
|
public ApiResp<String> uniqueIndex(@RequestBody UniqueIndexDTO dto) {
|
||||||
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo("unique_index_web",
|
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo("unique_index_web",
|
||||||
dto.getNo(), "web", dto.getTo(), dto.getInfo()));
|
dto.getNo(), "web", dto.getTo(), dto.getInfo()));
|
||||||
@@ -94,7 +93,6 @@ public class LoginController {
|
|||||||
* @param response
|
* @param response
|
||||||
*/
|
*/
|
||||||
@GetMapping("/ding/index/{service}")
|
@GetMapping("/ding/index/{service}")
|
||||||
@TokenIgnore
|
|
||||||
public void dingIndex(@PathVariable String service, String extra, HttpServletResponse response) {
|
public void dingIndex(@PathVariable String service, String extra, HttpServletResponse response) {
|
||||||
if (StrUtil.isEmpty(extra)) {
|
if (StrUtil.isEmpty(extra)) {
|
||||||
extra = "";
|
extra = "";
|
||||||
@@ -118,7 +116,6 @@ public class LoginController {
|
|||||||
* @param service
|
* @param service
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/ding/oauth2/{service}")
|
@RequestMapping("/ding/oauth2/{service}")
|
||||||
@TokenIgnore
|
|
||||||
public void dingOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) {
|
public void dingOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) {
|
||||||
String ddUserId = platformDingConfig.getUserIdByCode(service, dto.getCode());
|
String ddUserId = platformDingConfig.getUserIdByCode(service, dto.getCode());
|
||||||
DingUserInfo dingUserInfo = platformDingConfig.topapiV2UserGet(service, ddUserId);
|
DingUserInfo dingUserInfo = platformDingConfig.topapiV2UserGet(service, ddUserId);
|
||||||
@@ -136,7 +133,6 @@ public class LoginController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("/ding/jssdk/{service}")
|
@GetMapping("/ding/jssdk/{service}")
|
||||||
@TokenIgnore
|
|
||||||
public ApiResp<DingJsapiSignature> dingJssdk(@PathVariable String service, String url) {
|
public ApiResp<DingJsapiSignature> dingJssdk(@PathVariable String service, String url) {
|
||||||
DingJsapiSignature jsapiSignature = platformDingConfig.createJsapiSignature(service, url);
|
DingJsapiSignature jsapiSignature = platformDingConfig.createJsapiSignature(service, url);
|
||||||
return ApiResp.respOK(jsapiSignature);
|
return ApiResp.respOK(jsapiSignature);
|
||||||
@@ -154,7 +150,6 @@ public class LoginController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/wxmp/index/{service}")
|
@RequestMapping("/wxmp/index/{service}")
|
||||||
@TokenIgnore
|
|
||||||
public void wxmpIndex(@PathVariable String service, String extra, HttpServletResponse response) throws IOException {
|
public void wxmpIndex(@PathVariable String service, String extra, HttpServletResponse response) throws IOException {
|
||||||
if (StrUtil.isEmpty(extra)) {
|
if (StrUtil.isEmpty(extra)) {
|
||||||
extra = "";
|
extra = "";
|
||||||
@@ -169,7 +164,6 @@ public class LoginController {
|
|||||||
* 微信授权回调
|
* 微信授权回调
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/wxmp/oauth2/{service}")
|
@RequestMapping("/wxmp/oauth2/{service}")
|
||||||
@TokenIgnore
|
|
||||||
public void wxmpOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) {
|
public void wxmpOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) {
|
||||||
WxUserInfo wxUserInfo = platformWxmpConfig.getOAuth2AccessToken(service, dto.getCode());
|
WxUserInfo wxUserInfo = platformWxmpConfig.getOAuth2AccessToken(service, dto.getCode());
|
||||||
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo(wxUserInfo.getAppId(),
|
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo(wxUserInfo.getAppId(),
|
||||||
@@ -185,7 +179,6 @@ public class LoginController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("/wxmp/jssdk/{service}")
|
@GetMapping("/wxmp/jssdk/{service}")
|
||||||
@TokenIgnore
|
|
||||||
public ApiResp<WxJsapiSignature> wxmpJssdk(@PathVariable String service, String url) {
|
public ApiResp<WxJsapiSignature> wxmpJssdk(@PathVariable String service, String url) {
|
||||||
WxJsapiSignature jsapiSignature = platformWxmpConfig.createJsapiSignature(service, url);
|
WxJsapiSignature jsapiSignature = platformWxmpConfig.createJsapiSignature(service, url);
|
||||||
return ApiResp.respOK(jsapiSignature);
|
return ApiResp.respOK(jsapiSignature);
|
||||||
@@ -201,7 +194,6 @@ public class LoginController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/wxmini/index/{service}")
|
@RequestMapping("/wxmini/index/{service}")
|
||||||
@TokenIgnore
|
|
||||||
public ApiResp<WxminiLoginVo> wxminiIndex(@PathVariable String service, String code) {
|
public ApiResp<WxminiLoginVo> wxminiIndex(@PathVariable String service, String code) {
|
||||||
String openid = platformWxminiConfig.jscode2session(service, code);
|
String openid = platformWxminiConfig.jscode2session(service, code);
|
||||||
WxConfigBean configBean = platformWxminiConfig.getConfigBean(service);
|
WxConfigBean configBean = platformWxminiConfig.getConfigBean(service);
|
||||||
|
|||||||
@@ -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>0.7.0</version>
|
<version>0.8.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-message</artifactId>
|
<artifactId>springboot-message</artifactId>
|
||||||
|
|||||||
@@ -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>0.7.0</version>
|
<version>0.8.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-platform</artifactId>
|
<artifactId>springboot-platform</artifactId>
|
||||||
|
|||||||
@@ -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>0.7.0</version>
|
<version>0.8.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-poi</artifactId>
|
<artifactId>springboot-poi</artifactId>
|
||||||
|
|||||||
@@ -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>0.7.0</version>
|
<version>0.8.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-util</artifactId>
|
<artifactId>springboot-util</artifactId>
|
||||||
@@ -25,6 +25,11 @@
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
|
<artifactId>springboot-annotation</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-all</artifactId>
|
<artifactId>hutool-all</artifactId>
|
||||||
@@ -37,6 +42,14 @@
|
|||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
<version>1.2.78</version>
|
<version>1.2.78</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 加解密 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bouncycastle</groupId>
|
||||||
|
<artifactId>bcprov-jdk15to18</artifactId>
|
||||||
|
<version>1.68</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.tiesheng.util;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||||
|
import com.alibaba.fastjson.support.config.FastJsonConfig;
|
||||||
|
import com.tiesheng.util.config.DesensitizeValueFilter;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class CommonUtil {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FastJson配置
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static FastJsonConfig fastJsonConfig() {
|
||||||
|
FastJsonConfig config = new FastJsonConfig();
|
||||||
|
config.setSerializerFeatures(SerializerFeature.WriteMapNullValue,
|
||||||
|
SerializerFeature.WriteNullStringAsEmpty,
|
||||||
|
SerializerFeature.WriteEnumUsingName);
|
||||||
|
config.setDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
config.setSerializeFilters(new DesensitizeValueFilter());
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化数据
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* @return
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public static String writeJsonString(Object value) throws IOException {
|
||||||
|
FastJsonConfig fastJsonConfig = fastJsonConfig();
|
||||||
|
ByteArrayOutputStream outnew = new ByteArrayOutputStream();
|
||||||
|
JSON.writeJSONStringWithFastJsonConfig(outnew, fastJsonConfig.getCharset(),
|
||||||
|
value, fastJsonConfig.getSerializeConfig(),
|
||||||
|
fastJsonConfig.getSerializeFilters(),
|
||||||
|
fastJsonConfig.getDateFormat(), JSON.DEFAULT_GENERATE_FEATURE,
|
||||||
|
fastJsonConfig.getSerializerFeatures());
|
||||||
|
return outnew.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
package com.tiesheng.util;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.RandomUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import cn.hutool.crypto.SecureUtil;
|
|
||||||
import com.tiesheng.util.exception.ApiException;
|
|
||||||
|
|
||||||
public class PasswordUtils {
|
|
||||||
|
|
||||||
private static final int PREFIX_SIZE = 8;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取加密密码
|
|
||||||
*
|
|
||||||
* @param password
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String buildPassword(String password) {
|
|
||||||
String prefix = RandomUtil.randomString(PREFIX_SIZE);
|
|
||||||
return prefix + SecureUtil.sha1(password);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证密码
|
|
||||||
*
|
|
||||||
* @param userInput
|
|
||||||
* @param encrypted
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static void verifyPassword(String userInput, String encrypted) {
|
|
||||||
String userEncrypted = buildPassword(userInput);
|
|
||||||
|
|
||||||
userEncrypted = StrUtil.subSuf(userEncrypted, PREFIX_SIZE);
|
|
||||||
encrypted = StrUtil.subSuf(encrypted, PREFIX_SIZE);
|
|
||||||
|
|
||||||
if (!StrUtil.equals(userEncrypted, encrypted)) {
|
|
||||||
throw new ApiException("账号或密码错误");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -20,5 +20,14 @@ public class ServletKit extends ServletUtil {
|
|||||||
return attributes.getRequest();
|
return attributes.getRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取客户端IP
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getClientIP() {
|
||||||
|
return getClientIP(getRequest());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.tiesheng.core.config.desensitize;
|
package com.tiesheng.util.config;
|
||||||
|
|
||||||
import cn.hutool.core.util.ClassUtil;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.ReflectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson.serializer.ValueFilter;
|
import com.alibaba.fastjson.serializer.ValueFilter;
|
||||||
import com.tiesheng.annotation.desensitize.Desensitize;
|
import com.tiesheng.annotation.desensitize.Desensitize;
|
||||||
@@ -21,7 +21,10 @@ public class DesensitizeValueFilter implements ValueFilter {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Field field = ClassUtil.getDeclaredField(object.getClass(), name);
|
Field field = ReflectUtil.getField(object.getClass(), name);
|
||||||
|
if (ObjectUtil.isEmpty(field)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
Desensitize desensitize = field.getAnnotation(Desensitize.class);
|
Desensitize desensitize = field.getAnnotation(Desensitize.class);
|
||||||
if (String.class != field.getType() || ObjectUtil.isEmpty(desensitize)) {
|
if (String.class != field.getType() || ObjectUtil.isEmpty(desensitize)) {
|
||||||
return value;
|
return value;
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
package com.tiesheng.util.config;
|
||||||
|
|
||||||
|
import cn.hutool.core.codec.Base64;
|
||||||
|
import cn.hutool.core.util.NumberUtil;
|
||||||
|
import cn.hutool.core.util.RandomUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.crypto.SecureUtil;
|
||||||
|
import cn.hutool.crypto.SmUtil;
|
||||||
|
import cn.hutool.crypto.symmetric.SM4;
|
||||||
|
import com.tiesheng.util.ServletKit;
|
||||||
|
import com.tiesheng.util.TimedCacheHelper;
|
||||||
|
import com.tiesheng.util.exception.ApiException;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hao
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@ConfigurationProperties(prefix = "tiesheng.encrypt")
|
||||||
|
public class EncryptConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加解密对象
|
||||||
|
*/
|
||||||
|
private final SM4 sm4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加密密钥
|
||||||
|
*/
|
||||||
|
private String key = "WmdUzPJXbngVNiaSsQrihg==";
|
||||||
|
private Integer saltSize = 8;
|
||||||
|
|
||||||
|
public EncryptConfig() {
|
||||||
|
sm4 = SmUtil.sm4(Base64.decode(getKey()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加密
|
||||||
|
*
|
||||||
|
* @param content
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String encrypt(String content) {
|
||||||
|
if (StrUtil.isEmpty(content)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return sm4.encryptBase64(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解密
|
||||||
|
*
|
||||||
|
* @param base64
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String decrypt(String base64) {
|
||||||
|
try {
|
||||||
|
return sm4.decryptStr(base64);
|
||||||
|
} catch (Exception ignore) {
|
||||||
|
}
|
||||||
|
return base64;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建密码
|
||||||
|
*
|
||||||
|
* @param inputPasswd
|
||||||
|
* @param salt 盐,不存将自动生成
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String passwdCreate(String inputPasswd, String salt) {
|
||||||
|
if (StrUtil.isEmpty(salt)) {
|
||||||
|
salt = RandomUtil.randomString(saltSize);
|
||||||
|
}
|
||||||
|
if (!passwdComplexity(inputPasswd)) {
|
||||||
|
throw new ApiException("需要包含数字、大小写字母、特殊符号,且长度不低于8位");
|
||||||
|
}
|
||||||
|
return encrypt(salt + SecureUtil.sha1(salt + inputPasswd));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 复杂度校验
|
||||||
|
*
|
||||||
|
* @param inputPasswd
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean passwdComplexity(String inputPasswd) {
|
||||||
|
String password = "^(?![A-Za-z0-9]+$)(?![a-z0-9\\W]+$)(?![A-Za-z\\W]+$)(?![A-Z0-9\\W]+$)[a-zA-Z0-9\\W]{8,}$";
|
||||||
|
return inputPasswd.matches(password);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密码校验
|
||||||
|
*
|
||||||
|
* @param inputPasswd
|
||||||
|
*/
|
||||||
|
public void passwdVerify(String inputPasswd, String encrypted) {
|
||||||
|
String salt = decrypt(encrypted).substring(0, saltSize);
|
||||||
|
String inputEncrypted = passwdCreate(inputPasswd, salt);
|
||||||
|
if (!StrUtil.equals(inputEncrypted, encrypted)) {
|
||||||
|
String clientIp = ServletKit.getClientIP();
|
||||||
|
int num = NumberUtil.parseInt(TimedCacheHelper.getTimedCache().get(clientIp, false));
|
||||||
|
if (num > 5) {
|
||||||
|
throw new ApiException("登录失败已达6次,请10分钟后再试");
|
||||||
|
}
|
||||||
|
TimedCacheHelper.getTimedCache().put(clientIp, String.valueOf(num + 1), 10 * 60 * 1000);
|
||||||
|
throw new ApiException("账号或密码错误");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// setter\getter
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKey(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSaltSize() {
|
||||||
|
return saltSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSaltSize(Integer saltSize) {
|
||||||
|
this.saltSize = saltSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,6 +23,7 @@ public class GlobalConfig {
|
|||||||
private String host;
|
private String host;
|
||||||
private String service;
|
private String service;
|
||||||
private String version;
|
private String version;
|
||||||
|
private String uploadDir = System.getProperty("user.dir");
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// 逻辑方法
|
// 逻辑方法
|
||||||
@@ -80,6 +81,15 @@ public class GlobalConfig {
|
|||||||
// setter\getter
|
// setter\getter
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
public String getUploadDir() {
|
||||||
|
return uploadDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUploadDir(String uploadDir) {
|
||||||
|
this.uploadDir = uploadDir;
|
||||||
|
}
|
||||||
|
|
||||||
public String getHost() {
|
public String getHost() {
|
||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,6 +129,15 @@ public class ApiResp<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否成功
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean successful() {
|
||||||
|
return code == CODE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// setter\getter
|
// setter\getter
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import cn.hutool.core.io.FileUtil;
|
|||||||
import cn.hutool.core.util.CharUtil;
|
import cn.hutool.core.util.CharUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
|
import com.tiesheng.util.config.GlobalConfig;
|
||||||
|
|
||||||
public class FileUploadPath {
|
public class FileUploadPath {
|
||||||
|
|
||||||
@@ -46,7 +48,7 @@ public class FileUploadPath {
|
|||||||
}
|
}
|
||||||
pathBean.setHttpPath(tempPath);
|
pathBean.setHttpPath(tempPath);
|
||||||
|
|
||||||
String tempAbs = String.format("%s/static%s", System.getProperty("user.dir"), tempPath);
|
String tempAbs = String.format("%s/static%s", SpringUtil.getBean(GlobalConfig.class).getUploadDir(), tempPath);
|
||||||
tempAbs = FileUtil.normalize(tempAbs);
|
tempAbs = FileUtil.normalize(tempAbs);
|
||||||
pathBean.setAbsolutePath(tempAbs);
|
pathBean.setAbsolutePath(tempAbs);
|
||||||
|
|
||||||
|
|||||||
@@ -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>0.7.0</version>
|
<version>0.8.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-web</artifactId>
|
<artifactId>springboot-web</artifactId>
|
||||||
@@ -72,11 +72,6 @@
|
|||||||
<artifactId>springboot-poi</artifactId>
|
<artifactId>springboot-poi</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
|
||||||
<artifactId>springboot-annotation</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-login</artifactId>
|
<artifactId>springboot-login</artifactId>
|
||||||
@@ -87,6 +82,11 @@
|
|||||||
<artifactId>springboot-message</artifactId>
|
<artifactId>springboot-message</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
|
<artifactId>springboot-encrypt</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package com.tiesheng.core.config.json;
|
package com.tiesheng.core.config.json;
|
||||||
|
|
||||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
||||||
import com.alibaba.fastjson.support.config.FastJsonConfig;
|
|
||||||
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
||||||
import com.tiesheng.core.config.desensitize.DesensitizeValueFilter;
|
import com.tiesheng.util.CommonUtil;
|
||||||
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
|
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@@ -26,15 +24,9 @@ public class FastJsonMessageConverter {
|
|||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public HttpMessageConverters fastJsonHttpMessageConverters() {
|
public HttpMessageConverters fastJsonHttpMessageConverters() {
|
||||||
FastJsonConfig config = new FastJsonConfig();
|
|
||||||
config.setSerializerFeatures(SerializerFeature.WriteMapNullValue,
|
|
||||||
SerializerFeature.WriteNullStringAsEmpty,
|
|
||||||
SerializerFeature.WriteEnumUsingName);
|
|
||||||
config.setDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
||||||
config.setSerializeFilters(new DesensitizeValueFilter());
|
|
||||||
|
|
||||||
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
|
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
|
||||||
fastConverter.setFastJsonConfig(config);
|
fastConverter.setFastJsonConfig(CommonUtil.fastJsonConfig());
|
||||||
fastConverter.setDefaultCharset(StandardCharsets.UTF_8);
|
fastConverter.setDefaultCharset(StandardCharsets.UTF_8);
|
||||||
|
|
||||||
List<MediaType> mediaTypes = new ArrayList<>();
|
List<MediaType> mediaTypes = new ArrayList<>();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import cn.hutool.core.map.MapUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.tiesheng.annotation.operation.OperationLog;
|
import com.tiesheng.annotation.operation.OperationLog;
|
||||||
import com.tiesheng.core.service.CoreLogService;
|
import com.tiesheng.core.service.CoreLogService;
|
||||||
|
import com.tiesheng.util.ServletKit;
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
import org.aspectj.lang.annotation.Around;
|
import org.aspectj.lang.annotation.Around;
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
@@ -13,6 +14,7 @@ import org.aspectj.lang.reflect.MethodSignature;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -35,7 +37,7 @@ public class OperationAspect {
|
|||||||
CoreLogService coreLogService;
|
CoreLogService coreLogService;
|
||||||
|
|
||||||
|
|
||||||
@Pointcut("@annotation(com.tiesheng.annotation.operation.OperationLog)")
|
@Pointcut("execution(* com..controller..*.*(..))")
|
||||||
public void methodArgs() {
|
public void methodArgs() {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -48,11 +50,24 @@ public class OperationAspect {
|
|||||||
*/
|
*/
|
||||||
@Around("methodArgs()")
|
@Around("methodArgs()")
|
||||||
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
|
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||||
|
|
||||||
|
// GET请求不处理
|
||||||
|
HttpServletRequest request = ServletKit.getRequest();
|
||||||
|
if (StrUtil.equalsIgnoreCase(request.getMethod(), "GET")) {
|
||||||
|
return joinPoint.proceed(joinPoint.getArgs());
|
||||||
|
}
|
||||||
|
|
||||||
|
String title = "", subject = "";
|
||||||
|
String insertKey = "";
|
||||||
|
|
||||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||||
Method method = signature.getMethod();
|
Method method = signature.getMethod();
|
||||||
OperationLog operationLog = method.getAnnotation(OperationLog.class);
|
OperationLog operationLog = method.getAnnotation(OperationLog.class);
|
||||||
String subject = operationLog.subject();
|
if (operationLog != null) {
|
||||||
String insertKey = operationLog.insertKey();
|
title = operationLog.title();
|
||||||
|
subject = operationLog.subject();
|
||||||
|
insertKey = operationLog.insertKey();
|
||||||
|
}
|
||||||
|
|
||||||
Object reqObj = null;
|
Object reqObj = null;
|
||||||
Map<String, Object> allParams = new HashMap<>(16);
|
Map<String, Object> allParams = new HashMap<>(16);
|
||||||
@@ -65,7 +80,6 @@ public class OperationAspect {
|
|||||||
allParams.putAll(BeanUtil.beanToMap(response));
|
allParams.putAll(BeanUtil.beanToMap(response));
|
||||||
|
|
||||||
if (!StrUtil.isEmpty(subject)) {
|
if (!StrUtil.isEmpty(subject)) {
|
||||||
|
|
||||||
// 添加、编辑关键字处理
|
// 添加、编辑关键字处理
|
||||||
if (!StrUtil.isEmpty(insertKey)) {
|
if (!StrUtil.isEmpty(insertKey)) {
|
||||||
String insertVal = MapUtil.getStr(allParams, insertKey);
|
String insertVal = MapUtil.getStr(allParams, insertKey);
|
||||||
@@ -74,9 +88,12 @@ public class OperationAspect {
|
|||||||
|
|
||||||
// 占位符处理
|
// 占位符处理
|
||||||
subject = StrUtil.format(subject, allParams);
|
subject = StrUtil.format(subject, allParams);
|
||||||
|
} else {
|
||||||
|
title = method.getName();
|
||||||
|
subject = ServletKit.getRequest().getRequestURI();
|
||||||
}
|
}
|
||||||
|
|
||||||
coreLogService.addOperationLog(operationLog.title(), subject, reqObj);
|
coreLogService.addOperationLog(title, subject, reqObj);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.tiesheng.core.pojos.dao.CoreLogLogin;
|
import com.tiesheng.core.pojos.dao.CoreLogLogin;
|
||||||
import com.tiesheng.core.pojos.dao.CoreLogMessage;
|
import com.tiesheng.core.pojos.dao.CoreLogMessage;
|
||||||
import com.tiesheng.core.pojos.dao.CoreLogOperation;
|
import com.tiesheng.core.pojos.dao.CoreLogOperation;
|
||||||
|
import com.tiesheng.core.pojos.dao.CoreLogProcess;
|
||||||
import com.tiesheng.core.pojos.dto.PageDTO;
|
import com.tiesheng.core.pojos.dto.PageDTO;
|
||||||
|
import com.tiesheng.core.pojos.vo.ProcessDetailVo;
|
||||||
import com.tiesheng.core.service.CoreLogService;
|
import com.tiesheng.core.service.CoreLogService;
|
||||||
import com.tiesheng.util.pojos.ApiResp;
|
import com.tiesheng.util.pojos.ApiResp;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -88,4 +90,36 @@ public class LogController {
|
|||||||
return ApiResp.respOK(page.getRecords(), page.getTotal());
|
return ApiResp.respOK(page.getRecords(), page.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过程日志列表
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/process/page")
|
||||||
|
public ApiResp<List<CoreLogProcess>> processPage(String type, @Valid PageDTO dto) {
|
||||||
|
|
||||||
|
QueryWrapper<CoreLogProcess> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("is_deleted", 0);
|
||||||
|
if (!StrUtil.isEmpty(type)) {
|
||||||
|
queryWrapper.eq("type", type);
|
||||||
|
}
|
||||||
|
dto.likeColumns(queryWrapper, "title");
|
||||||
|
queryWrapper.orderByDesc("create_time");
|
||||||
|
|
||||||
|
Page<CoreLogProcess> page = dto.pageObj();
|
||||||
|
coreLogService.getCoreLogProcessMapper().selectPage(page, queryWrapper);
|
||||||
|
return ApiResp.respOK(page.getRecords(), page.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过程日志详情
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/process/detail")
|
||||||
|
public ApiResp<ProcessDetailVo> processPage(String id) {
|
||||||
|
ProcessDetailVo processDetail = coreLogService.getProcessDetail(id);
|
||||||
|
return ApiResp.respOK(processDetail);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ package com.tiesheng.core.controller;
|
|||||||
import cn.hutool.captcha.LineCaptcha;
|
import cn.hutool.captcha.LineCaptcha;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import com.tiesheng.annotation.token.TokenIgnore;
|
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.pojos.dto.ImageCodeDTO;
|
||||||
import com.tiesheng.core.pojos.vo.PicVerifyVo;
|
import com.tiesheng.core.pojos.vo.PicVerifyVo;
|
||||||
import com.tiesheng.core.service.FileUploadService;
|
import com.tiesheng.core.service.FileUploadService;
|
||||||
@@ -68,8 +71,8 @@ public class ToolController {
|
|||||||
*/
|
*/
|
||||||
@TokenIgnore
|
@TokenIgnore
|
||||||
@PostMapping(value = "/file/chunk_start")
|
@PostMapping(value = "/file/chunk_start")
|
||||||
public ApiResp<String> fileChunkStart(String fileExt) {
|
public ApiResp<String> fileChunkStart(@RequestBody ChunkStartDTO dto) {
|
||||||
fileUploadService.chunkStart(fileExt);
|
fileUploadService.chunkStart(dto.getFileExt());
|
||||||
return ApiResp.respOK("");
|
return ApiResp.respOK("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,8 +84,8 @@ public class ToolController {
|
|||||||
*/
|
*/
|
||||||
@TokenIgnore
|
@TokenIgnore
|
||||||
@PostMapping("/file/chunk_check")
|
@PostMapping("/file/chunk_check")
|
||||||
public ApiResp<Boolean> fileChunkCheck(String fileMd5, Integer chunk) {
|
public ApiResp<Boolean> fileChunkCheck(@RequestBody ChunkCheckDTO dto) {
|
||||||
boolean exist = fileUploadService.chunkCheck(fileMd5, chunk);
|
boolean exist = fileUploadService.chunkCheck(dto.getFileMd5(), dto.getChunk());
|
||||||
return ApiResp.respOK(exist);
|
return ApiResp.respOK(exist);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,8 +111,8 @@ public class ToolController {
|
|||||||
*/
|
*/
|
||||||
@TokenIgnore
|
@TokenIgnore
|
||||||
@PostMapping("/file/chunk_merge")
|
@PostMapping("/file/chunk_merge")
|
||||||
public ApiResp<String> fileChunkMerge(String fileMd5, String fileExt) {
|
public ApiResp<String> fileChunkMerge(@RequestBody ChunkMergeDTO dto) {
|
||||||
String path = fileUploadService.chunkMerge(fileMd5, fileExt);
|
String path = fileUploadService.chunkMerge(dto.getFileMd5(), dto.getFileExt());
|
||||||
return ApiResp.respOK(path);
|
return ApiResp.respOK(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.tiesheng.core.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.tiesheng.core.pojos.dao.CoreLogProcess;
|
||||||
|
|
||||||
|
public interface CoreLogProcessMapper extends BaseMapper<CoreLogProcess> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
package com.tiesheng.core.pojos.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.tiesheng.core.pojos.DaoBase;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志-过程
|
||||||
|
*/
|
||||||
|
@TableName(value = "core_log_process")
|
||||||
|
public class CoreLogProcess extends DaoBase {
|
||||||
|
/**
|
||||||
|
* 标题
|
||||||
|
*/
|
||||||
|
@TableField(value = "title")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总数
|
||||||
|
*/
|
||||||
|
@TableField(value = "total")
|
||||||
|
private Integer total;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成功数
|
||||||
|
*/
|
||||||
|
@TableField(value = "success_num")
|
||||||
|
private Integer successNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 失败数
|
||||||
|
*/
|
||||||
|
@TableField(value = "fail_num")
|
||||||
|
private Integer failNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类型(import-导入,sync-同步)
|
||||||
|
*/
|
||||||
|
@TableField(value = "`type`")
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态(0-未完成,1-完成)
|
||||||
|
*/
|
||||||
|
@TableField(value = "`status`")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取标题
|
||||||
|
*
|
||||||
|
* @return title - 标题
|
||||||
|
*/
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置标题
|
||||||
|
*
|
||||||
|
* @param title 标题
|
||||||
|
*/
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取总数
|
||||||
|
*
|
||||||
|
* @return total - 总数
|
||||||
|
*/
|
||||||
|
public Integer getTotal() {
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置总数
|
||||||
|
*
|
||||||
|
* @param total 总数
|
||||||
|
*/
|
||||||
|
public void setTotal(Integer total) {
|
||||||
|
this.total = total;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取成功数
|
||||||
|
*
|
||||||
|
* @return success_num - 成功数
|
||||||
|
*/
|
||||||
|
public Integer getSuccessNum() {
|
||||||
|
return successNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置成功数
|
||||||
|
*
|
||||||
|
* @param successNum 成功数
|
||||||
|
*/
|
||||||
|
public void setSuccessNum(Integer successNum) {
|
||||||
|
this.successNum = successNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取失败数
|
||||||
|
*
|
||||||
|
* @return fail_num - 失败数
|
||||||
|
*/
|
||||||
|
public Integer getFailNum() {
|
||||||
|
return failNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置失败数
|
||||||
|
*
|
||||||
|
* @param failNum 失败数
|
||||||
|
*/
|
||||||
|
public void setFailNum(Integer failNum) {
|
||||||
|
this.failNum = failNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取类型(import-导入,sync-同步)
|
||||||
|
*
|
||||||
|
* @return type - 类型(import-导入,sync-同步)
|
||||||
|
*/
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置类型(import-导入,sync-同步)
|
||||||
|
*
|
||||||
|
* @param type 类型(import-导入,sync-同步)
|
||||||
|
*/
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取状态(0-未完成,1-完成)
|
||||||
|
*
|
||||||
|
* @return status - 状态(0-未完成,1-完成)
|
||||||
|
*/
|
||||||
|
public Integer getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置状态(0-未完成,1-完成)
|
||||||
|
*
|
||||||
|
* @param status 状态(0-未完成,1-完成)
|
||||||
|
*/
|
||||||
|
public void setStatus(Integer status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.tiesheng.core.pojos.dto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hao
|
||||||
|
*/
|
||||||
|
public class ChunkCheckDTO {
|
||||||
|
|
||||||
|
private String fileMd5;
|
||||||
|
private Integer chunk;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// setter\getter
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public String getFileMd5() {
|
||||||
|
return fileMd5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileMd5(String fileMd5) {
|
||||||
|
this.fileMd5 = fileMd5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getChunk() {
|
||||||
|
return chunk;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChunk(Integer chunk) {
|
||||||
|
this.chunk = chunk;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.tiesheng.core.pojos.dto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hao
|
||||||
|
*/
|
||||||
|
public class ChunkMergeDTO {
|
||||||
|
|
||||||
|
private String fileMd5;
|
||||||
|
private String fileExt;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// setter\getter
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public String getFileMd5() {
|
||||||
|
return fileMd5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileMd5(String fileMd5) {
|
||||||
|
this.fileMd5 = fileMd5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileExt() {
|
||||||
|
return fileExt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileExt(String fileExt) {
|
||||||
|
this.fileExt = fileExt;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.tiesheng.core.pojos.dto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hao
|
||||||
|
*/
|
||||||
|
public class ChunkStartDTO {
|
||||||
|
|
||||||
|
private String fileExt;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// setter\getter
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public String getFileExt() {
|
||||||
|
return fileExt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileExt(String fileExt) {
|
||||||
|
this.fileExt = fileExt;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package com.tiesheng.core.pojos.vo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author lgc
|
||||||
|
*/
|
||||||
|
public class ProcessDetailVo {
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
private Integer total;
|
||||||
|
|
||||||
|
private Integer successNum;
|
||||||
|
|
||||||
|
private Integer failNum;
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
public Integer getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(Integer status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getTotal() {
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotal(Integer total) {
|
||||||
|
this.total = total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSuccessNum() {
|
||||||
|
return successNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSuccessNum(Integer successNum) {
|
||||||
|
this.successNum = successNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getFailNum() {
|
||||||
|
return failNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFailNum(Integer failNum) {
|
||||||
|
this.failNum = failNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,16 +1,17 @@
|
|||||||
package com.tiesheng.core.service;
|
package com.tiesheng.core.service;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
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.json.JSONUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.tiesheng.core.mapper.CoreLogLoginMapper;
|
import com.tiesheng.core.mapper.CoreLogLoginMapper;
|
||||||
import com.tiesheng.core.mapper.CoreLogMessageMapper;
|
import com.tiesheng.core.mapper.CoreLogMessageMapper;
|
||||||
import com.tiesheng.core.mapper.CoreLogOperationMapper;
|
import com.tiesheng.core.mapper.CoreLogOperationMapper;
|
||||||
|
import com.tiesheng.core.mapper.CoreLogProcessMapper;
|
||||||
import com.tiesheng.core.pojos.RequestUserInfo;
|
import com.tiesheng.core.pojos.RequestUserInfo;
|
||||||
import com.tiesheng.core.pojos.dao.CoreLogLogin;
|
import com.tiesheng.core.pojos.dao.*;
|
||||||
import com.tiesheng.core.pojos.dao.CoreLogMessage;
|
import com.tiesheng.core.pojos.vo.ProcessDetailVo;
|
||||||
import com.tiesheng.core.pojos.dao.CoreLogOperation;
|
|
||||||
import com.tiesheng.core.pojos.dao.CorePlatformUnique;
|
|
||||||
import com.tiesheng.login.config.token.TsTokenConfig;
|
import com.tiesheng.login.config.token.TsTokenConfig;
|
||||||
import com.tiesheng.login.config.token.bean.TokenBean;
|
import com.tiesheng.login.config.token.bean.TokenBean;
|
||||||
import com.tiesheng.message.pojos.MessageReqResp;
|
import com.tiesheng.message.pojos.MessageReqResp;
|
||||||
@@ -36,6 +37,8 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
|
|||||||
CoreLogMessageMapper coreLogMessageMapper;
|
CoreLogMessageMapper coreLogMessageMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
Ip2regionConfig ip2regionConfig;
|
Ip2regionConfig ip2regionConfig;
|
||||||
|
@Autowired
|
||||||
|
CoreLogProcessMapper coreLogProcessMapper;
|
||||||
|
|
||||||
public CoreLogLoginMapper getLogLoginMapper() {
|
public CoreLogLoginMapper getLogLoginMapper() {
|
||||||
return coreLogLoginMapper;
|
return coreLogLoginMapper;
|
||||||
@@ -45,17 +48,68 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
|
|||||||
return coreLogMessageMapper;
|
return coreLogMessageMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
public CoreLogProcessMapper getCoreLogProcessMapper() {
|
||||||
|
return coreLogProcessMapper;
|
||||||
|
}
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// 操作日志
|
// 操作日志
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加空的过程 返回id 用于更新
|
||||||
|
*/
|
||||||
|
public String addProcess() {
|
||||||
|
CoreLogProcess coreLogProcess = new CoreLogProcess();
|
||||||
|
coreLogProcessMapper.insert(coreLogProcess);
|
||||||
|
return coreLogProcess.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新过程
|
||||||
|
*
|
||||||
|
* @param id 过程id
|
||||||
|
* @param title 过程标题/说明
|
||||||
|
* @param total 总数
|
||||||
|
* @param successNum 成功数
|
||||||
|
* @param failNum 失败数
|
||||||
|
* @param type 类型(import-导出,sync-同步)
|
||||||
|
* @param status 状态(0-未完成,1-完成)
|
||||||
|
*/
|
||||||
|
public void upProcess(String id, String title, Integer total, Integer successNum, Integer failNum, String type, Integer status) {
|
||||||
|
CoreLogProcess coreLogProcess = new CoreLogProcess();
|
||||||
|
coreLogProcess.setId(id);
|
||||||
|
coreLogProcess.setTitle(title);
|
||||||
|
coreLogProcess.setTotal(total);
|
||||||
|
coreLogProcess.setSuccessNum(successNum);
|
||||||
|
coreLogProcess.setFailNum(failNum);
|
||||||
|
coreLogProcess.setType(type);
|
||||||
|
coreLogProcess.setStatus(status);
|
||||||
|
coreLogProcessMapper.updateById(coreLogProcess);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id 获取过程详情
|
||||||
|
*/
|
||||||
|
public ProcessDetailVo getProcessDetail(String id) {
|
||||||
|
QueryWrapper<CoreLogProcess> wrapper = new QueryWrapper<>();
|
||||||
|
wrapper.eq("id", id);
|
||||||
|
CoreLogProcess coreLogProcess = coreLogProcessMapper.selectOne(wrapper);
|
||||||
|
return BeanUtil.copyProperties(coreLogProcess, ProcessDetailVo.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加操作日志
|
* 添加操作日志
|
||||||
*/
|
*/
|
||||||
public void addOperationLog(String title, String subject, Object params) {
|
public void addOperationLog(String title, String subject, Object params) {
|
||||||
|
TokenBean tokenBean = TsTokenConfig.getWithoutThr();
|
||||||
|
if (tokenBean == null || StrUtil.isEmpty(tokenBean.getId())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RequestUserInfo requestUserInfo = tieshengWebConfigurer.getCurrentUserName(tokenBean);
|
||||||
CoreLogOperation operation = new CoreLogOperation();
|
CoreLogOperation operation = new CoreLogOperation();
|
||||||
RequestUserInfo requestUserInfo = tieshengWebConfigurer.getCurrentUserName(TsTokenConfig.get());
|
|
||||||
operation.setUserId(requestUserInfo.getId());
|
operation.setUserId(requestUserInfo.getId());
|
||||||
operation.setUserName(requestUserInfo.getName());
|
operation.setUserName(requestUserInfo.getName());
|
||||||
operation.setTitle(title);
|
operation.setTitle(title);
|
||||||
@@ -82,7 +136,7 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
|
|||||||
String ip = ServletUtil.getClientIP(request);
|
String ip = ServletUtil.getClientIP(request);
|
||||||
|
|
||||||
CoreLogLogin login = new CoreLogLogin();
|
CoreLogLogin login = new CoreLogLogin();
|
||||||
login.setUserId(platformUnique.getUserId());
|
login.setUserId(tokenBean.getId());
|
||||||
login.setPlatform(platformUnique.getPlatform());
|
login.setPlatform(platformUnique.getPlatform());
|
||||||
|
|
||||||
RequestUserInfo requestUserInfo = tieshengWebConfigurer.getCurrentUserName(tokenBean);
|
RequestUserInfo requestUserInfo = tieshengWebConfigurer.getCurrentUserName(tokenBean);
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
Navicat Premium Data Transfer
|
||||||
|
|
||||||
|
Source Server : 47.96.30.85
|
||||||
|
Source Server Type : MySQL
|
||||||
|
Source Server Version : 50730
|
||||||
|
Source Host : localhost:3306
|
||||||
|
Source Schema : com_tiesheng_web
|
||||||
|
|
||||||
|
Target Server Type : MySQL
|
||||||
|
Target Server Version : 50730
|
||||||
|
File Encoding : 65001
|
||||||
|
|
||||||
|
Date: 22/03/2023 10:39:06
|
||||||
|
*/
|
||||||
|
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
SET FOREIGN_KEY_CHECKS = 0;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for core_log_process
|
||||||
|
-- ----------------------------
|
||||||
|
CREATE TABLE `core_log_process` (
|
||||||
|
`id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||||
|
`create_time` datetime NOT NULL,
|
||||||
|
`update_time` datetime NOT NULL,
|
||||||
|
`is_deleted` int(6) NOT NULL DEFAULT 0,
|
||||||
|
`title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '标题',
|
||||||
|
`total` int(11) NOT NULL DEFAULT 0 COMMENT '总数',
|
||||||
|
`success_num` int(11) NOT NULL DEFAULT 0 COMMENT '成功数',
|
||||||
|
`fail_num` int(11) NOT NULL DEFAULT 0 COMMENT '失败数',
|
||||||
|
`type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'import' COMMENT '类型(import-导入,sync-同步)',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '日志-过程' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Records of core_log_process
|
||||||
|
-- ----------------------------
|
||||||
|
|
||||||
|
SET FOREIGN_KEY_CHECKS = 1;
|
||||||
|
|
||||||
|
ALTER TABLE core_log_process ADD status int(6) default 0 COMMENT '状态(0-未完成,1-已完成)';
|
||||||
|
commit;
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.tiesheng.core.mapper.CoreLogProcessMapper">
|
||||||
|
<resultMap id="BaseResultMap" type="com.tiesheng.core.pojos.dao.CoreLogProcess">
|
||||||
|
<!--@mbg.generated-->
|
||||||
|
<!--@Table core_log_process-->
|
||||||
|
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||||
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||||
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||||
|
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted" />
|
||||||
|
<result column="title" jdbcType="VARCHAR" property="title" />
|
||||||
|
<result column="total" jdbcType="INTEGER" property="total" />
|
||||||
|
<result column="success_num" jdbcType="INTEGER" property="successNum" />
|
||||||
|
<result column="fail_num" jdbcType="INTEGER" property="failNum" />
|
||||||
|
<result column="type" jdbcType="VARCHAR" property="type" />
|
||||||
|
<result column="status" jdbcType="INTEGER" property="status" />
|
||||||
|
</resultMap>
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
<!--@mbg.generated-->
|
||||||
|
id, create_time, update_time, is_deleted, title, total, success_num, fail_num, `type`,
|
||||||
|
`status`
|
||||||
|
</sql>
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user