Compare commits

...

34 Commits
0.1.3 ... 0.3.0

Author SHA1 Message Date
曾文豪
8854225934 publish 0.3.0 2023-02-08 19:22:17 +08:00
曾文豪
5ad35cefda publish 0.3.0 2023-02-08 19:20:45 +08:00
曾文豪
1921efa27b perf:移除插件代码 2023-02-08 19:19:00 +08:00
曾文豪
2e9de7ee64 publish 0.2.6 2023-02-08 13:30:22 +08:00
曾文豪
e352927396 publish 0.2.5 2023-02-08 13:19:50 +08:00
曾文豪
51b26c077d perf:更新新的脚本 2023-02-08 13:18:58 +08:00
曾文豪
2c5f55a876 publish 0.2.4 2023-02-07 10:04:06 +08:00
曾文豪
c52f7f5c77 perf:token有效期调整 2023-02-07 10:00:21 +08:00
曾文豪
7f46d2d371 perf:initScript增加执行成功的log 2023-02-07 09:40:15 +08:00
曾文豪
34d8201641 perf:调整ipdb的默认存放位置 2023-02-07 09:39:16 +08:00
曾文豪
92e1c1d9ef perf:文件路径生成调整 2023-02-07 09:32:24 +08:00
曾文豪
ee3748c361 perf:调整项目配置 2023-02-07 08:59:42 +08:00
曾文豪
439947caad publish 0.2.3 2023-02-01 16:43:04 +08:00
曾文豪
17706e8065 perf:删除无效配置 2023-02-01 12:08:15 +08:00
曾文豪
8853e3170d perf:删除无效配置 2023-02-01 12:07:49 +08:00
曾文豪
222f37afc1 publish 0.2.2 2023-02-01 12:05:20 +08:00
曾文豪
f8bc11d456 publish 0.2.1 2023-02-01 11:59:53 +08:00
曾文豪
1ea7fa968b publish 0.2.0 2023-02-01 10:18:04 +08:00
曾文豪
c892fec45b publish 0.2.0 2023-02-01 10:13:32 +08:00
曾文豪
7e94ea54a8 feat:增加launcher-maven-plugin 2023-02-01 10:10:43 +08:00
曾文豪
d006788c90 publish 0.1.9 2023-01-31 16:10:20 +08:00
曾文豪
c63a6769ad publish 0.1.8 2023-01-31 15:42:27 +08:00
曾文豪
156cce877b publish 0.1.8-pre 2023-01-31 14:47:25 +08:00
曾文豪
49d88ee08f publish 0.1.8-pre 2023-01-31 14:39:07 +08:00
曾文豪
88777898c4 feat:增加项目启动脚本 2023-01-31 14:27:29 +08:00
曾文豪
3f59d00092 publish 0.1.7 2023-01-12 11:58:44 +08:00
曾文豪
2e8969f249 perf:文件上传保留后缀 2023-01-12 11:58:23 +08:00
曾文豪
ebb99ced78 perf:增加登录例子 2023-01-11 16:43:33 +08:00
曾文豪
e862cdbf43 publish 0.1.6 2023-01-11 16:32:29 +08:00
曾文豪
d6faed4f68 perf:调整授权登录 2023-01-11 16:32:16 +08:00
曾文豪
ec4b0cbb1e publish 0.1.5 2023-01-11 16:25:38 +08:00
曾文豪
30fd68d430 perf:调整授权登录 2023-01-11 16:25:27 +08:00
曾文豪
ec865471cb publish 0.1.4 2023-01-11 15:46:14 +08:00
曾文豪
7d454e9c62 perf:调整授权登录 2023-01-11 15:46:02 +08:00
29 changed files with 266 additions and 182 deletions

2
.gitignore vendored
View File

@@ -4,4 +4,4 @@ rebel.xml
/.idea/
*.iml
/static/
/ipdb/
/config/

78
pom.xml
View 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>
<groupId>com.tiesheng</groupId>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>0.1.3</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.3</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.3</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.3</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.3</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.3</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.3</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.3</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.3</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.3</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>

View 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.3</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>

View File

@@ -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);
}
}
};
}
}

View File

@@ -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());
}

View 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: 阿里云短信测试

View File

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

View 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.3</version>
<version>0.3.0</version>
</parent>
<artifactId>springboot-annotation</artifactId>

View 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.3</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>

View 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.3</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>

View 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.3</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>

View File

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

View File

@@ -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();
}

View File

@@ -1,10 +1,9 @@
package com.tiesheng.login.pojos;
public class CodeExtraDTO {
public class CodeExtraDTO extends LoginToInfo {
private String code;
private String extra;
private String to;
///////////////////////////////////////////////////////////////////////////
// setter\getter
@@ -26,11 +25,4 @@ public class CodeExtraDTO {
this.extra = extra;
}
public String getTo() {
return to;
}
public void setTo(String to) {
this.to = to;
}
}

View File

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

View File

@@ -2,10 +2,9 @@ package com.tiesheng.login.pojos;
import cn.hutool.core.util.StrUtil;
public class UniqueIndexDTO {
public class UniqueIndexDTO extends LoginToInfo {
private String no;
private String to;
private String extra;
private String info;
@@ -21,14 +20,6 @@ public class UniqueIndexDTO {
this.no = no;
}
public String getTo() {
return to;
}
public void setTo(String to) {
this.to = to;
}
public String getExtra() {
if (StrUtil.isEmpty(extra)) {
extra = "";

View 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.3</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>

View 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.3</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>

View 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.3</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>

View 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.3</version>
<version>0.3.0</version>
</parent>
<artifactId>springboot-util</artifactId>

View File

@@ -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";
///////////////////////////////////////////////////////////////////////////
// 逻辑方法

View File

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

View 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.3</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>

View File

@@ -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);
}

View File

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

View File

@@ -43,7 +43,7 @@ public class CorePlatformUniqueService extends TsServiceBase<CorePlatformUniqueM
saveOrUpdate(platformUnique);
// 添加登录日志
coreLogService.addLoginLog(platformUnique);
coreLogService.addLoginLog(platformUnique,tokenBean);
}
return tokenBean;
}

View File

@@ -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()));

View File

@@ -22,7 +22,7 @@ public interface TieshengWebConfigurer {
*
* @return
*/
CurrentWebUser getCurrentUserName(String userId);
CurrentWebUser getCurrentUserName(TokenBean userId);
/**

View File

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