Compare commits
34 Commits
2.0.0.rc42
...
2.0.7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb816d0ff0 | ||
|
|
0470ca0b9a | ||
|
|
d38077b0f8 | ||
|
|
2621c6dedc | ||
|
|
456a95778c | ||
|
|
fd0976a30c | ||
|
|
e519781207 | ||
|
|
e602f4c658 | ||
|
|
a816acaddb | ||
|
|
278429157a | ||
|
|
143b100819 | ||
|
|
d0cd9aed0b | ||
|
|
3080d8a936 | ||
|
|
3f951dfe47 | ||
|
|
9c66dafe6b | ||
|
|
d6ed2b8037 | ||
|
|
02c2ccc0ff | ||
|
|
f27d8d1658 | ||
|
|
ba9d0da33f | ||
|
|
4690fa9f88 | ||
|
|
a9f218de89 | ||
|
|
55324199cd | ||
|
|
0b32559630 | ||
|
|
01cc4f16ad | ||
|
|
2b70c8121d | ||
|
|
fd30c5cf36 | ||
|
|
0310bd4a15 | ||
|
|
80ec6d2e3d | ||
|
|
d96f17b847 | ||
|
|
7648eef981 | ||
|
|
79087f33e4 | ||
|
|
d0289d38b3 | ||
|
|
90029faa53 | ||
|
|
ecb5aa1b29 |
@@ -1,3 +1,12 @@
|
|||||||
|
## 2.0.0.rc46
|
||||||
|
|
||||||
|
现在导入导出都接入底层流程,无需新增接口,只需要实现接口即可。
|
||||||
|
|
||||||
|
- 过程日志不再和操作日志同时存在
|
||||||
|
- 过程日志新增params参数
|
||||||
|
- 通过实现*TsImportHandler*接口编写导入逻辑
|
||||||
|
- 通过实现*TsExportHandler*接口编写导出逻辑
|
||||||
|
|
||||||
## 2.0.0.rc4
|
## 2.0.0.rc4
|
||||||
|
|
||||||
- perf:TsTokenConfig不在提供静态方法
|
- perf:TsTokenConfig不在提供静态方法
|
||||||
|
|||||||
34
pom.xml
34
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>2.0.0.rc42</version>
|
<version>2.0.7</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>springboot-parent</name>
|
<name>springboot-parent</name>
|
||||||
<description>杭州铁晟科技有限公司基础依赖</description>
|
<description>杭州铁晟科技有限公司基础依赖</description>
|
||||||
@@ -23,10 +23,8 @@
|
|||||||
<module>springboot-login</module>
|
<module>springboot-login</module>
|
||||||
<module>springboot-web</module>
|
<module>springboot-web</module>
|
||||||
<module>springboot-util</module>
|
<module>springboot-util</module>
|
||||||
<module>springboot-poi</module>
|
|
||||||
<module>springboot-platform</module>
|
<module>springboot-platform</module>
|
||||||
<module>springboot-message</module>
|
<module>springboot-message</module>
|
||||||
<module>springboot-encrypt</module>
|
|
||||||
<module>springboot-annotation</module>
|
<module>springboot-annotation</module>
|
||||||
<module>springboot-role</module>
|
<module>springboot-role</module>
|
||||||
</modules>
|
</modules>
|
||||||
@@ -35,6 +33,8 @@
|
|||||||
<maven.compiler.source>8</maven.compiler.source>
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
<maven.compiler.target>8</maven.compiler.target>
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
|
||||||
|
<hutool.version>5.8.31</hutool.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<developers>
|
<developers>
|
||||||
@@ -58,61 +58,49 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-database</artifactId>
|
<artifactId>springboot-database</artifactId>
|
||||||
<version>2.0.0.rc42</version>
|
<version>2.0.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>2.0.0.rc42</version>
|
<version>2.0.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>2.0.0.rc42</version>
|
<version>2.0.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>2.0.0.rc42</version>
|
<version>2.0.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>2.0.0.rc42</version>
|
<version>2.0.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>2.0.0.rc42</version>
|
<version>2.0.7</version>
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
|
||||||
<artifactId>springboot-encrypt</artifactId>
|
|
||||||
<version>2.0.0.rc42</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-role</artifactId>
|
<artifactId>springboot-role</artifactId>
|
||||||
<version>2.0.0.rc42</version>
|
<version>2.0.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>2.0.0.rc42</version>
|
<version>2.0.7</version>
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
|
||||||
<artifactId>springboot-poi</artifactId>
|
|
||||||
<version>2.0.0.rc42</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
31
qodana.yaml
Normal file
31
qodana.yaml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#-------------------------------------------------------------------------------#
|
||||||
|
# Qodana analysis is configured by qodana.yaml file #
|
||||||
|
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
|
||||||
|
#-------------------------------------------------------------------------------#
|
||||||
|
version: "1.0"
|
||||||
|
|
||||||
|
#Specify inspection profile for code analysis
|
||||||
|
profile:
|
||||||
|
name: qodana.starter
|
||||||
|
|
||||||
|
#Enable inspections
|
||||||
|
#include:
|
||||||
|
# - name: <SomeEnabledInspectionId>
|
||||||
|
|
||||||
|
#Disable inspections
|
||||||
|
#exclude:
|
||||||
|
# - name: <SomeDisabledInspectionId>
|
||||||
|
# paths:
|
||||||
|
# - <path/where/not/run/inspection>
|
||||||
|
|
||||||
|
projectJDK: 17 #(Applied in CI/CD pipeline)
|
||||||
|
|
||||||
|
#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
|
||||||
|
#bootstrap: sh ./prepare-qodana.sh
|
||||||
|
|
||||||
|
#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
|
||||||
|
#plugins:
|
||||||
|
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)
|
||||||
|
|
||||||
|
#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
|
||||||
|
linter: jetbrains/qodana-jvm:latest
|
||||||
@@ -6,11 +6,11 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>2.0.0.rc42</version>
|
<version>2.0.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-ademo</artifactId>
|
<artifactId>springboot-ademo</artifactId>
|
||||||
<version>2.0.0.rc42</version>
|
<version>2.0.7</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
|||||||
@@ -16,16 +16,11 @@ import java.util.Objects;
|
|||||||
@Component
|
@Component
|
||||||
public class DemoWebConfigurer implements TieshengWebConfigurer, TsLoginConfigurer {
|
public class DemoWebConfigurer implements TieshengWebConfigurer, TsLoginConfigurer {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
GlobalConfig globalConfig;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RequestUserInfo getCurrentUserName(TokenBean tokenBean) {
|
public RequestUserInfo getCurrentUserName(TokenBean tokenBean) {
|
||||||
RequestUserInfo info = new RequestUserInfo();
|
RequestUserInfo info = new RequestUserInfo();
|
||||||
info.setId(tokenBean.getId());
|
info.setId(tokenBean.getId());
|
||||||
info.setName(tokenBean.getExtra());
|
info.setName(tokenBean.getExtra());
|
||||||
info.setData(info);
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package com.tiesheng.demo.config;
|
package com.tiesheng.demo.config;
|
||||||
|
|
||||||
|
|
||||||
import com.tiesheng.web.service.CoreConfigService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
@@ -13,9 +11,6 @@ import javax.annotation.PostConstruct;
|
|||||||
@Component
|
@Component
|
||||||
public class TestJobConfig {
|
public class TestJobConfig {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
CoreConfigService coreConfigService;
|
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,35 +1,41 @@
|
|||||||
package com.tiesheng.demo.controller;
|
package com.tiesheng.demo.controller;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.date.TimeInterval;
|
import cn.hutool.core.date.TimeInterval;
|
||||||
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.log.LogFactory;
|
import cn.hutool.log.LogFactory;
|
||||||
import com.alibaba.excel.EasyExcel;
|
import com.alibaba.excel.EasyExcel;
|
||||||
import com.alibaba.excel.context.AnalysisContext;
|
import com.alibaba.excel.context.AnalysisContext;
|
||||||
import com.alibaba.excel.read.listener.ReadListener;
|
import com.alibaba.excel.read.listener.ReadListener;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.tiesheng.annotation.role.RoleAuthority;
|
import com.tiesheng.annotation.role.RoleAuthority;
|
||||||
import com.tiesheng.annotation.token.TokenIgnore;
|
import com.tiesheng.annotation.token.TokenIgnore;
|
||||||
import com.tiesheng.database.config.DbBackupConfig;
|
import com.tiesheng.database.config.DbBackupConfig;
|
||||||
import com.tiesheng.demo.pojos.JsonTest;
|
import com.tiesheng.demo.pojos.JsonTest;
|
||||||
import com.tiesheng.demo.pojos.PoiBean;
|
import com.tiesheng.demo.pojos.PoiBean;
|
||||||
import com.tiesheng.demo.pojos.TestFile;
|
|
||||||
import com.tiesheng.platform.config.ding.PlatformDingConfig;
|
import com.tiesheng.platform.config.ding.PlatformDingConfig;
|
||||||
import com.tiesheng.platform.config.ding.bean.DingUserInfo;
|
import com.tiesheng.platform.config.ding.bean.DingUserInfo;
|
||||||
import com.tiesheng.util.config.EncryptConfig;
|
import com.tiesheng.util.config.EncryptConfig;
|
||||||
import com.tiesheng.util.config.GlobalConfig;
|
import com.tiesheng.util.config.GlobalConfig;
|
||||||
import com.tiesheng.util.config.Ip2regionConfig;
|
import com.tiesheng.util.config.Ip2regionConfig;
|
||||||
import com.tiesheng.util.config.TsTokenConfig;
|
import com.tiesheng.util.config.TsTokenConfig;
|
||||||
|
import com.tiesheng.util.exception.ApiException;
|
||||||
import com.tiesheng.util.pojos.ApiResp;
|
import com.tiesheng.util.pojos.ApiResp;
|
||||||
import com.tiesheng.util.pojos.FileUploadPath;
|
import com.tiesheng.util.pojos.FileUploadPath;
|
||||||
import com.tiesheng.util.service.TsCacheService;
|
import com.tiesheng.util.service.TsCacheService;
|
||||||
|
import com.tiesheng.util.service.http.OkHttpUtil;
|
||||||
import com.tiesheng.web.service.CoreLogService;
|
import com.tiesheng.web.service.CoreLogService;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,7 +73,9 @@ public class TestController {
|
|||||||
@RequestMapping("/redirect")
|
@RequestMapping("/redirect")
|
||||||
@TokenIgnore
|
@TokenIgnore
|
||||||
@RoleAuthority("redirect")
|
@RoleAuthority("redirect")
|
||||||
public ApiResp<JsonTest> redirect(@RequestBody JsonTest dto, HttpServletResponse response) {
|
public ApiResp<JsonTest> redirect(HttpServletResponse response) {
|
||||||
|
|
||||||
|
encryptConfig.passwdCreate("111111@Zz", "");
|
||||||
|
|
||||||
JsonTest jsonTest = new JsonTest();
|
JsonTest jsonTest = new JsonTest();
|
||||||
jsonTest.setNow(DateUtil.date());
|
jsonTest.setNow(DateUtil.date());
|
||||||
@@ -76,7 +84,8 @@ public class TestController {
|
|||||||
String jsonString = JSON.toJSONString(jsonTest);
|
String jsonString = JSON.toJSONString(jsonTest);
|
||||||
LogFactory.get().info(jsonString);
|
LogFactory.get().info(jsonString);
|
||||||
|
|
||||||
LogFactory.get().info(JSON.toJSONString(dto));
|
String s = OkHttpUtil.get("http://toolbox.tieshengkeji.com/test/login/23232/3232");
|
||||||
|
LogFactory.get().info(s);
|
||||||
|
|
||||||
// ArrayList<String> strings = CollUtil.newArrayList("11111", "22222");
|
// ArrayList<String> strings = CollUtil.newArrayList("11111", "22222");
|
||||||
// coreLogService.addProcess("fdfd", strings, new ProcessImportConsumer<String>() {
|
// coreLogService.addProcess("fdfd", strings, new ProcessImportConsumer<String>() {
|
||||||
@@ -154,16 +163,6 @@ public class TestController {
|
|||||||
return ApiResp.respOK(search);
|
return ApiResp.respOK(search);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("desensitize")
|
|
||||||
@TokenIgnore
|
|
||||||
public ApiResp<List<TestFile>> desensitize() {
|
|
||||||
TestFile file = new TestFile("11111");
|
|
||||||
file.setTest("111111");
|
|
||||||
TestFile file1 = new TestFile("22222");
|
|
||||||
file1.setTest("22222");
|
|
||||||
return ApiResp.respOK(CollUtil.newArrayList(file, file1));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping("passwd")
|
@RequestMapping("passwd")
|
||||||
@TokenIgnore
|
@TokenIgnore
|
||||||
@@ -201,4 +200,33 @@ public class TestController {
|
|||||||
return ApiResp.respOK("");
|
return ApiResp.respOK("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("getwxacode")
|
||||||
|
@TokenIgnore
|
||||||
|
public ApiResp<String> getwxacode() {
|
||||||
|
String id = "test_1111111";
|
||||||
|
FileUploadPath path = FileUploadPath.random("png");
|
||||||
|
JSONObject paramJson = new JSONObject();
|
||||||
|
paramJson.put("page", "pages/login/index");
|
||||||
|
paramJson.put("scene", "no=" + id);
|
||||||
|
paramJson.put("env_version", "develop");
|
||||||
|
paramJson.put("width", 430);
|
||||||
|
paramJson.put("is_hyaline", false);
|
||||||
|
paramJson.put("auto_color", false);
|
||||||
|
FileUploadPath file = FileUploadPath.file(id + ".png");
|
||||||
|
try {
|
||||||
|
Request request = OkHttpUtil.ofPost("https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" +
|
||||||
|
"83_7xqG36kdgwuf8zzWLY3jtz7bg4ucziN-0oxbE0X9zBzwbjZ4S4Ss2RM9uHeSIcRp2K-wEp6MLzWhqo2AXj0Jpzd6IiJdUsRxqdHPvEWqAdOgt83vzZwdDf7tZBkGNGeAFASZS",
|
||||||
|
paramJson);
|
||||||
|
Response execute1 = OkHttpUtil.ofHttpClient().build().newCall(request).execute();
|
||||||
|
if (execute1.body() != null) {
|
||||||
|
FileUtil.writeFromStream(execute1.body().byteStream(), file.getAbsolutePath());
|
||||||
|
execute1.close();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ApiException("每分钟最多生成5000个二维码,请稍后再试!");
|
||||||
|
}
|
||||||
|
return ApiResp.respOK(path.getHttpPath());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
package com.tiesheng.demo.pojos;
|
|
||||||
|
|
||||||
import com.tiesheng.poi.pojos.PoiWriteBase;
|
|
||||||
|
|
||||||
|
|
||||||
public class TestFile extends TestParent implements PoiWriteBase {
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
public TestFile(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package com.tiesheng.demo.pojos;
|
|
||||||
|
|
||||||
import com.tiesheng.poi.pojos.PoiWriteBase;
|
|
||||||
|
|
||||||
|
|
||||||
public class TestParent implements PoiWriteBase {
|
|
||||||
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.tiesheng.demo.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.tiesheng.util.pojos.TokenBean;
|
||||||
|
import com.tiesheng.web.pojos.imex.ImportDealDTO;
|
||||||
|
import com.tiesheng.web.service.imex.TsImportHandler;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class UserImportHandler implements TsImportHandler<String> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> ready(ImportDealDTO dto, TokenBean token) {
|
||||||
|
return CollUtil.newArrayList("11111");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTemplateUrl() {
|
||||||
|
return "/template/xsxxzx_teacher_leader.xlsx";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAction() {
|
||||||
|
return "user_import";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int batchHandler(List<String> list) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getResultFile() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>2.0.0.rc42</version>
|
<version>2.0.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-annotation</artifactId>
|
<artifactId>springboot-annotation</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>2.0.0.rc42</version>
|
<version>2.0.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-database</artifactId>
|
<artifactId>springboot-database</artifactId>
|
||||||
|
|||||||
BIN
springboot-encrypt/.DS_Store
vendored
BIN
springboot-encrypt/.DS_Store
vendored
Binary file not shown.
@@ -1,40 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
|
||||||
<artifactId>springboot-parent</artifactId>
|
|
||||||
<version>2.0.0.rc42</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>springboot-encrypt</artifactId>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
|
||||||
<maven.compiler.target>8</maven.compiler.target>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
|
||||||
<artifactId>springboot-util</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
|
||||||
<artifactId>springboot-annotation</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package com.tiesheng.encrypt;
|
|
||||||
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
|
|
||||||
@ComponentScan({
|
|
||||||
"com.tiesheng.encrypt.**.*",
|
|
||||||
})
|
|
||||||
public class EncryptAutoConfigurer {
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>2.0.0.rc42</version>
|
<version>2.0.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-login</artifactId>
|
<artifactId>springboot-login</artifactId>
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class LoginController {
|
|||||||
@OperationIgnore
|
@OperationIgnore
|
||||||
public void uniqueIndex(UniqueIndexDTO dto, HttpServletResponse response) {
|
public void uniqueIndex(UniqueIndexDTO dto, HttpServletResponse response) {
|
||||||
if (tsTokenConfig.isValidLoginSign() && !dto.validSign()) {
|
if (tsTokenConfig.isValidLoginSign() && !dto.validSign()) {
|
||||||
corePlatformUniqueService.onSignError(response);
|
corePlatformUniqueService.redirect(null, dto.getTo(), dto.getExtra(), response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ public class LoginController {
|
|||||||
public ApiResp<String> uniqueIndex(@RequestBody UniqueIndexDTO dto) {
|
public ApiResp<String> uniqueIndex(@RequestBody UniqueIndexDTO dto) {
|
||||||
TokenBean tokenBean = corePlatformUniqueService.login(new DoLoginInfo("web_unique_index",
|
TokenBean tokenBean = corePlatformUniqueService.login(new DoLoginInfo("web_unique_index",
|
||||||
dto.getNo(), dto.getPlatform(), dto.getInfo()));
|
dto.getNo(), dto.getPlatform(), dto.getInfo()));
|
||||||
if (tokenBean == null || StrUtil.isEmpty(tokenBean.getId())) {
|
if (!TsTokenConfig.validToken(tokenBean)) {
|
||||||
throw new ApiException("登录失败");
|
throw new ApiException("登录失败");
|
||||||
}
|
}
|
||||||
return ApiResp.respOK(tokenBean.toToken());
|
return ApiResp.respOK(tokenBean.toToken());
|
||||||
@@ -219,7 +219,7 @@ public class LoginController {
|
|||||||
|
|
||||||
WxminiLoginVo loginVo = new WxminiLoginVo();
|
WxminiLoginVo loginVo = new WxminiLoginVo();
|
||||||
loginVo.setOpenid(openid);
|
loginVo.setOpenid(openid);
|
||||||
if (tokenBean != null) {
|
if (TsTokenConfig.validToken(tokenBean)) {
|
||||||
loginVo.setToken(tokenBean.toToken());
|
loginVo.setToken(tokenBean.toToken());
|
||||||
}
|
}
|
||||||
return ApiResp.respOK(loginVo);
|
return ApiResp.respOK(loginVo);
|
||||||
|
|||||||
@@ -2,6 +2,17 @@ package com.tiesheng.login.mapper;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.tiesheng.login.pojos.dao.CoreLogLogin;
|
import com.tiesheng.login.pojos.dao.CoreLogLogin;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
public interface CoreLogLoginMapper extends BaseMapper<CoreLogLogin> {
|
public interface CoreLogLoginMapper extends BaseMapper<CoreLogLogin> {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取登录失败的次数
|
||||||
|
*
|
||||||
|
* @param ip
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int getLoginErrorTimes(@Param("ip") String ip);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
package com.tiesheng.login.pojos;
|
package com.tiesheng.login.pojos;
|
||||||
|
|
||||||
|
import com.tiesheng.util.ServletKit;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
public class DoLoginInfo {
|
public class DoLoginInfo {
|
||||||
|
|
||||||
private String appId;
|
private String appId;
|
||||||
@@ -7,12 +11,16 @@ public class DoLoginInfo {
|
|||||||
private String platform;
|
private String platform;
|
||||||
private String info;
|
private String info;
|
||||||
private String extra;
|
private String extra;
|
||||||
|
private String loginIp;
|
||||||
|
|
||||||
public DoLoginInfo(String appId, String unique, String platform, String info) {
|
public DoLoginInfo(String appId, String unique, String platform, String info) {
|
||||||
this.appId = appId;
|
this.appId = appId;
|
||||||
this.unique = unique;
|
this.unique = unique;
|
||||||
this.platform = platform;
|
this.platform = platform;
|
||||||
this.info = info;
|
this.info = info;
|
||||||
|
|
||||||
|
// 设置IP
|
||||||
|
this.loginIp = ServletKit.getClientIP();
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
@@ -58,4 +66,12 @@ public class DoLoginInfo {
|
|||||||
public void setExtra(String extra) {
|
public void setExtra(String extra) {
|
||||||
this.extra = extra;
|
this.extra = extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLoginIp() {
|
||||||
|
return loginIp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLoginIp(String loginIp) {
|
||||||
|
this.loginIp = loginIp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,13 +16,13 @@ public class CoreLogLogin extends DaoBase {
|
|||||||
private String userId;
|
private String userId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户id
|
* 用户姓名
|
||||||
*/
|
*/
|
||||||
@TableField(value = "user_name")
|
@TableField(value = "user_name")
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ip
|
* 登录方式
|
||||||
*/
|
*/
|
||||||
@TableField(value = "platform")
|
@TableField(value = "platform")
|
||||||
private String platform;
|
private String platform;
|
||||||
@@ -39,6 +39,18 @@ public class CoreLogLogin extends DaoBase {
|
|||||||
@TableField(value = "address")
|
@TableField(value = "address")
|
||||||
private String address;
|
private String address;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录结果,0否,1是
|
||||||
|
*/
|
||||||
|
@TableField(value = "`result`")
|
||||||
|
private Integer result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求参数
|
||||||
|
*/
|
||||||
|
@TableField(value = "params")
|
||||||
|
private String params;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户id
|
* 获取用户id
|
||||||
*
|
*
|
||||||
@@ -57,18 +69,38 @@ public class CoreLogLogin extends DaoBase {
|
|||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户姓名
|
||||||
|
*
|
||||||
|
* @return user_name - 用户姓名
|
||||||
|
*/
|
||||||
public String getUserName() {
|
public String getUserName() {
|
||||||
return userName;
|
return userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置用户姓名
|
||||||
|
*
|
||||||
|
* @param userName 用户姓名
|
||||||
|
*/
|
||||||
public void setUserName(String userName) {
|
public void setUserName(String userName) {
|
||||||
this.userName = userName;
|
this.userName = userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取登录方式
|
||||||
|
*
|
||||||
|
* @return platform - 登录方式
|
||||||
|
*/
|
||||||
public String getPlatform() {
|
public String getPlatform() {
|
||||||
return platform;
|
return platform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置登录方式
|
||||||
|
*
|
||||||
|
* @param platform 登录方式
|
||||||
|
*/
|
||||||
public void setPlatform(String platform) {
|
public void setPlatform(String platform) {
|
||||||
this.platform = platform;
|
this.platform = platform;
|
||||||
}
|
}
|
||||||
@@ -108,4 +140,40 @@ public class CoreLogLogin extends DaoBase {
|
|||||||
public void setAddress(String address) {
|
public void setAddress(String address) {
|
||||||
this.address = address;
|
this.address = address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取登录结果,0否,1是
|
||||||
|
*
|
||||||
|
* @return result - 登录结果,0否,1是
|
||||||
|
*/
|
||||||
|
public Integer getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置登录结果,0否,1是
|
||||||
|
*
|
||||||
|
* @param result 登录结果,0否,1是
|
||||||
|
*/
|
||||||
|
public void setResult(Integer result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取请求参数
|
||||||
|
*
|
||||||
|
* @return params - 请求参数
|
||||||
|
*/
|
||||||
|
public String getParams() {
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置请求参数
|
||||||
|
*
|
||||||
|
* @param params 请求参数
|
||||||
|
*/
|
||||||
|
public void setParams(String params) {
|
||||||
|
this.params = params;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
package com.tiesheng.login.service;
|
package com.tiesheng.login.service;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.tiesheng.login.mapper.CoreLogLoginMapper;
|
import com.tiesheng.login.mapper.CoreLogLoginMapper;
|
||||||
import com.tiesheng.login.mapper.CorePlatformUniqueMapper;
|
import com.tiesheng.login.mapper.CorePlatformUniqueMapper;
|
||||||
import com.tiesheng.login.pojos.DoLoginInfo;
|
import com.tiesheng.login.pojos.DoLoginInfo;
|
||||||
import com.tiesheng.login.pojos.RequestUserInfo;
|
import com.tiesheng.login.pojos.RequestUserInfo;
|
||||||
import com.tiesheng.login.pojos.dao.CoreLogLogin;
|
import com.tiesheng.login.pojos.dao.CoreLogLogin;
|
||||||
import com.tiesheng.login.pojos.dao.CorePlatformUnique;
|
import com.tiesheng.login.pojos.dao.CorePlatformUnique;
|
||||||
import com.tiesheng.util.ServletKit;
|
|
||||||
import com.tiesheng.util.config.Ip2regionConfig;
|
import com.tiesheng.util.config.Ip2regionConfig;
|
||||||
|
import com.tiesheng.util.config.TsTokenConfig;
|
||||||
|
import com.tiesheng.util.exception.ApiException;
|
||||||
import com.tiesheng.util.pojos.TokenBean;
|
import com.tiesheng.util.pojos.TokenBean;
|
||||||
import com.tiesheng.util.service.TsCacheService;
|
import com.tiesheng.util.service.TsCacheService;
|
||||||
import com.tiesheng.util.service.TsServiceBase;
|
import com.tiesheng.util.service.TsServiceBase;
|
||||||
import com.tiesheng.util.service.role.TsAuthorityHandler;
|
import com.tiesheng.util.service.role.TsAuthorityHandler;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@@ -35,9 +35,19 @@ public class CorePlatformUniqueService extends TsServiceBase<CorePlatformUniqueM
|
|||||||
TsLoginConfigurer tsLoginConfigurer;
|
TsLoginConfigurer tsLoginConfigurer;
|
||||||
|
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
/**
|
||||||
|
* 登录操作
|
||||||
|
*
|
||||||
|
* @param loginInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public TokenBean login(DoLoginInfo loginInfo) {
|
public TokenBean login(DoLoginInfo loginInfo) {
|
||||||
|
|
||||||
|
int loginErrorTimes = coreLogLoginMapper.getLoginErrorTimes(loginInfo.getLoginIp());
|
||||||
|
if (loginErrorTimes > 4) {
|
||||||
|
throw new ApiException("登录失败已达5次,请10分钟后再试");
|
||||||
|
}
|
||||||
|
|
||||||
CorePlatformUnique platformUnique = getOneByColumn("unique_id", loginInfo.getUnique());
|
CorePlatformUnique platformUnique = getOneByColumn("unique_id", loginInfo.getUnique());
|
||||||
if (platformUnique == null) {
|
if (platformUnique == null) {
|
||||||
platformUnique = new CorePlatformUnique();
|
platformUnique = new CorePlatformUnique();
|
||||||
@@ -48,24 +58,32 @@ public class CorePlatformUniqueService extends TsServiceBase<CorePlatformUniqueM
|
|||||||
platformUnique.setInfo(loginInfo.getInfo());
|
platformUnique.setInfo(loginInfo.getInfo());
|
||||||
saveOrUpdate(platformUnique);
|
saveOrUpdate(platformUnique);
|
||||||
|
|
||||||
String oldUserId = platformUnique.getUserId();
|
TokenBean tokenBean = null;
|
||||||
TokenBean tokenBean = tsLoginConfigurer.login(platformUnique);
|
String errorMsg = null;
|
||||||
if (tokenBean != null) {
|
try {
|
||||||
|
tokenBean = tsLoginConfigurer.login(platformUnique);
|
||||||
|
} catch (Exception e) {
|
||||||
|
errorMsg = e.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TsTokenConfig.validToken(tokenBean)) {
|
||||||
|
|
||||||
// 清除授权信息
|
// 清除授权信息
|
||||||
TsCacheService.of().remove(StrUtil.format(TsAuthorityHandler.CACHE_HAS_AUTHORITY,
|
TsCacheService.of().remove(StrUtil.format(TsAuthorityHandler.CACHE_AUTHORITY,
|
||||||
tokenBean.getRoleId(), tokenBean.getId()));
|
tokenBean.getRoleId(), tokenBean.getId()));
|
||||||
|
|
||||||
// 添加登录日志
|
|
||||||
addLoginLog(platformUnique, tokenBean);
|
|
||||||
|
|
||||||
// 更新唯一值
|
// 更新唯一值
|
||||||
if (!StrUtil.isEmpty(tokenBean.getId()) &&
|
String oldUserId = platformUnique.getUserId();
|
||||||
!Objects.equals(oldUserId, tokenBean.getId())) {
|
if (!Objects.equals(oldUserId, tokenBean.getId())) {
|
||||||
platformUnique.setUserId(tokenBean.getId());
|
platformUnique.setUserId(tokenBean.getId());
|
||||||
saveOrUpdate(platformUnique);
|
saveOrUpdate(platformUnique);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addLoginLog(tokenBean, loginInfo);
|
||||||
|
|
||||||
|
if (StrUtil.isNotEmpty(errorMsg)) {
|
||||||
|
throw new ApiException(errorMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return tokenBean;
|
return tokenBean;
|
||||||
@@ -78,40 +96,37 @@ public class CorePlatformUniqueService extends TsServiceBase<CorePlatformUniqueM
|
|||||||
* @param bean
|
* @param bean
|
||||||
*/
|
*/
|
||||||
public void redirect(TokenBean bean, String to, String extra, HttpServletResponse response) {
|
public void redirect(TokenBean bean, String to, String extra, HttpServletResponse response) {
|
||||||
tsLoginConfigurer.redirect(bean, to, extra, response);
|
if (TsTokenConfig.validToken(bean)) {
|
||||||
|
tsLoginConfigurer.redirect(bean, to, extra, response);
|
||||||
|
} else {
|
||||||
|
tsLoginConfigurer.onLoginError(to, response);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 签名错误的时候
|
|
||||||
*/
|
|
||||||
public void onSignError(HttpServletResponse response) {
|
|
||||||
tsLoginConfigurer.onSignError(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
// 登录日志
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加登录日志
|
* 添加登录日志
|
||||||
*
|
*
|
||||||
* @param platformUnique
|
|
||||||
* @param tokenBean
|
* @param tokenBean
|
||||||
|
* @param info
|
||||||
*/
|
*/
|
||||||
public void addLoginLog(CorePlatformUnique platformUnique, TokenBean tokenBean) {
|
public void addLoginLog(TokenBean tokenBean, DoLoginInfo info) {
|
||||||
|
|
||||||
HttpServletRequest request = ServletKit.getRequest();
|
|
||||||
String ip = ServletKit.getClientIP(request);
|
|
||||||
|
|
||||||
CoreLogLogin login = new CoreLogLogin();
|
CoreLogLogin login = new CoreLogLogin();
|
||||||
login.setUserId(tokenBean.getId());
|
login.setPlatform(info.getPlatform());
|
||||||
login.setPlatform(platformUnique.getPlatform());
|
login.setParams(JSON.toJSONString(info));
|
||||||
|
|
||||||
RequestUserInfo requestUserInfo = tsLoginConfigurer.getCachedUserInfo(tokenBean, true);
|
if (TsTokenConfig.validToken(tokenBean)) {
|
||||||
login.setUserName(requestUserInfo.getName());
|
RequestUserInfo requestUserInfo = tsLoginConfigurer.getCachedUserInfo(tokenBean, true);
|
||||||
|
login.setUserId(tokenBean.getId());
|
||||||
|
login.setUserName(requestUserInfo.getName());
|
||||||
|
login.setResult(1);
|
||||||
|
} else {
|
||||||
|
login.setUserName(info.getUnique());
|
||||||
|
login.setResult(0);
|
||||||
|
}
|
||||||
|
|
||||||
login.setIp(ip);
|
login.setIp(info.getLoginIp());
|
||||||
login.setAddress(ip2regionConfig.search(login.getIp()));
|
login.setAddress(ip2regionConfig.search(login.getIp()));
|
||||||
coreLogLoginMapper.insert(login);
|
coreLogLoginMapper.insert(login);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ public interface TsLoginConfigurer {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 签名错误的时候
|
* 登录失败的时候
|
||||||
*/
|
*/
|
||||||
default void onSignError(HttpServletResponse response) {
|
default void onLoginError(String to,HttpServletResponse response) {
|
||||||
ServletKit.write(response, "404", "text");
|
ServletKit.write(response, "404", "text");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,21 @@
|
|||||||
<result column="platform" jdbcType="VARCHAR" property="platform" />
|
<result column="platform" jdbcType="VARCHAR" property="platform" />
|
||||||
<result column="ip" jdbcType="VARCHAR" property="ip" />
|
<result column="ip" jdbcType="VARCHAR" property="ip" />
|
||||||
<result column="address" jdbcType="VARCHAR" property="address" />
|
<result column="address" jdbcType="VARCHAR" property="address" />
|
||||||
|
<result column="result" jdbcType="INTEGER" property="result" />
|
||||||
|
<result column="params" jdbcType="LONGVARCHAR" property="params" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
id, create_time, update_time, is_deleted, user_id, user_name, platform, ip, address
|
id, create_time, update_time, is_deleted, user_id, user_name, platform, ip, address,
|
||||||
|
`result`, params
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
<select id="getLoginErrorTimes" resultType="int">
|
||||||
|
select count(1)
|
||||||
|
from core_log_login
|
||||||
|
where ip = #{ip}
|
||||||
|
and result = 0
|
||||||
|
and create_time > date_add(now(), interval -10 minute)
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>2.0.0.rc42</version>
|
<version>2.0.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-message</artifactId>
|
<artifactId>springboot-message</artifactId>
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ public class AliyunSmsSender implements TsMessageSender {
|
|||||||
String signature = specialUrlEncode(digest);
|
String signature = specialUrlEncode(digest);
|
||||||
queryMap.put("Signature", signature);
|
queryMap.put("Signature", signature);
|
||||||
|
|
||||||
String respBody = "";
|
String respBody;
|
||||||
try {
|
try {
|
||||||
respBody = OkHttpUtil.get(ENDPOINT + "?Signature=" + signature + sortQueryStringTmp);
|
respBody = OkHttpUtil.get(ENDPOINT + "?Signature=" + signature + sortQueryStringTmp);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>2.0.0.rc42</version>
|
<version>2.0.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-platform</artifactId>
|
<artifactId>springboot-platform</artifactId>
|
||||||
|
|||||||
@@ -76,15 +76,16 @@ public class PlatformDingConfig {
|
|||||||
request = OkHttpUtil.ofPost(url, body);
|
request = OkHttpUtil.ofPost(url, body);
|
||||||
}
|
}
|
||||||
request = request.newBuilder().header("x-acs-dingtalk-access-token", accessToken).build();
|
request = request.newBuilder().header("x-acs-dingtalk-access-token", accessToken).build();
|
||||||
try {
|
try (Response response = OkHttpUtil.ofHttpClient().build().newCall(request).execute()) {
|
||||||
Response response = OkHttpUtil.ofHttpClient().build().newCall(request).execute();
|
|
||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
String rawBody = response.body().string();
|
String rawBody = response.body().string();
|
||||||
DingResponse<T> bean = JSON.parseObject(rawBody, typeReference);
|
DingResponse<T> bean = JSON.parseObject(rawBody, typeReference);
|
||||||
bean.setRawBody(rawBody);
|
bean.setRawBody(rawBody);
|
||||||
return bean;
|
return bean;
|
||||||
} else {
|
} else {
|
||||||
LogFactory.get().info(response.body().string());
|
if (response.body() != null) {
|
||||||
|
LogFactory.get().info(response.body().string());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogFactory.get().error(e);
|
LogFactory.get().error(e);
|
||||||
@@ -246,7 +247,7 @@ public class PlatformDingConfig {
|
|||||||
JSONObject object = new JSONObject();
|
JSONObject object = new JSONObject();
|
||||||
object.put("dept_id", deptId);
|
object.put("dept_id", deptId);
|
||||||
object.put("cursor", cursor);
|
object.put("cursor", cursor);
|
||||||
object.put("size", 100);
|
object.put("size", 200);
|
||||||
|
|
||||||
return doRequest(service, "https://oapi.dingtalk.com/topapi/v2/user/list",
|
return doRequest(service, "https://oapi.dingtalk.com/topapi/v2/user/list",
|
||||||
object, new TypeReference<DingResponse<DingUserListVo>>() {
|
object, new TypeReference<DingResponse<DingUserListVo>>() {
|
||||||
|
|||||||
BIN
springboot-poi/.DS_Store
vendored
BIN
springboot-poi/.DS_Store
vendored
Binary file not shown.
@@ -1,34 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
|
||||||
<artifactId>springboot-parent</artifactId>
|
|
||||||
<version>2.0.0.rc42</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>springboot-poi</artifactId>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
|
||||||
<maven.compiler.target>8</maven.compiler.target>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba</groupId>
|
|
||||||
<artifactId>easyexcel</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
|
||||||
<artifactId>springboot-util</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.tiesheng.poi.pojos;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author hao
|
|
||||||
*/
|
|
||||||
public interface PoiReadBase {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package com.tiesheng.poi.pojos;
|
|
||||||
|
|
||||||
import com.alibaba.excel.annotation.write.style.*;
|
|
||||||
import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum;
|
|
||||||
import com.alibaba.excel.enums.poi.VerticalAlignmentEnum;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author hao
|
|
||||||
*/
|
|
||||||
@HeadRowHeight(24)
|
|
||||||
@HeadFontStyle(fontHeightInPoints = 13)
|
|
||||||
@HeadStyle(horizontalAlignment = HorizontalAlignmentEnum.LEFT)
|
|
||||||
@ContentRowHeight(20)
|
|
||||||
@ContentFontStyle(fontHeightInPoints = 12)
|
|
||||||
@ContentStyle(verticalAlignment = VerticalAlignmentEnum.CENTER)
|
|
||||||
@ColumnWidth(20)
|
|
||||||
public interface PoiWriteBase {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package com.tiesheng.poi.util;
|
|
||||||
|
|
||||||
import com.alibaba.excel.EasyExcel;
|
|
||||||
import com.alibaba.excel.read.listener.ReadListener;
|
|
||||||
import com.tiesheng.poi.pojos.PoiReadBase;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public class PoiReadUtil {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 读取文件
|
|
||||||
*
|
|
||||||
* @param file
|
|
||||||
* @param readListener
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static <T extends PoiReadBase> void read(File file, Class<T> tClass, ReadListener<T> readListener) {
|
|
||||||
EasyExcel.read(file, tClass, readListener).autoTrim(true).headRowNumber(1).sheet().doRead();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package com.tiesheng.poi.util;
|
|
||||||
|
|
||||||
import com.alibaba.excel.EasyExcel;
|
|
||||||
import com.alibaba.excel.annotation.write.style.*;
|
|
||||||
import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum;
|
|
||||||
import com.alibaba.excel.enums.poi.VerticalAlignmentEnum;
|
|
||||||
import com.alibaba.excel.support.ExcelTypeEnum;
|
|
||||||
import com.tiesheng.poi.pojos.PoiWriteBase;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author hao
|
|
||||||
*/
|
|
||||||
@HeadRowHeight(24)
|
|
||||||
@HeadFontStyle(fontHeightInPoints = 13)
|
|
||||||
@HeadStyle(horizontalAlignment = HorizontalAlignmentEnum.LEFT)
|
|
||||||
@ContentRowHeight(20)
|
|
||||||
@ContentFontStyle(fontHeightInPoints = 12)
|
|
||||||
@ContentStyle(verticalAlignment = VerticalAlignmentEnum.CENTER)
|
|
||||||
@ColumnWidth(20)
|
|
||||||
public class PoiWriteUtil {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出数据
|
|
||||||
*
|
|
||||||
* @param list
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static <T extends PoiWriteBase> boolean export(List<T> list, Class<T> tClass, String absPath, String sheetName) {
|
|
||||||
EasyExcel.write(absPath, tClass).excelType(ExcelTypeEnum.XLSX)
|
|
||||||
.sheet(sheetName)
|
|
||||||
.doWrite(list);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>2.0.0.rc42</version>
|
<version>2.0.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-role</artifactId>
|
<artifactId>springboot-role</artifactId>
|
||||||
|
|||||||
@@ -3,10 +3,13 @@ package com.tiesheng.role.controller;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.tiesheng.role.pojos.dao.CoreRoleAuthority;
|
import com.tiesheng.role.pojos.dao.CoreRoleAuthority;
|
||||||
|
import com.tiesheng.role.pojos.dao.CoreRoleGroup;
|
||||||
import com.tiesheng.role.pojos.dao.CoreRoleServer;
|
import com.tiesheng.role.pojos.dao.CoreRoleServer;
|
||||||
import com.tiesheng.role.pojos.dto.OwnerMenuDTO;
|
import com.tiesheng.role.pojos.dto.OwnerMenuDTO;
|
||||||
import com.tiesheng.role.pojos.dto.OwnerPointDTO;
|
import com.tiesheng.role.pojos.dto.OwnerPointDTO;
|
||||||
|
import com.tiesheng.role.pojos.vo.GroupTypeDTO;
|
||||||
import com.tiesheng.role.pojos.vo.ServiceMenuVO;
|
import com.tiesheng.role.pojos.vo.ServiceMenuVO;
|
||||||
import com.tiesheng.role.service.CoreRoleService;
|
import com.tiesheng.role.service.CoreRoleService;
|
||||||
import com.tiesheng.util.pojos.ApiResp;
|
import com.tiesheng.util.pojos.ApiResp;
|
||||||
@@ -101,4 +104,24 @@ public class CommRoleController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色、职位列表
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/group")
|
||||||
|
public ApiResp<List<CoreRoleGroup>> groupPage(@Valid GroupTypeDTO dto) {
|
||||||
|
|
||||||
|
QueryWrapper<CoreRoleGroup> queryWrapper = new QueryWrapper<CoreRoleGroup>()
|
||||||
|
.eq("is_deleted", 0)
|
||||||
|
.eq(StrUtil.isNotEmpty(dto.getType()), "type", dto.getType())
|
||||||
|
.orderByAsc("sort");
|
||||||
|
dto.likeColumns(queryWrapper, "name");
|
||||||
|
|
||||||
|
Page<CoreRoleGroup> page = dto.pageObj();
|
||||||
|
coreRoleService.page(page, queryWrapper);
|
||||||
|
|
||||||
|
return ApiResp.respOK(page.getRecords(), page.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,7 +138,6 @@ public class CoreRoleService extends TsServiceBase<CoreRoleGroupMapper, CoreRole
|
|||||||
coreRoleGroupRxMapper.batchInsert(list);
|
coreRoleGroupRxMapper.batchInsert(list);
|
||||||
onRoleChange(dto.getId(), "");
|
onRoleChange(dto.getId(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -148,13 +147,16 @@ public class CoreRoleService extends TsServiceBase<CoreRoleGroupMapper, CoreRole
|
|||||||
* @param roleUser
|
* @param roleUser
|
||||||
*/
|
*/
|
||||||
public void roleUserUpdate(CoreRoleUser roleUser) {
|
public void roleUserUpdate(CoreRoleUser roleUser) {
|
||||||
|
Validator.validateNotEmpty(roleUser.getType(), "请选择授权方式");
|
||||||
|
Validator.validateNotEmpty(roleUser.getTypeId(), "请选择授权" + (Objects.equals(roleUser.getType(), "menu") ? "菜单" : "职位"));
|
||||||
|
|
||||||
if (StrUtil.isNotEmpty(roleUser.getId())) {
|
if (StrUtil.isNotEmpty(roleUser.getId())) {
|
||||||
coreRoleUserMapper.updateById(roleUser);
|
coreRoleUserMapper.updateById(roleUser);
|
||||||
} else {
|
} else {
|
||||||
coreRoleUserMapper.insert(roleUser);
|
coreRoleUserMapper.insert(roleUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
onRoleChange(roleUser.getTypeId(), roleUser.getUserId());
|
onRoleChange("", roleUser.getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -171,7 +173,7 @@ public class CoreRoleService extends TsServiceBase<CoreRoleGroupMapper, CoreRole
|
|||||||
coreRoleUser.setIsDeleted(1);
|
coreRoleUser.setIsDeleted(1);
|
||||||
coreRoleUserMapper.updateById(coreRoleUser);
|
coreRoleUserMapper.updateById(coreRoleUser);
|
||||||
|
|
||||||
onRoleChange(coreRoleUser.getTypeId(), coreRoleUser.getUserId());
|
onRoleChange("", coreRoleUser.getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -179,8 +181,13 @@ public class CoreRoleService extends TsServiceBase<CoreRoleGroupMapper, CoreRole
|
|||||||
* 当授权发生变化时
|
* 当授权发生变化时
|
||||||
*/
|
*/
|
||||||
public void onRoleChange(String roleId, String userId) {
|
public void onRoleChange(String roleId, String userId) {
|
||||||
TsCacheService.of().keys(StrUtil.format(TsAuthorityHandler.CACHE_HAS_AUTHORITY,
|
if (StrUtil.isEmpty(roleId)) {
|
||||||
roleId, userId)).forEach(key -> TsCacheService.of().remove(key));
|
TsCacheService.of().keys(StrUtil.replace(TsAuthorityHandler.CACHE_AUTHORITY,
|
||||||
|
":{}", "")).forEach(key -> TsCacheService.of().remove(key));
|
||||||
|
} else {
|
||||||
|
TsCacheService.of().keys(StrUtil.format(TsAuthorityHandler.CACHE_AUTHORITY,
|
||||||
|
roleId, userId)).forEach(key -> TsCacheService.of().remove(key));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ public class RoleAuthorityHandler implements TsAuthorityHandler {
|
|||||||
groupAuthority.setParent(parentId);
|
groupAuthority.setParent(parentId);
|
||||||
groupAuthority.setVersion(version);
|
groupAuthority.setVersion(version);
|
||||||
groupAuthority.setSource("auto");
|
groupAuthority.setSource("auto");
|
||||||
|
groupAuthority.setDeps("[]");
|
||||||
groupAuthority.setId(StrUtil.join("_", groupAuthority.getService(), groupAuthority.getNo()));
|
groupAuthority.setId(StrUtil.join("_", groupAuthority.getService(), groupAuthority.getNo()));
|
||||||
list.add(groupAuthority);
|
list.add(groupAuthority);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>2.0.0.rc42</version>
|
<version>2.0.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-util</artifactId>
|
<artifactId>springboot-util</artifactId>
|
||||||
@@ -15,7 +15,6 @@
|
|||||||
<maven.compiler.source>8</maven.compiler.source>
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
<maven.compiler.target>8</maven.compiler.target>
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<hutool.version>5.8.31</hutool.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|||||||
@@ -17,7 +17,25 @@ public class ServletKit extends ServletUtil {
|
|||||||
public static HttpServletRequest getRequest() {
|
public static HttpServletRequest getRequest() {
|
||||||
ServletRequestAttributes attributes = (ServletRequestAttributes)
|
ServletRequestAttributes attributes = (ServletRequestAttributes)
|
||||||
RequestContextHolder.getRequestAttributes();
|
RequestContextHolder.getRequestAttributes();
|
||||||
return attributes.getRequest();
|
if (attributes != null) {
|
||||||
|
return attributes.getRequest();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取请求头
|
||||||
|
*
|
||||||
|
* @param name 请求头
|
||||||
|
* @return 请求头
|
||||||
|
*/
|
||||||
|
public static String getHeader(String name) {
|
||||||
|
HttpServletRequest request = getRequest();
|
||||||
|
if (request == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return getHeader(request, name, "utf-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -27,6 +45,9 @@ public class ServletKit extends ServletUtil {
|
|||||||
*/
|
*/
|
||||||
public static String getClientIP() {
|
public static String getClientIP() {
|
||||||
HttpServletRequest request = getRequest();
|
HttpServletRequest request = getRequest();
|
||||||
|
if (request == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
return getClientIP(request);
|
return getClientIP(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,12 @@
|
|||||||
package com.tiesheng.util.config;
|
package com.tiesheng.util.config;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.Base64;
|
||||||
import cn.hutool.core.util.NumberUtil;
|
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.crypto.SecureUtil;
|
import cn.hutool.crypto.SecureUtil;
|
||||||
import cn.hutool.crypto.SmUtil;
|
import cn.hutool.crypto.SmUtil;
|
||||||
import cn.hutool.crypto.symmetric.SM4;
|
import cn.hutool.crypto.symmetric.SM4;
|
||||||
import com.tiesheng.util.ServletKit;
|
|
||||||
import com.tiesheng.util.exception.ApiException;
|
import com.tiesheng.util.exception.ApiException;
|
||||||
import com.tiesheng.util.service.TsCacheService;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@@ -31,6 +28,7 @@ public class EncryptConfig {
|
|||||||
private String key = "WmdUzPJXbngVNiaSsQrihg==";
|
private String key = "WmdUzPJXbngVNiaSsQrihg==";
|
||||||
private Integer saltSize = 8;
|
private Integer saltSize = 8;
|
||||||
private boolean body = false;
|
private boolean body = false;
|
||||||
|
private String pwdPatten = "^(?![A-Za-z0-9]+$)(?![a-z0-9\\W]+$)(?![A-Za-z\\W]+$)(?![A-Z0-9\\W]+$)[a-zA-Z0-9\\W]{8,}$";
|
||||||
|
|
||||||
public EncryptConfig() {
|
public EncryptConfig() {
|
||||||
sm4 = SmUtil.sm4(Base64.decode(getKey()));
|
sm4 = SmUtil.sm4(Base64.decode(getKey()));
|
||||||
@@ -76,25 +74,13 @@ public class EncryptConfig {
|
|||||||
if (StrUtil.isEmpty(salt) || StrUtil.length(salt) != getSaltSize()) {
|
if (StrUtil.isEmpty(salt) || StrUtil.length(salt) != getSaltSize()) {
|
||||||
salt = RandomUtil.randomString(saltSize);
|
salt = RandomUtil.randomString(saltSize);
|
||||||
}
|
}
|
||||||
if (!passwdComplexity(inputPasswd)) {
|
if (!inputPasswd.matches(getPwdPatten())) {
|
||||||
throw new ApiException("需要包含数字、大小写字母、特殊符号,且长度不低于8位");
|
throw new ApiException("密码复杂度不够,请重新设置");
|
||||||
}
|
}
|
||||||
return encrypt(salt + SecureUtil.sha1(salt + inputPasswd));
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 密码校验
|
* 密码校验
|
||||||
*
|
*
|
||||||
@@ -104,12 +90,6 @@ public class EncryptConfig {
|
|||||||
String salt = decrypt(encrypted).substring(0, saltSize);
|
String salt = decrypt(encrypted).substring(0, saltSize);
|
||||||
String inputEncrypted = passwdCreate(inputPasswd, salt);
|
String inputEncrypted = passwdCreate(inputPasswd, salt);
|
||||||
if (!StrUtil.equals(inputEncrypted, encrypted)) {
|
if (!StrUtil.equals(inputEncrypted, encrypted)) {
|
||||||
String clientIp = "passwdVerify_" + ServletKit.getClientIP();
|
|
||||||
int num = NumberUtil.parseInt(TsCacheService.of().get(clientIp, -1));
|
|
||||||
if (num > 5) {
|
|
||||||
throw new ApiException("登录失败已达6次,请10分钟后再试");
|
|
||||||
}
|
|
||||||
TsCacheService.of().put(clientIp, String.valueOf(num + 1), 10 * 60);
|
|
||||||
throw new ApiException("账号或密码错误");
|
throw new ApiException("账号或密码错误");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -142,4 +122,12 @@ public class EncryptConfig {
|
|||||||
public void setBody(boolean body) {
|
public void setBody(boolean body) {
|
||||||
this.body = body;
|
this.body = body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPwdPatten() {
|
||||||
|
return pwdPatten;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPwdPatten(String pwdPatten) {
|
||||||
|
this.pwdPatten = pwdPatten;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,16 @@ public class TsTokenConfig {
|
|||||||
return validToken(token, thrExp);
|
return validToken(token, thrExp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* token是否有效
|
||||||
|
*
|
||||||
|
* @param token
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean validToken(TokenBean token) {
|
||||||
|
return token != null && StrUtil.isNotEmpty(token.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证token
|
* 验证token
|
||||||
|
|||||||
@@ -384,7 +384,7 @@ public class JWT implements RegisteredPayload<JWT> {
|
|||||||
* @since 5.7.4
|
* @since 5.7.4
|
||||||
*/
|
*/
|
||||||
public boolean validate(long leeway) {
|
public boolean validate(long leeway) {
|
||||||
if (false == verify()) {
|
if (!verify()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -160,13 +160,13 @@ public class JWTValidator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final String algorithmIdInSigner = signer.getAlgorithmId();
|
final String algorithmIdInSigner = signer.getAlgorithmId();
|
||||||
if (false == StrUtil.equals(algorithmId, algorithmIdInSigner)) {
|
if (!StrUtil.equals(algorithmId, algorithmIdInSigner)) {
|
||||||
throw new ValidateException("Algorithm [{}] defined in header doesn't match to [{}]!"
|
throw new ValidateException("Algorithm [{}] defined in header doesn't match to [{}]!"
|
||||||
, algorithmId, algorithmIdInSigner);
|
, algorithmId, algorithmIdInSigner);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 通过算法验证签名是否正确
|
// 通过算法验证签名是否正确
|
||||||
if (false == jwt.verify(signer)) {
|
if (!jwt.verify(signer)) {
|
||||||
throw new ValidateException("Signature verification failed!");
|
throw new ValidateException("Signature verification failed!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,11 +68,11 @@ public class TsCacheService {
|
|||||||
/**
|
/**
|
||||||
* 获取key
|
* 获取key
|
||||||
*
|
*
|
||||||
* @param pattern
|
* @param prefix
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Set<String> keys(String pattern) {
|
public Set<String> keys(String prefix) {
|
||||||
return tsCacheHandler.keys(pattern);
|
return tsCacheHandler.keys(prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ public class TsCacheService {
|
|||||||
* 验证 图片验证码
|
* 验证 图片验证码
|
||||||
*/
|
*/
|
||||||
public void verifyCaptcha(String value) {
|
public void verifyCaptcha(String value) {
|
||||||
String captchaKey = ServletUtil.getHeader(ServletKit.getRequest(), "captcha", "utf-8");
|
String captchaKey = ServletKit.getHeader("captcha");
|
||||||
String cache = get(captchaKey);
|
String cache = get(captchaKey);
|
||||||
if (StrUtil.isEmpty(cache) || !StrUtil.equals(cache, value)) {
|
if (StrUtil.isEmpty(cache) || !StrUtil.equals(cache, value)) {
|
||||||
throw new ApiException("验证码不正确");
|
throw new ApiException("验证码不正确");
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import java.util.Set;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConditionalOnMissingBean(value = TsCacheHandler.class, ignored = {TsCacheTimedHandler.class, TsCacheTimedHandler.class})
|
@ConditionalOnMissingBean(value = TsCacheHandler.class, ignored = {TsCacheTimedHandler.class})
|
||||||
public class TsCacheTimedHandler implements TsCacheHandler {
|
public class TsCacheTimedHandler implements TsCacheHandler {
|
||||||
|
|
||||||
private static volatile TimedCache<String, String> timedCache;
|
private static volatile TimedCache<String, String> timedCache;
|
||||||
|
|||||||
@@ -83,9 +83,11 @@ public class OkHttpUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String get(String urlString, int timeout) {
|
public static String get(String urlString, int timeout) {
|
||||||
try {
|
try (Response execute = ofHttpClient().connectTimeout(timeout, TimeUnit.MILLISECONDS)
|
||||||
return ofHttpClient().connectTimeout(timeout, TimeUnit.MILLISECONDS)
|
.build().newCall(ofGet(urlString)).execute()) {
|
||||||
.build().newCall(ofGet(urlString)).execute().body().string();
|
if (execute.body() != null) {
|
||||||
|
return execute.body().string();
|
||||||
|
}
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -117,9 +119,11 @@ public class OkHttpUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String post(String urlString, RequestBody body, int timeout) {
|
public static String post(String urlString, RequestBody body, int timeout) {
|
||||||
try {
|
try (Response response = ofHttpClient().connectTimeout(timeout, TimeUnit.MILLISECONDS)
|
||||||
return ofHttpClient().connectTimeout(timeout, TimeUnit.MILLISECONDS)
|
.build().newCall(ofPost(urlString, body)).execute()) {
|
||||||
.build().newCall(ofPost(urlString, body)).execute().body().string();
|
if (response.body() != null) {
|
||||||
|
return response.body().string();
|
||||||
|
}
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -135,11 +139,10 @@ public class OkHttpUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static File downloadFile(String url, File destFile) {
|
public static File downloadFile(String url, File destFile) {
|
||||||
try {
|
try (Response response = ofHttpClient()
|
||||||
Response response = ofHttpClient()
|
.connectTimeout(0, TimeUnit.MILLISECONDS)
|
||||||
.connectTimeout(0, TimeUnit.MILLISECONDS)
|
.readTimeout(0, TimeUnit.MILLISECONDS)
|
||||||
.readTimeout(0, TimeUnit.MILLISECONDS)
|
.build().newCall(ofGet(url)).execute()) {
|
||||||
.build().newCall(ofGet(url)).execute();
|
|
||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
FileUtil.writeFromStream(response.body().byteStream(), destFile);
|
FileUtil.writeFromStream(response.body().byteStream(), destFile);
|
||||||
}
|
}
|
||||||
@@ -150,11 +153,10 @@ public class OkHttpUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] downloadBytes(String url) {
|
public static byte[] downloadBytes(String url) {
|
||||||
try {
|
try (Response response = ofHttpClient()
|
||||||
Response response = ofHttpClient()
|
.connectTimeout(0, TimeUnit.MILLISECONDS)
|
||||||
.connectTimeout(0, TimeUnit.MILLISECONDS)
|
.readTimeout(0, TimeUnit.MILLISECONDS)
|
||||||
.readTimeout(0, TimeUnit.MILLISECONDS)
|
.build().newCall(ofGet(url)).execute()) {
|
||||||
.build().newCall(ofGet(url)).execute();
|
|
||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
return response.body().bytes();
|
return response.body().bytes();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import java.util.List;
|
|||||||
@Service
|
@Service
|
||||||
public interface TsAuthorityHandler {
|
public interface TsAuthorityHandler {
|
||||||
|
|
||||||
String CACHE_HAS_AUTHORITY = "CACHE:HAS_AUTHORITY:{}:{}";
|
String CACHE_AUTHORITY = "CACHE:AUTHORITY:{}:{}";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>2.0.0.rc42</version>
|
<version>2.0.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-web</artifactId>
|
<artifactId>springboot-web</artifactId>
|
||||||
@@ -49,11 +49,6 @@
|
|||||||
<artifactId>springboot-database</artifactId>
|
<artifactId>springboot-database</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
|
||||||
<artifactId>springboot-poi</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-login</artifactId>
|
<artifactId>springboot-login</artifactId>
|
||||||
@@ -64,11 +59,6 @@
|
|||||||
<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,7 +1,6 @@
|
|||||||
package com.tiesheng.web;
|
package com.tiesheng.web;
|
||||||
|
|
||||||
import com.tiesheng.database.DatabaseAutoConfigurer;
|
import com.tiesheng.database.DatabaseAutoConfigurer;
|
||||||
import com.tiesheng.encrypt.EncryptAutoConfigurer;
|
|
||||||
import com.tiesheng.message.MessageAutoConfigurer;
|
import com.tiesheng.message.MessageAutoConfigurer;
|
||||||
import com.tiesheng.platform.PlatformAutoConfigurer;
|
import com.tiesheng.platform.PlatformAutoConfigurer;
|
||||||
import com.tiesheng.util.UtilAutoConfigurer;
|
import com.tiesheng.util.UtilAutoConfigurer;
|
||||||
@@ -21,7 +20,6 @@ import java.lang.annotation.*;
|
|||||||
MessageAutoConfigurer.class,
|
MessageAutoConfigurer.class,
|
||||||
WebAutoConfigurer.class,
|
WebAutoConfigurer.class,
|
||||||
DatabaseAutoConfigurer.class,
|
DatabaseAutoConfigurer.class,
|
||||||
EncryptAutoConfigurer.class,
|
|
||||||
PlatformAutoConfigurer.class,
|
PlatformAutoConfigurer.class,
|
||||||
})
|
})
|
||||||
public @interface EnableTieshengWeb {
|
public @interface EnableTieshengWeb {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.tiesheng.encrypt.config;
|
package com.tiesheng.web.config.encrypt;
|
||||||
|
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.tiesheng.encrypt.config;
|
package com.tiesheng.web.config.encrypt;
|
||||||
|
|
||||||
import cn.hutool.core.annotation.AnnotationUtil;
|
import cn.hutool.core.annotation.AnnotationUtil;
|
||||||
import cn.hutool.log.LogFactory;
|
import cn.hutool.log.LogFactory;
|
||||||
@@ -56,8 +56,12 @@ 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();
|
HttpServletRequest request = ServletKit.getRequest();
|
||||||
|
if (request == null) {
|
||||||
|
return joinPoint.proceed();
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET请求不处理
|
||||||
if (StrUtil.equalsIgnoreCase(request.getMethod(), "GET")) {
|
if (StrUtil.equalsIgnoreCase(request.getMethod(), "GET")) {
|
||||||
return joinPoint.proceed(joinPoint.getArgs());
|
return joinPoint.proceed(joinPoint.getArgs());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ 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;
|
||||||
import org.aspectj.lang.reflect.MethodSignature;
|
import org.aspectj.lang.reflect.MethodSignature;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@@ -24,6 +25,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
@Aspect
|
@Aspect
|
||||||
@Component
|
@Component
|
||||||
|
@ConditionalOnBean(value = TsAuthorityHandler.class)
|
||||||
public class RoleAuthorityAspect {
|
public class RoleAuthorityAspect {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@@ -56,7 +58,7 @@ public class RoleAuthorityAspect {
|
|||||||
|
|
||||||
HttpServletRequest request = ServletKit.getRequest();
|
HttpServletRequest request = ServletKit.getRequest();
|
||||||
TokenBean tokenBean = tsTokenConfig.validToken(request, true);
|
TokenBean tokenBean = tsTokenConfig.validToken(request, true);
|
||||||
String cacheKey = StrUtil.format(TsAuthorityHandler.CACHE_HAS_AUTHORITY, tokenBean.getRoleId(), tokenBean.getId());
|
String cacheKey = StrUtil.format(TsAuthorityHandler.CACHE_AUTHORITY, tokenBean.getRoleId(), tokenBean.getId());
|
||||||
List<String> authorityList = StrUtil.split(TsCacheService.of().get(cacheKey), ";")
|
List<String> authorityList = StrUtil.split(TsCacheService.of().get(cacheKey), ";")
|
||||||
.stream().filter(StrUtil::isNotEmpty).collect(Collectors.toList());
|
.stream().filter(StrUtil::isNotEmpty).collect(Collectors.toList());
|
||||||
if (CollUtil.isEmpty(authorityList)) {
|
if (CollUtil.isEmpty(authorityList)) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
|
|||||||
import com.tiesheng.annotation.role.RoleAuthority;
|
import com.tiesheng.annotation.role.RoleAuthority;
|
||||||
import com.tiesheng.util.service.role.TsAuthorityHandler;
|
import com.tiesheng.util.service.role.TsAuthorityHandler;
|
||||||
import org.springframework.aop.support.AopUtils;
|
import org.springframework.aop.support.AopUtils;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
import org.springframework.context.event.ContextRefreshedEvent;
|
import org.springframework.context.event.ContextRefreshedEvent;
|
||||||
@@ -18,6 +19,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ConditionalOnBean(value = TsAuthorityHandler.class)
|
||||||
public class RoleAuthorityCreator implements ApplicationListener<ContextRefreshedEvent> {
|
public class RoleAuthorityCreator implements ApplicationListener<ContextRefreshedEvent> {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
package com.tiesheng.web.config.template;
|
|
||||||
|
|
||||||
import com.tiesheng.web.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package com.tiesheng.web.config.template;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import com.tiesheng.web.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());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -62,6 +62,7 @@ public class CommWebController {
|
|||||||
QueryWrapper<CoreConfigEnum> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<CoreConfigEnum> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("is_deleted", 0);
|
queryWrapper.eq("is_deleted", 0);
|
||||||
queryWrapper.eq("type", dto.getType());
|
queryWrapper.eq("type", dto.getType());
|
||||||
|
queryWrapper.orderByAsc("type", "sort");
|
||||||
List<CoreConfigEnum> selectList = coreConfigService.getEnumMapper().selectList(queryWrapper);
|
List<CoreConfigEnum> selectList = coreConfigService.getEnumMapper().selectList(queryWrapper);
|
||||||
|
|
||||||
return ApiResp.respOK(selectList);
|
return ApiResp.respOK(selectList);
|
||||||
|
|||||||
@@ -4,19 +4,33 @@ package com.tiesheng.web.controller.comm;
|
|||||||
import cn.hutool.captcha.LineCaptcha;
|
import cn.hutool.captcha.LineCaptcha;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.tiesheng.annotation.operation.OperationIgnore;
|
||||||
import com.tiesheng.annotation.token.TokenIgnore;
|
import com.tiesheng.annotation.token.TokenIgnore;
|
||||||
import com.tiesheng.util.service.TsCacheService;
|
|
||||||
import com.tiesheng.web.config.template.ToolTemplateHandler;
|
|
||||||
import com.tiesheng.web.pojos.dto.*;
|
|
||||||
import com.tiesheng.web.pojos.vo.TemplateInfoVO;
|
|
||||||
import com.tiesheng.web.pojos.vo.PicVerifyVo;
|
|
||||||
import com.tiesheng.web.service.FileUploadService;
|
|
||||||
import com.tiesheng.util.exception.ApiException;
|
import com.tiesheng.util.exception.ApiException;
|
||||||
import com.tiesheng.util.pojos.ApiResp;
|
import com.tiesheng.util.pojos.ApiResp;
|
||||||
|
import com.tiesheng.util.pojos.TokenBean;
|
||||||
|
import com.tiesheng.util.service.TsCacheService;
|
||||||
|
import com.tiesheng.web.pojos.dao.CoreLogProcess;
|
||||||
|
import com.tiesheng.web.pojos.dto.ChunkCheckDTO;
|
||||||
|
import com.tiesheng.web.pojos.dto.ChunkMergeDTO;
|
||||||
|
import com.tiesheng.web.pojos.dto.ChunkStartDTO;
|
||||||
|
import com.tiesheng.web.pojos.dto.ImageCodeDTO;
|
||||||
|
import com.tiesheng.web.pojos.imex.ExportDealDTO;
|
||||||
|
import com.tiesheng.web.pojos.imex.ImportDealDTO;
|
||||||
|
import com.tiesheng.web.pojos.imex.ImportInfoDTO;
|
||||||
|
import com.tiesheng.web.pojos.imex.ImportInfoVO;
|
||||||
|
import com.tiesheng.web.pojos.vo.PicVerifyVo;
|
||||||
|
import com.tiesheng.web.service.CoreLogService;
|
||||||
|
import com.tiesheng.web.service.FileUploadService;
|
||||||
|
import com.tiesheng.web.service.imex.TsExportHandler;
|
||||||
|
import com.tiesheng.web.service.imex.TsImportHandler;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -35,7 +49,11 @@ public class ToolController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
FileUploadService fileUploadService;
|
FileUploadService fileUploadService;
|
||||||
@Autowired
|
@Autowired
|
||||||
List<ToolTemplateHandler> templateHandlerList;
|
List<TsImportHandler> importHandlers;
|
||||||
|
@Autowired
|
||||||
|
List<TsExportHandler> exportHandlers;
|
||||||
|
@Autowired
|
||||||
|
CoreLogService coreLogService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -124,40 +142,102 @@ public class ToolController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@TokenIgnore
|
///////////////////////////////////////////////////////////////////////////
|
||||||
@GetMapping("/template/info")
|
// import
|
||||||
public ApiResp<TemplateInfoVO> templateInfo(TemplateInfoDTO dto) {
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
List<ToolTemplateHandler> collect = templateHandlerList.stream()
|
@TokenIgnore
|
||||||
.filter(it -> Objects.equals(it.getAction(), dto.getAction()))
|
@GetMapping("/imex/info")
|
||||||
.sorted((it, it2) -> it2.getSort() - it.getSort())
|
public ApiResp<ImportInfoVO> importInfo(@Valid ImportInfoDTO dto) {
|
||||||
.collect(Collectors.toList());
|
|
||||||
if (CollUtil.isEmpty(collect)) {
|
ImportInfoVO template = new ImportInfoVO();
|
||||||
throw new ApiException("没有找到对应的模版");
|
|
||||||
|
if (Objects.equals(dto.getType(), "import")) {
|
||||||
|
List<TsImportHandler> collect = importHandlers.stream()
|
||||||
|
.filter(it -> Objects.equals(it.getAction(), dto.getAction()))
|
||||||
|
.sorted((it, it2) -> it2.getSort() - it.getSort())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(collect)) {
|
||||||
|
TsImportHandler toolTemplateHandler = collect.get(0);
|
||||||
|
template.setTemplateUrl(toolTemplateHandler.getTemplateUrl());
|
||||||
|
template.setImexId(toolTemplateHandler.getImexId());
|
||||||
|
}
|
||||||
|
} else if (Objects.equals(dto.getType(), "export")) {
|
||||||
|
List<TsExportHandler> collect = exportHandlers.stream()
|
||||||
|
.filter(it -> Objects.equals(it.getAction(), dto.getAction()))
|
||||||
|
.sorted((it, it2) -> it2.getSort() - it.getSort())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(collect)) {
|
||||||
|
TsExportHandler toolTemplateHandler = collect.get(0);
|
||||||
|
template.setImexId(toolTemplateHandler.getImexId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolTemplateHandler toolTemplateHandler = collect.get(0);
|
if (StrUtil.isEmpty(template.getImexId())) {
|
||||||
|
throw new ApiException("没有找到对应的模版");
|
||||||
TemplateInfoVO template = new TemplateInfoVO();
|
}
|
||||||
template.setTemplateUrl(toolTemplateHandler.getTemplateUrl());
|
|
||||||
template.setParams(toolTemplateHandler.getParms(dto.getParams()));
|
|
||||||
template.setTemplateId(toolTemplateHandler.getTeamplateId());
|
|
||||||
|
|
||||||
return ApiResp.respOK(template);
|
return ApiResp.respOK(template);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TokenIgnore
|
|
||||||
@PostMapping("/template/deal")
|
|
||||||
public ApiResp<String> templateDeal(@RequestBody TemplateDealDTO dto) {
|
|
||||||
|
|
||||||
List<ToolTemplateHandler> collect = templateHandlerList.stream().
|
@TokenIgnore
|
||||||
filter(it -> Objects.equals(it.getTeamplateId(), dto.getTemplateId()))
|
@OperationIgnore
|
||||||
|
@PostMapping("/import/deal")
|
||||||
|
public ApiResp<String> importDeal(@RequestBody @Valid ImportDealDTO dto, TokenBean token) {
|
||||||
|
|
||||||
|
List<TsImportHandler> collect = importHandlers.stream().
|
||||||
|
filter(it -> Objects.equals(it.getImexId(), dto.getImexId()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
if (CollUtil.isEmpty(collect)) {
|
if (CollUtil.isEmpty(collect)) {
|
||||||
throw new ApiException("模版ID不存在");
|
throw new ApiException("导入ID不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
return ApiResp.respOK(collect.get(0).handler(dto));
|
TsImportHandler tsImportHandler = collect.get(0);
|
||||||
|
tsImportHandler.validToken(token);
|
||||||
|
List read = tsImportHandler.ready(dto, token);
|
||||||
|
if (CollUtil.isEmpty(read)) {
|
||||||
|
throw new ApiException("没有数据可以导入");
|
||||||
|
}
|
||||||
|
CoreLogProcess coreLogProcess = coreLogService.addProcess(tsImportHandler.getImexId(), read, tsImportHandler);
|
||||||
|
coreLogProcess.setParams(JSON.toJSONString(dto));
|
||||||
|
coreLogService.getCoreLogProcessMapper().updateById(coreLogProcess);
|
||||||
|
|
||||||
|
return ApiResp.respOK(coreLogProcess.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// export
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@TokenIgnore
|
||||||
|
@OperationIgnore
|
||||||
|
@PostMapping("/export/deal")
|
||||||
|
public ApiResp<String> exportDeal(@RequestBody @Valid ExportDealDTO dto, TokenBean token) {
|
||||||
|
|
||||||
|
List<TsExportHandler> collect = exportHandlers.stream().
|
||||||
|
filter(it -> Objects.equals(it.getImexId(), dto.getImexId()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (CollUtil.isEmpty(collect)) {
|
||||||
|
throw new ApiException("导出ID不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
TsExportHandler tsExportHandler = collect.get(0);
|
||||||
|
tsExportHandler.validToken(token);
|
||||||
|
List read = tsExportHandler.ready(dto, token);
|
||||||
|
if (CollUtil.isEmpty(read)) {
|
||||||
|
throw new ApiException("没有数据可以导出");
|
||||||
|
}
|
||||||
|
CoreLogProcess coreLogProcess = coreLogService.addProcess(tsExportHandler.getImexId(), read, tsExportHandler);
|
||||||
|
coreLogProcess.setType("export");
|
||||||
|
coreLogProcess.setParams(JSON.toJSONString(dto));
|
||||||
|
coreLogService.getCoreLogProcessMapper().updateById(coreLogProcess);
|
||||||
|
|
||||||
|
return ApiResp.respOK(coreLogProcess.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ public class ConfigEnumController {
|
|||||||
if (!StrUtil.isEmpty(dto.getType())) {
|
if (!StrUtil.isEmpty(dto.getType())) {
|
||||||
queryWrapper.eq("type", dto.getType());
|
queryWrapper.eq("type", dto.getType());
|
||||||
}
|
}
|
||||||
|
queryWrapper.orderByAsc("type", "sort");
|
||||||
List<CoreConfigEnum> selectList = coreConfigService.getEnumMapper().selectList(queryWrapper);
|
List<CoreConfigEnum> selectList = coreConfigService.getEnumMapper().selectList(queryWrapper);
|
||||||
|
|
||||||
return ApiResp.respOK(selectList);
|
return ApiResp.respOK(selectList);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class LogApiController {
|
|||||||
if (!StrUtil.isEmpty(result)) {
|
if (!StrUtil.isEmpty(result)) {
|
||||||
queryWrapper.eq("result", result);
|
queryWrapper.eq("result", result);
|
||||||
}
|
}
|
||||||
dto.likeColumns(queryWrapper, "type", "content");
|
dto.likeColumns(queryWrapper, "type", "url", "content");
|
||||||
queryWrapper.orderByDesc("create_time");
|
queryWrapper.orderByDesc("create_time");
|
||||||
|
|
||||||
Page<CoreLogApi> page = dto.pageObj();
|
Page<CoreLogApi> page = dto.pageObj();
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
|||||||
import com.tiesheng.util.pojos.DaoBase;
|
import com.tiesheng.util.pojos.DaoBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 配置-枚举
|
* 配置-枚举
|
||||||
*/
|
*/
|
||||||
@TableName(value = "core_config_enum")
|
@TableName(value = "core_config_enum")
|
||||||
public class CoreConfigEnum extends DaoBase {
|
public class CoreConfigEnum extends DaoBase {
|
||||||
/**
|
/**
|
||||||
@@ -21,6 +21,12 @@ public class CoreConfigEnum extends DaoBase {
|
|||||||
@TableField(value = "`name`")
|
@TableField(value = "`name`")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序
|
||||||
|
*/
|
||||||
|
@TableField(value = "sort")
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
@@ -69,6 +75,24 @@ public class CoreConfigEnum extends DaoBase {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取排序
|
||||||
|
*
|
||||||
|
* @return sort - 排序
|
||||||
|
*/
|
||||||
|
public Integer getSort() {
|
||||||
|
return sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置排序
|
||||||
|
*
|
||||||
|
* @param sort 排序
|
||||||
|
*/
|
||||||
|
public void setSort(Integer sort) {
|
||||||
|
this.sort = sort;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取备注
|
* 获取备注
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -48,14 +48,8 @@ public class CoreLogProcess extends DaoBase {
|
|||||||
/**
|
/**
|
||||||
* 失败的文件
|
* 失败的文件
|
||||||
*/
|
*/
|
||||||
@TableField(value = "fail_file")
|
@TableField(value = "result_file")
|
||||||
private String failFile;
|
private String resultFile;
|
||||||
|
|
||||||
/**
|
|
||||||
* 异常说明
|
|
||||||
*/
|
|
||||||
@TableField(value = "error")
|
|
||||||
private String error;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 进度
|
* 进度
|
||||||
@@ -63,6 +57,12 @@ public class CoreLogProcess extends DaoBase {
|
|||||||
@TableField(value = "`process`")
|
@TableField(value = "`process`")
|
||||||
private Integer process;
|
private Integer process;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异常说明
|
||||||
|
*/
|
||||||
|
@TableField(value = "params")
|
||||||
|
private String params;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取标题
|
* 获取标题
|
||||||
*
|
*
|
||||||
@@ -174,37 +174,19 @@ public class CoreLogProcess extends DaoBase {
|
|||||||
/**
|
/**
|
||||||
* 获取失败的文件
|
* 获取失败的文件
|
||||||
*
|
*
|
||||||
* @return fail_file - 失败的文件
|
* @return result_file - 失败的文件
|
||||||
*/
|
*/
|
||||||
public String getFailFile() {
|
public String getResultFile() {
|
||||||
return failFile;
|
return resultFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置失败的文件
|
* 设置失败的文件
|
||||||
*
|
*
|
||||||
* @param failFile 失败的文件
|
* @param resultFile 失败的文件
|
||||||
*/
|
*/
|
||||||
public void setFailFile(String failFile) {
|
public void setResultFile(String resultFile) {
|
||||||
this.failFile = failFile;
|
this.resultFile = resultFile;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取异常说明
|
|
||||||
*
|
|
||||||
* @return error - 异常说明
|
|
||||||
*/
|
|
||||||
public String getError() {
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置异常说明
|
|
||||||
*
|
|
||||||
* @param error 异常说明
|
|
||||||
*/
|
|
||||||
public void setError(String error) {
|
|
||||||
this.error = error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -224,4 +206,22 @@ public class CoreLogProcess extends DaoBase {
|
|||||||
public void setProcess(Integer process) {
|
public void setProcess(Integer process) {
|
||||||
this.process = process;
|
this.process = process;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取异常说明
|
||||||
|
*
|
||||||
|
* @return params - 异常说明
|
||||||
|
*/
|
||||||
|
public String getParams() {
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置异常说明
|
||||||
|
*
|
||||||
|
* @param params 异常说明
|
||||||
|
*/
|
||||||
|
public void setParams(String params) {
|
||||||
|
this.params = params;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ public class ImageCodeDTO {
|
|||||||
if (height == null) {
|
if (height == null) {
|
||||||
height = 62;
|
height = 62;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
width = Math.min(width, 500);
|
||||||
|
height = Math.min(height, 200);
|
||||||
|
|
||||||
LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(width, height, 4, lineCount);
|
LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(width, height, 4, lineCount);
|
||||||
lineCaptcha.setGenerator(new RandomGenerator("0123456789", 4));
|
lineCaptcha.setGenerator(new RandomGenerator("0123456789", 4));
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.tiesheng.web.pojos.imex;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
|
public class ExportDealDTO {
|
||||||
|
|
||||||
|
@NotEmpty(message = "模版ID")
|
||||||
|
private String imexId;
|
||||||
|
private JSONObject params;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// setter\getter
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
public String getImexId() {
|
||||||
|
return imexId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImexId(String imexId) {
|
||||||
|
this.imexId = imexId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSONObject getParams() {
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParams(JSONObject params) {
|
||||||
|
this.params = params;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,25 +1,27 @@
|
|||||||
package com.tiesheng.web.pojos.dto;
|
package com.tiesheng.web.pojos.imex;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
public class TemplateDealDTO {
|
public class ImportDealDTO {
|
||||||
|
|
||||||
@NotEmpty(message = "模版ID")
|
@NotEmpty(message = "模版ID")
|
||||||
private String templateId;
|
private String imexId;
|
||||||
@NotEmpty(message = "文件路径必填")
|
@NotEmpty(message = "文件路径必填")
|
||||||
private String file;
|
private String file;
|
||||||
private Object params;
|
private JSONObject params;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// setter\getter
|
// setter\getter
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public String getTemplateId() {
|
public String getImexId() {
|
||||||
return templateId;
|
return imexId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTemplateId(String templateId) {
|
public void setImexId(String imexId) {
|
||||||
this.templateId = templateId;
|
this.imexId = imexId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFile() {
|
public String getFile() {
|
||||||
@@ -30,11 +32,11 @@ public class TemplateDealDTO {
|
|||||||
this.file = file;
|
this.file = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getParams() {
|
public JSONObject getParams() {
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParams(Object params) {
|
public void setParams(JSONObject params) {
|
||||||
this.params = params;
|
this.params = params;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,15 @@
|
|||||||
package com.tiesheng.web.pojos.dto;
|
package com.tiesheng.web.pojos.imex;
|
||||||
|
|
||||||
|
|
||||||
public class TemplateInfoDTO {
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
|
public class ImportInfoDTO {
|
||||||
|
|
||||||
|
@NotEmpty(message = "操作必须存在")
|
||||||
private String action;
|
private String action;
|
||||||
private Object params;
|
|
||||||
|
@NotEmpty(message = "类型必须存在")
|
||||||
|
private String type;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// setter\getter
|
// setter\getter
|
||||||
@@ -18,11 +23,11 @@ public class TemplateInfoDTO {
|
|||||||
this.action = action;
|
this.action = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getParams() {
|
public String getType() {
|
||||||
return params;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParams(Object params) {
|
public void setType(String type) {
|
||||||
this.params = params;
|
this.type = type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.tiesheng.web.pojos.imex;
|
||||||
|
|
||||||
|
|
||||||
|
public class ImportInfoVO {
|
||||||
|
|
||||||
|
private String imexId;
|
||||||
|
private String templateUrl;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// setter\getter
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public String getImexId() {
|
||||||
|
return imexId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImexId(String imexId) {
|
||||||
|
this.imexId = imexId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTemplateUrl() {
|
||||||
|
return templateUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTemplateUrl(String templateUrl) {
|
||||||
|
this.templateUrl = templateUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ package com.tiesheng.web.pojos.vo;
|
|||||||
*/
|
*/
|
||||||
public class ProcessDetailVo {
|
public class ProcessDetailVo {
|
||||||
|
|
||||||
private String title;
|
private String id;
|
||||||
|
|
||||||
private Integer total;
|
private Integer total;
|
||||||
|
|
||||||
@@ -15,13 +15,17 @@ public class ProcessDetailVo {
|
|||||||
|
|
||||||
private Integer process;
|
private Integer process;
|
||||||
|
|
||||||
private String type;
|
|
||||||
|
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
private String failFile;
|
private String resultFile;
|
||||||
|
|
||||||
private String error;
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getStatus() {
|
public Integer getStatus() {
|
||||||
return status;
|
return status;
|
||||||
@@ -31,14 +35,6 @@ public class ProcessDetailVo {
|
|||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getTotal() {
|
public Integer getTotal() {
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
@@ -63,20 +59,12 @@ public class ProcessDetailVo {
|
|||||||
this.failNum = failNum;
|
this.failNum = failNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
public String getResultFile() {
|
||||||
return type;
|
return resultFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(String type) {
|
public void setResultFile(String resultFile) {
|
||||||
this.type = type;
|
this.resultFile = resultFile;
|
||||||
}
|
|
||||||
|
|
||||||
public String getFailFile() {
|
|
||||||
return failFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFailFile(String failFile) {
|
|
||||||
this.failFile = failFile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getProcess() {
|
public Integer getProcess() {
|
||||||
@@ -87,11 +75,4 @@ public class ProcessDetailVo {
|
|||||||
this.process = process;
|
this.process = process;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getError() {
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setError(String error) {
|
|
||||||
this.error = error;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
package com.tiesheng.web.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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -23,7 +23,6 @@ import com.tiesheng.web.util.ProcessSyncConsumer;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,11 +31,6 @@ import java.util.List;
|
|||||||
@Service
|
@Service
|
||||||
public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLogOperation> {
|
public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLogOperation> {
|
||||||
|
|
||||||
/**
|
|
||||||
* 日志缓存
|
|
||||||
*/
|
|
||||||
private static final List<CoreLogOperation> cacheOperations = new ArrayList<>();
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
TieshengWebConfigurer tieshengWebConfigurer;
|
TieshengWebConfigurer tieshengWebConfigurer;
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -79,33 +73,24 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
|
|||||||
coreLogProcess.setSuccessNum(0);
|
coreLogProcess.setSuccessNum(0);
|
||||||
coreLogProcess.setFailNum(0);
|
coreLogProcess.setFailNum(0);
|
||||||
coreLogProcess.setProcess(0);
|
coreLogProcess.setProcess(0);
|
||||||
coreLogProcess.setError("");
|
coreLogProcess.setParams("");
|
||||||
coreLogProcessMapper.insert(coreLogProcess);
|
coreLogProcessMapper.insert(coreLogProcess);
|
||||||
|
|
||||||
ThreadUtil.execute(() -> {
|
ThreadUtil.execute(() -> {
|
||||||
List<Exception> errorList = new ArrayList<>();
|
|
||||||
CollUtil.split(list, 100).forEach((it) -> {
|
CollUtil.split(list, 100).forEach((it) -> {
|
||||||
int accept = 0;
|
int accept = consumer.batchHandler(it);
|
||||||
try {
|
|
||||||
accept = consumer.accept(it);
|
|
||||||
} catch (Exception e) {
|
|
||||||
errorList.add(e);
|
|
||||||
}
|
|
||||||
coreLogProcess.setProcess(coreLogProcess.getProcess() + it.size());
|
coreLogProcess.setProcess(coreLogProcess.getProcess() + it.size());
|
||||||
coreLogProcess.setSuccessNum(coreLogProcess.getSuccessNum() + accept);
|
coreLogProcess.setSuccessNum(coreLogProcess.getSuccessNum() + accept);
|
||||||
coreLogProcess.setFailNum(coreLogProcess.getFailNum() + it.size() - accept);
|
coreLogProcess.setFailNum(coreLogProcess.getFailNum() + it.size() - accept);
|
||||||
coreLogProcess.setError(JSON.toJSONString(errorList));
|
|
||||||
coreLogProcessMapper.updateById(coreLogProcess);
|
coreLogProcessMapper.updateById(coreLogProcess);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 执行结束
|
// 执行结束
|
||||||
coreLogProcess.setFailFile(consumer.getFailFile());
|
coreLogProcess.setResultFile(consumer.getResultFile());
|
||||||
coreLogProcess.setStatus(1);
|
coreLogProcess.setStatus(1);
|
||||||
coreLogProcess.setError(JSON.toJSONString(errorList));
|
|
||||||
coreLogProcessMapper.updateById(coreLogProcess);
|
coreLogProcessMapper.updateById(coreLogProcess);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return coreLogProcess;
|
return coreLogProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,29 +111,24 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
|
|||||||
coreLogProcess.setFailNum(0);
|
coreLogProcess.setFailNum(0);
|
||||||
coreLogProcess.setTotal(0);
|
coreLogProcess.setTotal(0);
|
||||||
coreLogProcess.setProcess(0);
|
coreLogProcess.setProcess(0);
|
||||||
coreLogProcess.setError("");
|
|
||||||
coreLogProcessMapper.insert(coreLogProcess);
|
coreLogProcessMapper.insert(coreLogProcess);
|
||||||
|
|
||||||
ThreadUtil.execute(() -> {
|
ThreadUtil.execute(() -> {
|
||||||
int pageSize = 1000;
|
int pageSize = 1000;
|
||||||
int pageNum = 1, lastCount = pageSize;
|
int pageNum = 1, lastCount = pageSize;
|
||||||
List<Exception> errorList = new ArrayList<>();
|
|
||||||
while (lastCount == pageSize) {
|
while (lastCount == pageSize) {
|
||||||
try {
|
try {
|
||||||
lastCount = consumer.accept(pageNum, pageSize);
|
lastCount = consumer.accept(pageNum, pageSize);
|
||||||
coreLogProcess.setTotal(coreLogProcess.getTotal() + lastCount);
|
coreLogProcess.setTotal(coreLogProcess.getTotal() + lastCount);
|
||||||
coreLogProcess.setProcess(coreLogProcess.getTotal());
|
coreLogProcess.setProcess(coreLogProcess.getTotal());
|
||||||
coreLogProcess.setError(JSON.toJSONString(errorList));
|
|
||||||
coreLogProcess.setSuccessNum(coreLogProcess.getSuccessNum() + lastCount);
|
coreLogProcess.setSuccessNum(coreLogProcess.getSuccessNum() + lastCount);
|
||||||
} catch (Exception e) {
|
} catch (Exception ignored) {
|
||||||
errorList.add(e);
|
|
||||||
}
|
}
|
||||||
coreLogProcessMapper.updateById(coreLogProcess);
|
coreLogProcessMapper.updateById(coreLogProcess);
|
||||||
pageNum++;
|
pageNum++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 执行结束
|
// 执行结束
|
||||||
coreLogProcess.setError(JSON.toJSONString(errorList));
|
|
||||||
coreLogProcess.setStatus(1);
|
coreLogProcess.setStatus(1);
|
||||||
coreLogProcessMapper.updateById(coreLogProcess);
|
coreLogProcessMapper.updateById(coreLogProcess);
|
||||||
});
|
});
|
||||||
@@ -194,14 +174,7 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
|
|||||||
if (params != null) {
|
if (params != null) {
|
||||||
operation.setParams(JSON.toJSONString(params));
|
operation.setParams(JSON.toJSONString(params));
|
||||||
}
|
}
|
||||||
|
save(operation);
|
||||||
synchronized (CoreLogOperation.class) {
|
|
||||||
cacheOperations.add(operation);
|
|
||||||
if (cacheOperations.size() >= 100) {
|
|
||||||
getBaseMapper().batchInsert(cacheOperations);
|
|
||||||
cacheOperations.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.tiesheng.web.service;
|
package com.tiesheng.web.service;
|
||||||
|
|
||||||
import cn.hutool.core.thread.ThreadUtil;
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.tiesheng.util.service.http.OkHttpUtil;
|
import com.tiesheng.util.service.http.OkHttpUtil;
|
||||||
import com.tiesheng.web.mapper.CoreLogApiMapper;
|
import com.tiesheng.web.mapper.CoreLogApiMapper;
|
||||||
@@ -13,7 +14,7 @@ import javax.annotation.Resource;
|
|||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class LogApiOkHttpInterceptor implements Interceptor {
|
public class OkHttpLogInterceptor implements Interceptor {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
CoreLogApiMapper coreLogApiMapper;
|
CoreLogApiMapper coreLogApiMapper;
|
||||||
@@ -32,10 +33,18 @@ public class LogApiOkHttpInterceptor implements Interceptor {
|
|||||||
Response response;
|
Response response;
|
||||||
try {
|
try {
|
||||||
response = chain.proceed(request);
|
response = chain.proceed(request);
|
||||||
ResponseBody peekBody = response.peekBody(Long.MAX_VALUE);
|
|
||||||
logApi.setRespBody(peekBody.string());
|
|
||||||
logApi.setResult(response.code());
|
logApi.setResult(response.code());
|
||||||
peekBody.close();
|
|
||||||
|
// 如果是json,xml,text,则保存记录
|
||||||
|
if (response.body() != null) {
|
||||||
|
MediaType mediaType = response.body().contentType();
|
||||||
|
String contentType = mediaType == null ? "" : mediaType.toString();
|
||||||
|
if (StrUtil.containsAny(contentType, "json", "xml", "text")) {
|
||||||
|
ResponseBody peekBody = response.peekBody(Long.MAX_VALUE);
|
||||||
|
logApi.setRespBody(peekBody.string());
|
||||||
|
peekBody.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
JSONObject object = new JSONObject();
|
JSONObject object = new JSONObject();
|
||||||
@@ -46,6 +55,9 @@ public class LogApiOkHttpInterceptor implements Interceptor {
|
|||||||
|
|
||||||
response = new Response.Builder()
|
response = new Response.Builder()
|
||||||
.request(request)
|
.request(request)
|
||||||
|
.protocol(Protocol.HTTP_1_1)
|
||||||
|
.code(logApi.getResult())
|
||||||
|
.message(e.getMessage())
|
||||||
.body(OkHttpUtil.ofJsonResponse(logApi.getRespBody()))
|
.body(OkHttpUtil.ofJsonResponse(logApi.getRespBody()))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package com.tiesheng.web.service.imex;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.tiesheng.util.pojos.TokenBean;
|
||||||
|
import com.tiesheng.web.pojos.imex.ExportDealDTO;
|
||||||
|
import com.tiesheng.web.pojos.imex.ImportDealDTO;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class DefaultImexHandler implements TsImportHandler<String>, TsExportHandler<String> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> ready(ExportDealDTO dto, TokenBean token) {
|
||||||
|
return CollUtil.newArrayList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> ready(ImportDealDTO dto, TokenBean token) {
|
||||||
|
return CollUtil.newArrayList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTemplateUrl() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAction() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int batchHandler(List<String> list) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getResultFile() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.tiesheng.web.service.imex;
|
||||||
|
|
||||||
|
import com.tiesheng.util.pojos.TokenBean;
|
||||||
|
import com.tiesheng.web.pojos.imex.ExportDealDTO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface TsExportHandler<T> extends TsImexBase<T> {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据准备中
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<T> ready(ExportDealDTO dto, TokenBean token);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package com.tiesheng.web.service.imex;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.tiesheng.util.exception.ApiException;
|
||||||
|
import com.tiesheng.util.pojos.TokenBean;
|
||||||
|
import com.tiesheng.web.util.ProcessImportConsumer;
|
||||||
|
|
||||||
|
public interface TsImexBase<T> extends ProcessImportConsumer<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动作说明(唯一)
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String getAction();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序,如果action相同,只会使用sort大的来处理
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
default int getSort() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证是否登录
|
||||||
|
*
|
||||||
|
* @param tokenBean
|
||||||
|
*/
|
||||||
|
default void validToken(TokenBean tokenBean) {
|
||||||
|
if (tokenBean == null || StrUtil.isEmpty(tokenBean.getId())) {
|
||||||
|
throw new ApiException("请先登录");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取模版ID
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
default String getImexId() {
|
||||||
|
return StrUtil.format("{}_{}", getAction(), getSort());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.tiesheng.web.service.imex;
|
||||||
|
|
||||||
|
import com.tiesheng.util.pojos.TokenBean;
|
||||||
|
import com.tiesheng.web.pojos.imex.ImportDealDTO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface TsImportHandler<T> extends TsImexBase<T> {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取文件内容
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<T> ready(ImportDealDTO dto, TokenBean token);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取模版地址
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String getTemplateUrl();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -6,20 +6,19 @@ public interface ProcessImportConsumer<T> {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理数据
|
* 分批处理
|
||||||
*
|
*
|
||||||
* @param list
|
* @param list
|
||||||
* @param <T>
|
|
||||||
* @return 返回成功的数量
|
* @return 返回成功的数量
|
||||||
*/
|
*/
|
||||||
int accept(List<T> list);
|
int batchHandler(List<T> list);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取失败的文件路径
|
* 获取导入结果文件
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String getFailFile();
|
String getResultFile();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,4 +33,7 @@ CREATE TABLE `core_config_system`
|
|||||||
) ENGINE = InnoDB
|
) ENGINE = InnoDB
|
||||||
DEFAULT CHARSET = utf8mb4 COMMENT ='配置-系统';
|
DEFAULT CHARSET = utf8mb4 COMMENT ='配置-系统';
|
||||||
|
|
||||||
|
alter table core_config_enum
|
||||||
|
add sort int(10) not null default 0 comment '排序' after name;
|
||||||
|
|
||||||
SET FOREIGN_KEY_CHECKS = 1;
|
SET FOREIGN_KEY_CHECKS = 1;
|
||||||
|
|||||||
@@ -72,4 +72,18 @@ CREATE TABLE `core_log_operation`
|
|||||||
DEFAULT CHARSET = utf8mb4 COMMENT ='日志-操作';
|
DEFAULT CHARSET = utf8mb4 COMMENT ='日志-操作';
|
||||||
|
|
||||||
|
|
||||||
|
alter table core_log_process
|
||||||
|
change error params longtext null comment '异常说明';
|
||||||
|
|
||||||
|
alter table core_log_process
|
||||||
|
change fail_file result_file varchar(500) null comment '失败的文件';
|
||||||
|
|
||||||
|
## 2.0.2
|
||||||
|
|
||||||
|
alter table core_log_login
|
||||||
|
add result int(10) not null default 1 comment '登录结果,0否,1是';
|
||||||
|
|
||||||
|
alter table core_log_login
|
||||||
|
add params longtext null comment '请求参数';
|
||||||
|
|
||||||
SET FOREIGN_KEY_CHECKS = 1;
|
SET FOREIGN_KEY_CHECKS = 1;
|
||||||
|
|||||||
@@ -10,11 +10,12 @@
|
|||||||
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted" />
|
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted" />
|
||||||
<result column="type" jdbcType="VARCHAR" property="type" />
|
<result column="type" jdbcType="VARCHAR" property="type" />
|
||||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||||
|
<result column="sort" jdbcType="INTEGER" property="sort" />
|
||||||
<result column="remark" jdbcType="VARCHAR" property="remark" />
|
<result column="remark" jdbcType="VARCHAR" property="remark" />
|
||||||
<result column="ext" jdbcType="VARCHAR" property="ext" />
|
<result column="ext" jdbcType="VARCHAR" property="ext" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
id, create_time, update_time, is_deleted, `type`, `name`, remark, ext
|
id, create_time, update_time, is_deleted, `type`, `name`, sort, remark, ext
|
||||||
</sql>
|
</sql>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -14,13 +14,13 @@
|
|||||||
<result column="fail_num" jdbcType="INTEGER" property="failNum" />
|
<result column="fail_num" jdbcType="INTEGER" property="failNum" />
|
||||||
<result column="type" jdbcType="VARCHAR" property="type" />
|
<result column="type" jdbcType="VARCHAR" property="type" />
|
||||||
<result column="status" jdbcType="INTEGER" property="status" />
|
<result column="status" jdbcType="INTEGER" property="status" />
|
||||||
<result column="fail_file" jdbcType="VARCHAR" property="failFile" />
|
<result column="result_file" jdbcType="VARCHAR" property="resultFile" />
|
||||||
<result column="error" jdbcType="LONGVARCHAR" property="error" />
|
|
||||||
<result column="process" jdbcType="INTEGER" property="process" />
|
<result column="process" jdbcType="INTEGER" property="process" />
|
||||||
|
<result column="params" jdbcType="LONGVARCHAR" property="params" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
id, create_time, update_time, is_deleted, title, total, success_num, fail_num, `type`,
|
id, create_time, update_time, is_deleted, title, total, success_num, fail_num, `type`,
|
||||||
`status`, fail_file, error, `process`
|
`status`, result_file, `process`, params
|
||||||
</sql>
|
</sql>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user