Compare commits
37 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8854225934 | ||
|
|
5ad35cefda | ||
|
|
1921efa27b | ||
|
|
2e9de7ee64 | ||
|
|
e352927396 | ||
|
|
51b26c077d | ||
|
|
2c5f55a876 | ||
|
|
c52f7f5c77 | ||
|
|
7f46d2d371 | ||
|
|
34d8201641 | ||
|
|
92e1c1d9ef | ||
|
|
ee3748c361 | ||
|
|
439947caad | ||
|
|
17706e8065 | ||
|
|
8853e3170d | ||
|
|
222f37afc1 | ||
|
|
f8bc11d456 | ||
|
|
1ea7fa968b | ||
|
|
c892fec45b | ||
|
|
7e94ea54a8 | ||
|
|
d006788c90 | ||
|
|
c63a6769ad | ||
|
|
156cce877b | ||
|
|
49d88ee08f | ||
|
|
88777898c4 | ||
|
|
3f59d00092 | ||
|
|
2e8969f249 | ||
|
|
ebb99ced78 | ||
|
|
e862cdbf43 | ||
|
|
d6faed4f68 | ||
|
|
ec4b0cbb1e | ||
|
|
30fd68d430 | ||
|
|
ec865471cb | ||
|
|
7d454e9c62 | ||
|
|
82c8e3f474 | ||
|
|
b49e736f0d | ||
|
|
603b5abdfe |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -4,4 +4,4 @@ rebel.xml
|
||||
/.idea/
|
||||
*.iml
|
||||
/static/
|
||||
/ipdb/
|
||||
/config/
|
||||
|
||||
78
pom.xml
78
pom.xml
@@ -4,9 +4,9 @@
|
||||
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>
|
||||
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.1.2</version>
|
||||
<version>0.3.0</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>springboot-parent</name>
|
||||
<description>杭州铁晟科技有限公司基础依赖</description>
|
||||
@@ -55,57 +55,57 @@
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-db-migration</artifactId>
|
||||
<version>0.1.2</version>
|
||||
<version>0.3.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-login</artifactId>
|
||||
<version>0.1.2</version>
|
||||
<version>0.3.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-web</artifactId>
|
||||
<version>0.1.2</version>
|
||||
<version>0.3.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-util</artifactId>
|
||||
<version>0.1.2</version>
|
||||
<version>0.3.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-platform</artifactId>
|
||||
<version>0.1.2</version>
|
||||
<version>0.3.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-message</artifactId>
|
||||
<version>0.1.2</version>
|
||||
<version>0.3.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-encrypt</artifactId>
|
||||
<version>0.1.2</version>
|
||||
<version>0.3.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-annotation</artifactId>
|
||||
<version>0.1.2</version>
|
||||
<version>0.3.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-poi</artifactId>
|
||||
<version>0.1.2</version>
|
||||
<version>0.3.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -120,8 +120,44 @@
|
||||
<version>3.5.1</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>kepai-repo-plugin</id>
|
||||
<url>http://git.kepai365.com/zeng_wenhao/kepai-repo/raw/master</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>com.tiesheng.springboot-plugin</groupId>
|
||||
<artifactId>launcher-maven-plugin</artifactId>
|
||||
<version>0.0.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>initScript</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<!-- 把外部jar打包进入项目中 -->
|
||||
<includeSystemScope>true</includeSystemScope>
|
||||
<!-- 打包后的jar可直接执行 -->
|
||||
<executable>true</executable>
|
||||
<embeddedLaunchScript>${basedir}/target/launchScript</embeddedLaunchScript>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
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</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.1.2</version>
|
||||
<version>0.3.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-ademo</artifactId>
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@@ -29,14 +29,15 @@
|
||||
<repository>
|
||||
<id>kepai-repo</id>
|
||||
<url>http://git.kepai365.com/zeng_wenhao/kepai-repo/raw/master</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>com.tiesheng.springboot-plugin</groupId>
|
||||
<artifactId>launcher-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
|
||||
@@ -1,19 +1,53 @@
|
||||
package com.tiesheng.demo.config;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.tiesheng.core.pojos.CurrentWebUser;
|
||||
import com.tiesheng.core.pojos.dao.CorePlatformUnique;
|
||||
import com.tiesheng.core.service.TieshengWebConfigurer;
|
||||
import com.tiesheng.login.config.token.bean.TokenBean;
|
||||
import com.tiesheng.util.config.GlobalConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Objects;
|
||||
|
||||
@Component
|
||||
public class DemoWebConfigurer implements TieshengWebConfigurer {
|
||||
|
||||
@Autowired
|
||||
GlobalConfig globalConfig;
|
||||
|
||||
@Override
|
||||
public CurrentWebUser getCurrentUserName(String userId) {
|
||||
public CurrentWebUser getCurrentUserName(TokenBean tokenBean) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoginConfigurer loginConfigurer() {
|
||||
return null;
|
||||
return new LoginConfigurer() {
|
||||
@Override
|
||||
public TokenBean doLogin(CorePlatformUnique platformUnique, String to) {
|
||||
|
||||
// 默认跳转到mobile
|
||||
to = StrUtil.emptyToDefault(to, "mobile");
|
||||
|
||||
TokenBean tokenBean = null;
|
||||
if (!StrUtil.isEmpty(platformUnique.getUserId())) {
|
||||
tokenBean = new TokenBean(platformUnique.getUserId(), to, globalConfig.getService());
|
||||
} else {
|
||||
// 获取用户信息判断是否可登录
|
||||
}
|
||||
|
||||
return tokenBean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redirect(TokenBean bean, String to, String extra, HttpServletResponse response) {
|
||||
if (Objects.equals(bean.getEnvironmentType(), "mobile")) {
|
||||
globalConfig.redirect("mobile", "/?token=" + bean.toToken(), response);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.tiesheng.demo.controller;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.hutool.log.LogFactory;
|
||||
import com.tiesheng.annotation.token.TokenIgnore;
|
||||
import com.tiesheng.login.config.token.TsTokenConfig;
|
||||
import com.tiesheng.login.config.token.bean.TokenBean;
|
||||
import com.tiesheng.message.config.aliyun.AliyunSmsConfig;
|
||||
import com.tiesheng.message.pojos.MessageReqResp;
|
||||
import com.tiesheng.util.config.GlobalConfig;
|
||||
@@ -24,17 +27,24 @@ public class TestController {
|
||||
GlobalConfig globalConfig;
|
||||
@Autowired
|
||||
AliyunSmsConfig aliyunSmsConfig;
|
||||
@Autowired
|
||||
TsTokenConfig tsTokenConfig;
|
||||
|
||||
@RequestMapping("/index")
|
||||
@TokenIgnore
|
||||
public ApiResp<String> index() {
|
||||
|
||||
TokenBean tokenBean = new TokenBean("11", "", "fdfd");
|
||||
LogFactory.get().info(tokenBean.toToken());
|
||||
|
||||
return ApiResp.respOK("hello world");
|
||||
}
|
||||
|
||||
@RequestMapping("/redirect")
|
||||
@TokenIgnore
|
||||
public void redirect(HttpServletResponse response) {
|
||||
globalConfig.redirect("mobile", "/test", response);
|
||||
tsTokenConfig.validToken("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NzYwMDY4NzUsImlkIjoiMSIsImVudmlyb25tZW50VHlwZSI6Im1vYmlsZSIsInNlcnZpY2UiOiJjb250ZXN0LXJlc2VydmUiLCJleHRyYSI6IiJ9.nsfxEFpCNHC7eNCS5DJXdu1VDdnHrTjSfgrozND70Lc", true);
|
||||
// globalConfig.redirect("mobile", "/test", response);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +76,7 @@ public class TestController {
|
||||
@RequestMapping("/uploadPath")
|
||||
@TokenIgnore
|
||||
public ApiResp<String> uploadPath() {
|
||||
FileUploadPath uploadPath = FileUploadPath.get("http://scv6.tmp.kepai365.ltd/upload/2023-01/2b4b6b7b-70d0-4683-859a-f799adc4f04c.xls");
|
||||
FileUploadPath uploadPath = FileUploadPath.file("http://scv6.tmp.kepai365.ltd/upload/2023-01/2b4b6b7b-70d0-4683-859a-f799adc4f04c.xls");
|
||||
return ApiResp.respOK(uploadPath.getAbsolutePath());
|
||||
}
|
||||
|
||||
|
||||
28
springboot-ademo/src/main/resources/application-test.yml
Normal file
28
springboot-ademo/src/main/resources/application-test.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
## Spring配置
|
||||
spring:
|
||||
|
||||
## 数据库配置
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://47.96.30.85:3306/com_tiesheng_web?useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&queryTimeout=5400&allowMultiQueries=true&serverTimezone=GMT%2B8
|
||||
username: com_tiesheng_web
|
||||
password: 4Xo$XheGFc
|
||||
|
||||
platform:
|
||||
wxmp:
|
||||
global:
|
||||
app-id: wxa0343fe519824651
|
||||
app-secret: 776f089ba70bcd66455a7c7893f810b9
|
||||
|
||||
tiesheng:
|
||||
token:
|
||||
ignores:
|
||||
"1111":
|
||||
id: "1111"
|
||||
global:
|
||||
version: 2
|
||||
host: http://localhost:8080
|
||||
aliyun:
|
||||
access-key-id: LTAI5tJtbgBCnTY5eS4SmrTf
|
||||
access-key-secret: JIHqpRUFffCHhXaJEVvWN31WcexWqG
|
||||
sign-name: 阿里云短信测试
|
||||
@@ -1,28 +1,21 @@
|
||||
server:
|
||||
compression:
|
||||
enabled: true
|
||||
|
||||
## Spring配置
|
||||
spring:
|
||||
|
||||
## 数据库配置
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://47.96.30.85:3306/com_tiesheng_web?useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&queryTimeout=5400&allowMultiQueries=true&serverTimezone=GMT%2B8
|
||||
username: com_tiesheng_web
|
||||
password: 4Xo$XheGFc
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 20MB
|
||||
web:
|
||||
resources:
|
||||
static-locations: classpath:/static/,file:static/
|
||||
mvc:
|
||||
pathmatch:
|
||||
matching-strategy: ant_path_matcher
|
||||
|
||||
platform:
|
||||
wxmp:
|
||||
global:
|
||||
app-id: wxa0343fe519824651
|
||||
app-secret: 776f089ba70bcd66455a7c7893f810b9
|
||||
|
||||
tiesheng:
|
||||
token:
|
||||
ignores:
|
||||
"1111":
|
||||
id: "1111"
|
||||
global:
|
||||
version: 2
|
||||
host: http://localhost:8080
|
||||
aliyun:
|
||||
access-key-id: LTAI5tJtbgBCnTY5eS4SmrTf
|
||||
access-key-secret: JIHqpRUFffCHhXaJEVvWN31WcexWqG
|
||||
sign-name: 阿里云短信测试
|
||||
## 日志
|
||||
logging:
|
||||
file:
|
||||
name: logs/tiesheng.log
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
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</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.1.2</version>
|
||||
<version>0.3.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-annotation</artifactId>
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
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</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.1.2</version>
|
||||
<version>0.3.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-db-migration</artifactId>
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-util</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import java.util.List;
|
||||
@ConfigurationProperties(prefix = "tiesheng.db-migration")
|
||||
public class DbMigrationConfig {
|
||||
|
||||
private String table = "core_db_migration";
|
||||
private String table = "core_config_db";
|
||||
private List<String> locations = CollUtil.newArrayList("classpath*:db/migration/*.sql");
|
||||
private String ignoreSqls = "drop,delete";
|
||||
|
||||
@@ -41,7 +41,7 @@ public class DbMigrationConfig {
|
||||
" `file` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文件名称',\n" +
|
||||
" `checksum` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文件checksum',\n" +
|
||||
" PRIMARY KEY (`id`) USING BTREE\n" +
|
||||
") ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'db-合并' ROW_FORMAT = Dynamic;");
|
||||
") ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '配置-数据库' ROW_FORMAT = Dynamic;");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
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</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.1.2</version>
|
||||
<version>0.3.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-encrypt</artifactId>
|
||||
@@ -31,12 +31,12 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-util</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-annotation</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
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</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.1.2</version>
|
||||
<version>0.3.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-login</artifactId>
|
||||
@@ -27,12 +27,12 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-annotation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-platform</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.tiesheng.login.config.token;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.hutool.jwt.JWT;
|
||||
import cn.hutool.jwt.JWTValidator;
|
||||
import com.tiesheng.login.config.token.bean.TokenBean;
|
||||
import com.tiesheng.util.ServletKit;
|
||||
import com.tiesheng.util.exception.ApiException;
|
||||
@@ -66,10 +68,21 @@ public class TsTokenConfig {
|
||||
/**
|
||||
* 验证token
|
||||
*
|
||||
* @param thrExp
|
||||
* @return
|
||||
*/
|
||||
public TokenBean validToken(boolean thrExp) {
|
||||
String token = ServletUtil.getHeader(ServletKit.getRequest(), "token", "utf-8");
|
||||
return validToken(token, thrExp);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 验证token
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public TokenBean validToken(String token, boolean thrExp) {
|
||||
TokenBean tokenBean = isIgnored(token);
|
||||
if (tokenBean != null) {
|
||||
return tokenBean;
|
||||
@@ -77,15 +90,11 @@ public class TsTokenConfig {
|
||||
|
||||
try {
|
||||
JWT decode = JWT.of(token);
|
||||
JWTValidator.of(decode).validateDate();
|
||||
String id = decode.getPayload("id").toString();
|
||||
String environmentType = decode.getPayload("environmentType").toString();
|
||||
String service = decode.getPayload("service").toString();
|
||||
String extra = decode.getPayload("extra").toString();
|
||||
Long expireTime = decode.getPayloads().getLong("time");
|
||||
if (expireTime != null && expireTime < System.currentTimeMillis()) {
|
||||
throw new ApiException("登录过期,请重新登陆");
|
||||
}
|
||||
|
||||
tokenBean = new TokenBean(id, environmentType, service);
|
||||
tokenBean.setExtra(extra);
|
||||
} catch (Exception ignored) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.tiesheng.login.config.token.bean;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.hutool.jwt.JWT;
|
||||
import com.tiesheng.login.config.token.TsTokenConfig;
|
||||
@@ -31,11 +32,11 @@ public class TokenBean {
|
||||
public String toToken() {
|
||||
TsTokenConfig tsTokenConfig = SpringUtil.getBean(TsTokenConfig.class);
|
||||
return JWT.create()
|
||||
.setExpiresAt(DateUtil.offsetHour(DateUtil.date(), tsTokenConfig.getExpireHours()))
|
||||
.setPayload("id", getId())
|
||||
.setPayload("environmentType", getEnvironmentType())
|
||||
.setPayload("service", getService())
|
||||
.setPayload("extra", getExtra())
|
||||
.setPayload("time", System.currentTimeMillis() + tsTokenConfig.getExpireHours() * 1000 * 60 * 60)
|
||||
.setKey(tsTokenConfig.getEncryptKey().getBytes())
|
||||
.sign();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,9 @@ import cn.hutool.core.util.URLUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.tiesheng.annotation.token.TokenIgnore;
|
||||
import com.tiesheng.login.config.token.bean.TokenBean;
|
||||
import com.tiesheng.login.pojos.dto.UniqueIndexDTO;
|
||||
import com.tiesheng.login.pojos.CodeExtraDTO;
|
||||
import com.tiesheng.login.pojos.DoLoginInfo;
|
||||
import com.tiesheng.login.pojos.UniqueIndexDTO;
|
||||
import com.tiesheng.login.service.TieshengLoginConfigurer;
|
||||
import com.tiesheng.platform.config.ding.PlatformDingConfig;
|
||||
import com.tiesheng.platform.config.ding.bean.DingJsapiSignature;
|
||||
@@ -51,9 +53,9 @@ public class LoginController {
|
||||
@GetMapping("/unique/redirect")
|
||||
@TokenIgnore
|
||||
public void uniqueIndex(UniqueIndexDTO dto, HttpServletResponse response) {
|
||||
TokenBean tokenBean = tieshengLoginConfigurer.doLogin("unique_index_" + dto.getPlatform(),
|
||||
dto.getNo(), dto.getPlatform(), dto.getInfo());
|
||||
tieshengLoginConfigurer.onLoginRedirect(tokenBean, dto.getExtra(), response);
|
||||
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo("unique_index_web",
|
||||
dto.getNo(), "web", dto.getTo(), dto.getInfo()));
|
||||
tieshengLoginConfigurer.onLoginRedirect(tokenBean, dto.getTo(), dto.getExtra(), response);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,8 +68,8 @@ public class LoginController {
|
||||
@PostMapping("/unique/index")
|
||||
@TokenIgnore
|
||||
public ApiResp<String> uniqueIndex(@RequestBody UniqueIndexDTO dto) {
|
||||
TokenBean tokenBean = tieshengLoginConfigurer.doLogin("unique_index_" + dto.getPlatform(),
|
||||
dto.getNo(), dto.getPlatform(), dto.getInfo());
|
||||
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo("unique_index_web",
|
||||
dto.getNo(), "web", dto.getTo(), dto.getInfo()));
|
||||
if (tokenBean == null) {
|
||||
throw new ApiException("登录失败");
|
||||
}
|
||||
@@ -112,12 +114,13 @@ public class LoginController {
|
||||
*/
|
||||
@RequestMapping("/ding/oauth2/{service}")
|
||||
@TokenIgnore
|
||||
public void dingOauth2(@PathVariable String service, String code, String extra, HttpServletResponse response) {
|
||||
String ddUserId = platformDingConfig.getUserIdByCode(service, code);
|
||||
public void dingOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) {
|
||||
String ddUserId = platformDingConfig.getUserIdByCode(service, dto.getCode());
|
||||
DingUserInfo dingUserInfo = platformDingConfig.topapiV2UserGet(service, ddUserId);
|
||||
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(dingUserInfo.getAppId(), dingUserInfo.getUserid(), "ding",
|
||||
JSON.toJSONString(dingUserInfo));
|
||||
tieshengLoginConfigurer.onLoginRedirect(tokenBean, extra, response);
|
||||
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo(dingUserInfo.getAppId(),
|
||||
dingUserInfo.getUserid(), "ding", dto.getTo(),
|
||||
JSON.toJSONString(dingUserInfo)));
|
||||
tieshengLoginConfigurer.onLoginRedirect(tokenBean, dto.getTo(), dto.getExtra(), response);
|
||||
}
|
||||
|
||||
|
||||
@@ -159,15 +162,14 @@ public class LoginController {
|
||||
|
||||
/**
|
||||
* 微信授权回调
|
||||
*
|
||||
* @param code
|
||||
*/
|
||||
@RequestMapping("/wxmp/oauth2/{service}")
|
||||
@TokenIgnore
|
||||
public void wxmpOauth2(@PathVariable String service, String code, String extra, HttpServletResponse response) {
|
||||
WxUserInfo wxUserInfo = platformWxmpConfig.getOAuth2AccessToken(service, code);
|
||||
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(wxUserInfo.getAppId(), wxUserInfo.getOpenid(), "wxmp", JSON.toJSONString(wxUserInfo));
|
||||
tieshengLoginConfigurer.onLoginRedirect(tokenBean, extra, response);
|
||||
public void wxmpOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) {
|
||||
WxUserInfo wxUserInfo = platformWxmpConfig.getOAuth2AccessToken(service, dto.getCode());
|
||||
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo(wxUserInfo.getAppId(),
|
||||
wxUserInfo.getOpenid(), "wxmp", dto.getTo(), JSON.toJSONString(wxUserInfo)));
|
||||
tieshengLoginConfigurer.onLoginRedirect(tokenBean, dto.getTo(), dto.getExtra(), response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.tiesheng.login.pojos;
|
||||
|
||||
public class CodeExtraDTO extends LoginToInfo {
|
||||
|
||||
private String code;
|
||||
private String extra;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getExtra() {
|
||||
return extra;
|
||||
}
|
||||
|
||||
public void setExtra(String extra) {
|
||||
this.extra = extra;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.tiesheng.login.pojos;
|
||||
|
||||
public class DoLoginInfo {
|
||||
|
||||
private String appId;
|
||||
private String unique;
|
||||
private String platform;
|
||||
private String to;
|
||||
private String info;
|
||||
private String extra;
|
||||
|
||||
public DoLoginInfo(String appId, String unique, String platform, String to, String info) {
|
||||
this.appId = appId;
|
||||
this.unique = unique;
|
||||
this.platform = platform;
|
||||
this.to = to;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getAppId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
public void setAppId(String appId) {
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
public String getUnique() {
|
||||
return unique;
|
||||
}
|
||||
|
||||
public void setUnique(String unique) {
|
||||
this.unique = unique;
|
||||
}
|
||||
|
||||
public String getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
public void setPlatform(String platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
public String getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
public void setTo(String to) {
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public void setInfo(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public String getExtra() {
|
||||
return extra;
|
||||
}
|
||||
|
||||
public void setExtra(String extra) {
|
||||
this.extra = extra;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.tiesheng.login.pojos;
|
||||
|
||||
public class LoginToInfo {
|
||||
|
||||
private String to;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
public void setTo(String to) {
|
||||
this.to = to;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.tiesheng.login.pojos.dto;
|
||||
package com.tiesheng.login.pojos;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
public class UniqueIndexDTO {
|
||||
public class UniqueIndexDTO extends LoginToInfo {
|
||||
|
||||
private String no;
|
||||
private String platform;
|
||||
private String extra;
|
||||
private String info;
|
||||
|
||||
@@ -21,14 +20,6 @@ public class UniqueIndexDTO {
|
||||
this.no = no;
|
||||
}
|
||||
|
||||
public String getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
public void setPlatform(String platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
public String getExtra() {
|
||||
if (StrUtil.isEmpty(extra)) {
|
||||
extra = "";
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.tiesheng.login.service;
|
||||
|
||||
import com.tiesheng.login.config.token.bean.TokenBean;
|
||||
import com.tiesheng.login.pojos.DoLoginInfo;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -16,7 +17,7 @@ public interface TieshengLoginConfigurer {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
TokenBean doLogin(String appId, String uniqueId, String platfrom, String info);
|
||||
TokenBean doLogin(DoLoginInfo loginInfo);
|
||||
|
||||
|
||||
/**
|
||||
@@ -24,7 +25,7 @@ public interface TieshengLoginConfigurer {
|
||||
*
|
||||
* @param tokenBean
|
||||
*/
|
||||
void onLoginRedirect(TokenBean bean, String extra, HttpServletResponse response);
|
||||
void onLoginRedirect(TokenBean bean, String to, String extra, HttpServletResponse response);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.tiesheng.login.service.impl;
|
||||
|
||||
import com.tiesheng.login.config.token.bean.TokenBean;
|
||||
import com.tiesheng.login.pojos.DoLoginInfo;
|
||||
import com.tiesheng.login.service.TieshengLoginConfigurer;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -15,12 +16,12 @@ import javax.servlet.http.HttpServletResponse;
|
||||
public class DefaultLoginConfigurer implements TieshengLoginConfigurer {
|
||||
|
||||
@Override
|
||||
public TokenBean doLogin(String appId, String uniqueId, String platfrom, String info) {
|
||||
public TokenBean doLogin(DoLoginInfo loginInfo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoginRedirect(TokenBean bean, String extra, HttpServletResponse response) {
|
||||
public void onLoginRedirect(TokenBean bean, String to, String extra, HttpServletResponse response) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
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</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.1.2</version>
|
||||
<version>0.3.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-message</artifactId>
|
||||
@@ -20,7 +20,7 @@
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-platform</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
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</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.1.2</version>
|
||||
<version>0.3.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-platform</artifactId>
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-util</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
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</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.1.2</version>
|
||||
<version>0.3.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-poi</artifactId>
|
||||
@@ -25,7 +25,7 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-util</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
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</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.1.2</version>
|
||||
<version>0.3.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-util</artifactId>
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.io.RandomAccessFile;
|
||||
public class Ip2regionConfig {
|
||||
|
||||
private String dbUrl = "http://git.kepai365.com/zeng_wenhao/kepai-repo/raw/master/ipdb/ip2region.db";
|
||||
private String dbPath = System.getProperty("user.dir") + "/ipdb/ip2region.db";
|
||||
private String dbPath = System.getProperty("user.dir") + "/config/ip2region.db";
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 逻辑方法
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.tiesheng.util.pojos;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.CharUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
@@ -29,19 +30,26 @@ public class FileUploadPath {
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
public static FileUploadPath get(String fileName) {
|
||||
public static FileUploadPath file(String fileName) {
|
||||
|
||||
// 下载文件
|
||||
fileName = downloadFile(fileName);
|
||||
fileName = fileDownload(fileName);
|
||||
|
||||
FileUploadPath pathBean = new FileUploadPath();
|
||||
|
||||
String tempPath = fileName;
|
||||
if (!StrUtil.startWith(tempPath, CharUtil.SLASH)) {
|
||||
tempPath = CharUtil.SLASH + tempPath;
|
||||
}
|
||||
if (!StrUtil.startWith(tempPath, UPLOAD_FOLDER)) {
|
||||
tempPath = UPLOAD_FOLDER + DateUtil.format(DateUtil.date(), "yyyy-MM") + "/" + fileName;
|
||||
tempPath = UPLOAD_FOLDER + DateUtil.format(DateUtil.date(), "yyyy-MM") + CharUtil.SLASH + fileName;
|
||||
}
|
||||
pathBean.setHttpPath(tempPath);
|
||||
pathBean.setAbsolutePath(String.format("%s/static%s", System.getProperty("user.dir"), tempPath));
|
||||
|
||||
String tempAbs = String.format("%s/static%s", System.getProperty("user.dir"), tempPath);
|
||||
tempAbs = FileUtil.normalize(tempAbs);
|
||||
pathBean.setAbsolutePath(tempAbs);
|
||||
|
||||
FileUtil.mkParentDirs(pathBean.getAbsolutePath());
|
||||
|
||||
return pathBean;
|
||||
@@ -51,40 +59,33 @@ public class FileUploadPath {
|
||||
/**
|
||||
* 下载http文件
|
||||
*
|
||||
* @param fileName
|
||||
* @param httpUrl
|
||||
* @return
|
||||
*/
|
||||
public static String downloadFile(String fileName) {
|
||||
if (!StrUtil.startWith(fileName, "http")) {
|
||||
return fileName;
|
||||
public static String fileDownload(String httpUrl) {
|
||||
if (!StrUtil.startWith(httpUrl, "http")) {
|
||||
return httpUrl;
|
||||
}
|
||||
String newFileName = UPLOAD_FOLDER + StrUtil.subAfter(fileName, UPLOAD_FOLDER, true);
|
||||
FileUploadPath uploadPath = get(newFileName);
|
||||
String newFileName = UPLOAD_FOLDER + StrUtil.subAfter(httpUrl, UPLOAD_FOLDER, true);
|
||||
FileUploadPath uploadPath = file(newFileName);
|
||||
if (!FileUtil.exist(uploadPath.getAbsolutePath())) {
|
||||
HttpUtil.downloadFile(fileName, uploadPath.getAbsolutePath());
|
||||
HttpUtil.downloadFile(httpUrl, uploadPath.getAbsolutePath());
|
||||
}
|
||||
|
||||
return uploadPath.getHttpPath();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 随机生成一个文件路径
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static FileUploadPath random() {
|
||||
return get(IdUtil.simpleUUID());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 随机生成一个文件路径
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static FileUploadPath random(String fileExt) {
|
||||
return get(IdUtil.simpleUUID() + "." + fileExt);
|
||||
String fileName = IdUtil.simpleUUID();
|
||||
if (!StrUtil.isEmpty(fileExt)) {
|
||||
fileName = fileName + "." + fileExt;
|
||||
}
|
||||
return file(fileName);
|
||||
}
|
||||
|
||||
|
||||
@@ -95,20 +96,9 @@ public class FileUploadPath {
|
||||
* @return
|
||||
*/
|
||||
public static FileUploadPath folder(String folder) {
|
||||
FileUploadPath pathBean = new FileUploadPath();
|
||||
|
||||
String tempFolder = folder;
|
||||
if (!StrUtil.startWith(tempFolder, UPLOAD_FOLDER)) {
|
||||
tempFolder = UPLOAD_FOLDER + tempFolder;
|
||||
}
|
||||
if (!StrUtil.endWith(folder, "/")) {
|
||||
tempFolder = tempFolder + "/";
|
||||
}
|
||||
pathBean.setHttpPath(tempFolder);
|
||||
pathBean.setAbsolutePath(String.format("%s/static%s", System.getProperty("user.dir"), tempFolder));
|
||||
FileUtil.mkParentDirs(pathBean.getAbsolutePath());
|
||||
|
||||
return pathBean;
|
||||
FileUploadPath file = file(folder);
|
||||
FileUtil.mkdir(file.getAbsolutePath());
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
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</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.1.2</version>
|
||||
<version>0.3.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-web</artifactId>
|
||||
@@ -58,32 +58,32 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-util</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-db-migration</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-poi</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-annotation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-login</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-message</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -108,8 +108,8 @@ public class ToolController {
|
||||
*/
|
||||
@TokenIgnore
|
||||
@PostMapping("/file/chunk_merge")
|
||||
public ApiResp<String> fileChunkMerge(String fileMd5) {
|
||||
String path = fileUploadService.chunkMerge(fileMd5);
|
||||
public ApiResp<String> fileChunkMerge(String fileMd5, String fileExt) {
|
||||
String path = fileUploadService.chunkMerge(fileMd5, fileExt);
|
||||
return ApiResp.respOK(path);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.tiesheng.core.pojos.dao.CoreLogMessage;
|
||||
import com.tiesheng.core.pojos.dao.CoreLogOperation;
|
||||
import com.tiesheng.core.pojos.dao.CorePlatformUnique;
|
||||
import com.tiesheng.login.config.token.TsTokenConfig;
|
||||
import com.tiesheng.login.config.token.bean.TokenBean;
|
||||
import com.tiesheng.message.pojos.MessageReqResp;
|
||||
import com.tiesheng.message.service.TieshengMessageConfigurer;
|
||||
import com.tiesheng.util.ServletKit;
|
||||
@@ -53,7 +54,7 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
|
||||
*/
|
||||
public void addOperationLog(String title, String subject, Object params) {
|
||||
CoreLogOperation operation = new CoreLogOperation();
|
||||
CurrentWebUser currentWebUser = tieshengWebConfigurer.getCurrentUserName(TsTokenConfig.get().getId());
|
||||
CurrentWebUser currentWebUser = tieshengWebConfigurer.getCurrentUserName(TsTokenConfig.get());
|
||||
operation.setUserId(currentWebUser.getId());
|
||||
operation.setUserName(currentWebUser.getName());
|
||||
operation.setTitle(title);
|
||||
@@ -72,8 +73,9 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
|
||||
* 添加登录日志
|
||||
*
|
||||
* @param platformUnique
|
||||
* @param tokenBean
|
||||
*/
|
||||
public void addLoginLog(CorePlatformUnique platformUnique) {
|
||||
public void addLoginLog(CorePlatformUnique platformUnique, TokenBean tokenBean) {
|
||||
|
||||
HttpServletRequest request = ServletKit.getRequest();
|
||||
String ip = ServletUtil.getClientIP(request);
|
||||
@@ -82,7 +84,7 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
|
||||
login.setUserId(platformUnique.getUserId());
|
||||
login.setPlatform(platformUnique.getPlatform());
|
||||
|
||||
CurrentWebUser currentWebUser = tieshengWebConfigurer.getCurrentUserName(platformUnique.getUserId());
|
||||
CurrentWebUser currentWebUser = tieshengWebConfigurer.getCurrentUserName(tokenBean);
|
||||
login.setUserName(currentWebUser.getName());
|
||||
|
||||
login.setIp(ip);
|
||||
|
||||
@@ -4,8 +4,9 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.tiesheng.core.mapper.CorePlatformUniqueMapper;
|
||||
import com.tiesheng.core.pojos.dao.CorePlatformUnique;
|
||||
import com.tiesheng.login.service.TieshengLoginConfigurer;
|
||||
import com.tiesheng.login.config.token.bean.TokenBean;
|
||||
import com.tiesheng.login.pojos.DoLoginInfo;
|
||||
import com.tiesheng.login.service.TieshengLoginConfigurer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -24,49 +25,32 @@ public class CorePlatformUniqueService extends TsServiceBase<CorePlatformUniqueM
|
||||
CoreLogService coreLogService;
|
||||
|
||||
@Override
|
||||
public TokenBean doLogin(String appId, String uniqueId, String platfrom, String info) {
|
||||
public TokenBean doLogin(DoLoginInfo loginInfo) {
|
||||
|
||||
CorePlatformUnique platformUnique = getByAppAndUnique(appId, uniqueId, platfrom);
|
||||
platformUnique.setInfo(info);
|
||||
TokenBean tokenBean = tieshengWebConfigurer.loginConfigurer().doLogin(platformUnique);
|
||||
CorePlatformUnique platformUnique = getOneByColumn("unique_id", loginInfo.getUnique());
|
||||
if (platformUnique == null) {
|
||||
platformUnique = new CorePlatformUnique();
|
||||
platformUnique.setAppId(loginInfo.getAppId());
|
||||
platformUnique.setPlatform(loginInfo.getPlatform());
|
||||
platformUnique.setUniqueId(loginInfo.getUnique());
|
||||
}
|
||||
platformUnique.setInfo(loginInfo.getInfo());
|
||||
|
||||
TokenBean tokenBean = tieshengWebConfigurer.loginConfigurer().doLogin(platformUnique, loginInfo.getTo());
|
||||
if (tokenBean != null) {
|
||||
platformUnique.setUserId(tokenBean.getId());
|
||||
platformUnique.setIsDeleted(0);
|
||||
saveOrUpdate(platformUnique);
|
||||
|
||||
// 添加登录日志
|
||||
coreLogService.addLoginLog(platformUnique);
|
||||
coreLogService.addLoginLog(platformUnique,tokenBean);
|
||||
}
|
||||
return tokenBean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoginRedirect(TokenBean bean, String extra, HttpServletResponse response) {
|
||||
tieshengWebConfigurer.loginConfigurer().redirect(bean, extra, response);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过appId获取登录对象
|
||||
*
|
||||
* @param appId
|
||||
* @param uniqueId
|
||||
* @return
|
||||
*/
|
||||
private CorePlatformUnique getByAppAndUnique(String appId, String uniqueId, String platform) {
|
||||
QueryWrapper<CorePlatformUnique> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("app_id", appId);
|
||||
queryWrapper.eq("unique_id", uniqueId);
|
||||
queryWrapper.eq("platform", platform);
|
||||
queryWrapper.last("limit 1");
|
||||
CorePlatformUnique platformUnique = getOne(queryWrapper);
|
||||
if (platformUnique == null) {
|
||||
platformUnique = new CorePlatformUnique();
|
||||
platformUnique.setAppId(appId);
|
||||
platformUnique.setUniqueId(uniqueId);
|
||||
platformUnique.setPlatform(platform);
|
||||
}
|
||||
return platformUnique;
|
||||
public void onLoginRedirect(TokenBean bean, String to, String extra, HttpServletResponse response) {
|
||||
tieshengWebConfigurer.loginConfigurer().redirect(bean, to, extra, response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class FileUploadService {
|
||||
String fileType = FileTypeUtil.getType(file.getInputStream(), file.getOriginalFilename());
|
||||
tieshengWebConfigurer.uploadFileCheck(fileType);
|
||||
|
||||
FileUploadPath filePath = FileUploadPath.random();
|
||||
FileUploadPath filePath = FileUploadPath.random(fileType);
|
||||
|
||||
InputStream stream = file.getInputStream();
|
||||
FileUtil.writeFromStream(stream, filePath.getAbsolutePath());
|
||||
@@ -107,7 +107,7 @@ public class FileUploadService {
|
||||
*
|
||||
* @param fileMd5
|
||||
*/
|
||||
public String chunkMerge(String fileMd5) {
|
||||
public String chunkMerge(String fileMd5, String fileExt) {
|
||||
|
||||
// 1,获取文件块的目录
|
||||
FileUploadPath folder = FileUploadPath.folder(fileMd5);
|
||||
@@ -118,7 +118,7 @@ public class FileUploadService {
|
||||
}
|
||||
|
||||
// 3,生成保存文件的路径
|
||||
FileUploadPath uploadPath = FileUploadPath.random();
|
||||
FileUploadPath uploadPath = FileUploadPath.random(fileExt);
|
||||
|
||||
// 4,获取块文件,此列表是已经排好序的列表
|
||||
List<File> chunkFiles = getSortedChunkFiles(new File(folder.getAbsolutePath()));
|
||||
|
||||
@@ -22,7 +22,7 @@ public interface TieshengWebConfigurer {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
CurrentWebUser getCurrentUserName(String userId);
|
||||
CurrentWebUser getCurrentUserName(TokenBean userId);
|
||||
|
||||
|
||||
/**
|
||||
@@ -71,7 +71,7 @@ public interface TieshengWebConfigurer {
|
||||
* @param platformUnique
|
||||
* @return
|
||||
*/
|
||||
TokenBean doLogin(CorePlatformUnique platformUnique);
|
||||
TokenBean doLogin(CorePlatformUnique platformUnique, String to);
|
||||
|
||||
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ public interface TieshengWebConfigurer {
|
||||
* @param extra
|
||||
* @param response
|
||||
*/
|
||||
void redirect(TokenBean bean, String extra, HttpServletResponse response);
|
||||
void redirect(TokenBean bean, String to, String extra, HttpServletResponse response);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
server:
|
||||
compression:
|
||||
enabled: true
|
||||
|
||||
## Spring配置
|
||||
spring:
|
||||
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 20MB
|
||||
web:
|
||||
resources:
|
||||
static-locations: classpath:/static/,file:static/
|
||||
mvc:
|
||||
pathmatch:
|
||||
matching-strategy: ant_path_matcher
|
||||
|
||||
## 日志
|
||||
logging:
|
||||
file:
|
||||
name: logs/tiesheng.log
|
||||
Reference in New Issue
Block a user