Compare commits

..

28 Commits

Author SHA1 Message Date
曾文豪
6dd4e19e39 publish 1.0.16 2023-12-06 16:43:31 +08:00
曾文豪
4373ec7c0e publish 1.0.15 2023-11-20 16:23:18 +08:00
曾文豪
5cc135d8e2 fix:兼容windows服务器的路径问题 2023-11-20 16:22:49 +08:00
曾文豪
69a9681b48 publish 1.0.14 2023-08-22 09:29:12 +08:00
曾文豪
6c39dc24bd chore:更新ci 2023-08-22 09:28:06 +08:00
曾文豪
952341918a publish 1.0.13 2023-08-21 15:29:18 +08:00
曾文豪
5dde3e3e9f publish 1.1.0 2023-08-21 15:21:54 +08:00
曾文豪
c5c7afd7f6 feat:globalConfig增加ext属性 2023-08-21 15:11:47 +08:00
曾文豪
ceb13dc78d perf:删除其他代码 2023-08-14 15:48:55 +08:00
曾文豪
0fabc7aae9 perf:优化部分代码 2023-08-14 15:43:48 +08:00
曾文豪
28a2fa0262 perf:增加网络请求超时、重定向的配置 2023-08-10 18:10:49 +08:00
曾文豪
cc3ab52885 perf:过程中保存错误日志,而不是在最后保存,方式错误日志丢失 2023-08-10 18:07:27 +08:00
曾文豪
027587ae02 perf:更新数据库对比插件 2023-08-10 17:55:09 +08:00
曾文豪
353851a0aa perf:/operation/page接口需要鉴权 2023-07-19 10:39:45 +08:00
曾文豪
1db6d88e4e feat(web):增加DaoBase的常量 2023-07-11 10:05:53 +08:00
曾文豪
7e69138ef7 feat(web):增加DaoBase的常量 2023-07-11 10:05:27 +08:00
曾文豪
ea211b1bfc chore:更新日志 2023-07-11 09:03:16 +08:00
曾文豪
101270e881 perf(web):操作日志优化
1,不再返回params字段
2,params字段有text改为longtext
2023-07-11 08:58:48 +08:00
曾文豪
a658298363 perf:优化slat长度的校验 2023-07-10 09:44:07 +08:00
曾文豪
65beecc330 docs: 文档调整 2023-07-05 14:14:33 +08:00
曾文豪
ea24bf3479 perf(encrypt):加解密调整 2023-07-05 14:11:01 +08:00
曾文豪
90e504e7fd fix:验签接口调整 2023-07-05 13:58:01 +08:00
曾文豪
5db42f5bc8 publish 1.0.12 2023-07-05 13:55:14 +08:00
曾文豪
37d84e2f36 docs: 文档调整 2023-06-30 10:24:13 +08:00
曾文豪
f59d56be9e docs: 文档调整 2023-06-28 13:04:11 +08:00
曾文豪
7f4871fe19 publish 1.0.10 2023-06-28 13:03:03 +08:00
曾文豪
34e3cb2f09 docs: 文档调整 2023-06-14 09:44:11 +08:00
曾文豪
7c1abb9b97 docs: 文档调整 2023-06-14 09:39:38 +08:00
40 changed files with 224 additions and 152 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -1,23 +1,10 @@
stages:
- deploy
- package
build-jar:
stage: deploy
tags:
- hzkepai
rules:
- if: $CI_COMMIT_BRANCH == "master"
script:
- mvn clean package -Dmaven.test.skip=true
- systemctl stop tieshengboot-ademo
- cp springboot-ademo/target/*.jar /usr/local/nginx/html/demo.tmp.kepai365.ltd/
- systemctl start tieshengboot-ademo
deploy-jar:
stage: deploy
tags:
- hzkepai
- zengos
rules:
- if: $CI_COMMIT_TAG
script:

View File

@@ -1,58 +1,48 @@
## 1.0.9
## 1.1.0
## 新增
- featglobalConfig增加ext属性。
- feat增加网络请求超时、重定向的配置。
- perf更新数据库对比插件。
- feat(web)增加DaoBase的常量。
- perf(web):操作日志优化。
> 登录接口,增加验签步骤,可通过**validLoginSign**属性开启或关闭(默认)。
## 修复
## 1.0.12
> 修复微信、钉钉授权跳转地址错误的bug
- perf(encrypt):开启关闭加解密移动到**yaml**中配置,移除**EnableEncryptConfig**注解。
- feat(login):登录接口增加验签步骤,可通过**validLoginSign**属性开启或关闭(默认)。
- perf(login):可重写**onSignError**方法自定义验签错误的跳转。
- fix(login)修复微信、钉钉授权跳转地址错误的bug
## 1.0.7
## 新增
> feat(web): 增加uploadFileCustomize方法允许自定义文件存放情况
> feat(database): 增加db/data目录存放初始化数据的sql
## 优化
> perf(login): 增加默认值防止token解析异常
- feat(web): 增加uploadFileCustomize方法允许自定义文件存放情况
- feat(database): 增加db/data目录存放初始化数据的sql
- perf(login): 增加默认值防止token解析异常
## 1.0.6
### 新增
> 1新增 **OperationIgnore** 注解,可以指定接口忽略操作日志的收集。
> 2**OperationLog** 增加 desensitize 属性,用来脱敏指定的字段。
- feat(web):新增 **OperationIgnore** 注解,可以指定接口忽略操作日志的收集。
- feat(web)**OperationLog** 增加 desensitize 属性,用来脱敏指定的字段。
## 1.0.2
### 调整
> 1增加数据库定时备份
> 2增加过期备份的删除操作默认过期时间为7天
> 3调整阿里云短信类方便扩展其他方法。
> 4消息发送接口该body类型为 **JSONObject**
> 5调整消息发送接口和方法不兼容旧版本
- feat(database):增加数据库定时备份;
- feat(database)增加过期备份的删除操作默认过期时间为7天
- perf(message):调整阿里云短信类,方便扩展其他方法。
- perf(message)消息发送接口该body类型为 **JSONObject**
- perf(message):调整消息发送接口和方法(不兼容旧版本)
## 1.0.1
### 调整
fastjson增加配置 **DisableCircularReferenceDetect**,禁用相同的对象写成引用的形式。
- perf(web)fastjson增加配置 **DisableCircularReferenceDetect**,禁用相同的对象写成引用的形式。
## 1.0.0
### 升级
> 1hutool依赖升级:5.8.11 -> 5.8.16
> 2fastjson依赖升级1.2.78 -> 1.2.83
> 3mybatis-plus依赖升级3.5.1 -> 3.5.3
### 调整
> 1**TieshengWebConfigurer** 增加 **configSystemCheck** 方法,可根据情况校验系统配置参数。
- perfhutool依赖升级5.8.11 -> 5.8.16
- perffastjson依赖升级1.2.78 -> 1.2.83
- perfmybatis-plus依赖升级:3.5.1 -> 3.5.3
- perf**TieshengWebConfigurer** 增加 **configSystemCheck** 方法,可根据情况校验系统配置参数。
从该版本开始,仓库地址改为:

22
pom.xml
View File

@@ -6,7 +6,7 @@
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.9</version>
<version>1.0.16</version>
<packaging>pom</packaging>
<name>springboot-parent</name>
<description>杭州铁晟科技有限公司基础依赖</description>
@@ -57,55 +57,55 @@
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-database</artifactId>
<version>1.0.9</version>
<version>1.0.16</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-login</artifactId>
<version>1.0.9</version>
<version>1.0.16</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-web</artifactId>
<version>1.0.9</version>
<version>1.0.16</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-util</artifactId>
<version>1.0.9</version>
<version>1.0.16</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-platform</artifactId>
<version>1.0.9</version>
<version>1.0.16</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-message</artifactId>
<version>1.0.9</version>
<version>1.0.16</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-encrypt</artifactId>
<version>1.0.9</version>
<version>1.0.16</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-annotation</artifactId>
<version>1.0.9</version>
<version>1.0.16</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-poi</artifactId>
<version>1.0.9</version>
<version>1.0.16</version>
</dependency>
<dependency>
@@ -136,7 +136,7 @@
<plugin>
<groupId>com.tiesheng.springboot-plugin</groupId>
<artifactId>tiesheng-maven-plugin</artifactId>
<version>0.0.6</version>
<version>1.0.0</version>
<executions>
<execution>
<goals>

View File

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

View File

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

View File

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

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.9</version>
<version>1.0.16</version>
</parent>
<artifactId>springboot-annotation</artifactId>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.9</version>
<version>1.0.16</version>
</parent>
<artifactId>springboot-database</artifactId>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.9</version>
<version>1.0.16</version>
</parent>
<artifactId>springboot-encrypt</artifactId>

View File

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

View File

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

View File

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

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.9</version>
<version>1.0.16</version>
</parent>
<artifactId>springboot-login</artifactId>

View File

@@ -21,7 +21,6 @@ import com.tiesheng.platform.config.wxmp.PlatformWxmpConfig;
import com.tiesheng.platform.config.wxmp.bean.WxConfigBean;
import com.tiesheng.platform.config.wxmp.bean.WxJsapiSignature;
import com.tiesheng.platform.config.wxmp.bean.WxUserInfo;
import com.tiesheng.util.ServletKit;
import com.tiesheng.util.config.GlobalConfig;
import com.tiesheng.util.exception.ApiException;
import com.tiesheng.util.pojos.ApiResp;
@@ -65,7 +64,7 @@ public class LoginController {
@OperationIgnore
public void uniqueIndex(UniqueIndexDTO dto, HttpServletResponse response) {
if (tsTokenConfig.isValidLoginSign() && !dto.validSign()) {
ServletKit.write(response, "404", "text");
tieshengLoginConfigurer.onSignError(response);
return;
}
@@ -114,6 +113,7 @@ public class LoginController {
map.put("corpId", platformDingConfig.getConfigBean(service).getCorpId());
map.put("service", service);
map.put("extra", extra);
map.put("context", globalConfig.getContextPath());
String query = URLUtil.buildQuery(map, Charset.defaultCharset());
String configUrl = globalConfig.buildPath("/ding/index.html?" + query);
try {

View File

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

View File

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

View File

@@ -24,10 +24,10 @@
corpId: getQueryString("corpId"),
onSuccess: function (result) {
let search = window.location.search + "&code=" + result.code;
window.location.href = "/login/ding/oauth2/" + getQueryString("service") + search;
window.location.replace(getQueryString("context") + "/login/ding/oauth2/" + getQueryString("service") + search);
},
onFail: function (err) {
window.location.href = "./error.html?message=" + JSON.stringify(err);
window.location.replace("./error.html?message=" + JSON.stringify(err));
}
})

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.9</version>
<version>1.0.16</version>
</parent>
<artifactId>springboot-message</artifactId>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.9</version>
<version>1.0.16</version>
</parent>
<artifactId>springboot-platform</artifactId>

View File

@@ -5,6 +5,7 @@ import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
@@ -125,9 +126,11 @@ public class PlatformDingConfig {
* @see <a href="https://open.dingtalk.com/document/isvapp-server/obtain-the-userid-of-a-user-by-using-the-log-free"></a>
*/
public String getUserIdByCode(String service, String code) {
String response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/user/getuserinfo?access_token=" + getAccessToken(service))
.body(JSONUtil.createObj().putOpt("code", code).toString()).execute().body();
return JSONUtil.parseObj(response).getJSONObject("result").getStr("userid");
HttpRequest request = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/user/getuserinfo?access_token=" + getAccessToken(service))
.body(JSONUtil.createObj().putOpt("code", code).toString());
try (HttpResponse response = request.execute()) {
return JSONUtil.parseObj(response.body()).getJSONObject("result").getStr("userid");
}
}
@@ -141,15 +144,16 @@ public class PlatformDingConfig {
*/
public DingUserInfo topapiV2UserGet(String service, String ddUserId) {
DingConfigBean dingConfigBean = getConfigBean(service);
String response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/user/get?access_token=" + getAccessToken(service))
.body(JSONUtil.createObj().putOpt("userid", ddUserId).toString()).execute().body();
JSONObject resultJson = JSONUtil.parseObj(response).getJSONObject("result");
DingUserInfo userInfo = JSONUtil.toBean(resultJson, DingUserInfo.class);
// 设置一下job_number
userInfo.setJobNumber(resultJson.getStr("job_number"));
userInfo.setAppId(dingConfigBean.getAppKey());
return userInfo;
try (HttpResponse response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/user/get?access_token="
+ getAccessToken(service))
.body(JSONUtil.createObj().putOpt("userid", ddUserId).toString()).execute()) {
JSONObject resultJson = JSONUtil.parseObj(response.body()).getJSONObject("result");
DingUserInfo userInfo = JSONUtil.toBean(resultJson, DingUserInfo.class);
// 设置一下job_number
userInfo.setJobNumber(resultJson.getStr("job_number"));
userInfo.setAppId(dingConfigBean.getAppKey());
return userInfo;
}
}
/**
@@ -164,15 +168,16 @@ public class PlatformDingConfig {
if (StrUtil.isEmpty(token)) {
return new ArrayList<>();
}
String response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/department/listsub?access_token=" + token)
.body(JSONUtil.createObj().putOpt("dept_id", deptId).toString()).execute().body();
DingResponse<List<DingDeptVo>> result = JSONUtil.toBean(response, new TypeReference<DingResponse<List<DingDeptVo>>>() {
}.getType(), true);
try (HttpResponse response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/department/listsub?access_token=" + token)
.body(JSONUtil.createObj().putOpt("dept_id", deptId).toString()).execute()) {
DingResponse<List<DingDeptVo>> result = JSONUtil.toBean(response.body(), new TypeReference<DingResponse<List<DingDeptVo>>>() {
}.getType(), true);
if (!result.isOk()) {
result.setResult(new ArrayList<>());
if (!result.isOk()) {
result.setResult(new ArrayList<>());
}
return result.getResult();
}
return result.getResult();
}
@@ -187,16 +192,16 @@ public class PlatformDingConfig {
if (StrUtil.isEmpty(token)) {
return DingUserListVo.fail();
}
String response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/user/list?access_token=" + token)
try (HttpResponse response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/user/list?access_token=" + token)
.body(JSONUtil.createObj().putOpt("dept_id", deptId).putOpt("cursor", cursor).putOpt("size", 100).toString())
.execute().body();
DingResponse<DingUserListVo> result = JSONUtil.toBean(response, new TypeReference<DingResponse<DingUserListVo>>() {
}.getType(), true);
if (!result.isOk()) {
result.setResult(DingUserListVo.fail());
.execute()) {
DingResponse<DingUserListVo> result = JSONUtil.toBean(response.body(), new TypeReference<DingResponse<DingUserListVo>>() {
}.getType(), true);
if (!result.isOk()) {
result.setResult(DingUserListVo.fail());
}
return result.getResult();
}
return result.getResult();
}
/**

View File

@@ -3,6 +3,7 @@ package com.tiesheng.platform.config.wxmini;
import cn.hutool.core.map.MapUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.tiesheng.platform.config.wxmp.bean.WxConfigBean;
@@ -50,12 +51,13 @@ public class PlatformWxminiConfig {
*/
public String jscode2session(String service, String code) {
WxConfigBean configBean = getConfigBean(service);
String body = HttpRequest.get("https://api.weixin.qq.com/sns/jscode2session"
try (HttpResponse response = HttpRequest.get("https://api.weixin.qq.com/sns/jscode2session"
+ "?appid=" + configBean.getAppId()
+ "&secret=" + configBean.getAppSecret()
+ "&js_code=" + code + "&grant_type=authorization_code").execute().body();
JSONObject object = JSONUtil.parseObj(body);
return object.getStr("openid");
+ "&js_code=" + code + "&grant_type=authorization_code").execute()) {
JSONObject object = JSONUtil.parseObj(response.body());
return object.getStr("openid");
}
}
/**
@@ -65,11 +67,12 @@ public class PlatformWxminiConfig {
*/
public String getAccessToken(String service) {
WxConfigBean configBean = getConfigBean(service);
String body = HttpRequest.get("https://api.weixin.qq.com/cgi-bin/token"
try (HttpResponse response = HttpRequest.get("https://api.weixin.qq.com/cgi-bin/token"
+ "?grant_type=client_credential&appid=" + configBean.getAppId()
+ "&secret=" + configBean.getAppSecret()).execute().body();
JSONObject object = JSONUtil.parseObj(body);
return object.getStr("access_token");
+ "&secret=" + configBean.getAppSecret()).execute()) {
JSONObject object = JSONUtil.parseObj(response.body());
return object.getStr("access_token");
}
}

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.9</version>
<version>1.0.16</version>
</parent>
<artifactId>springboot-poi</artifactId>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.9</version>
<version>1.0.16</version>
</parent>
<artifactId>springboot-util</artifactId>

View File

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

View File

@@ -30,6 +30,7 @@ public class EncryptConfig {
*/
private String key = "WmdUzPJXbngVNiaSsQrihg==";
private Integer saltSize = 8;
private boolean body = false;
public EncryptConfig() {
sm4 = SmUtil.sm4(Base64.decode(getKey()));
@@ -72,7 +73,7 @@ public class EncryptConfig {
* @return
*/
public String passwdCreate(String inputPasswd, String salt) {
if (StrUtil.isEmpty(salt)) {
if (StrUtil.isEmpty(salt) || StrUtil.length(salt) != getSaltSize()) {
salt = RandomUtil.randomString(saltSize);
}
if (!passwdComplexity(inputPasswd)) {
@@ -133,4 +134,12 @@ public class EncryptConfig {
public void setSaltSize(Integer saltSize) {
this.saltSize = saltSize;
}
public boolean isBody() {
return body;
}
public void setBody(boolean body) {
this.body = body;
}
}

View File

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

View File

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

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.9</version>
<version>1.0.16</version>
</parent>
<artifactId>springboot-web</artifactId>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -8,6 +8,7 @@ import com.tiesheng.login.pojos.DoLoginInfo;
import com.tiesheng.login.service.TieshengLoginConfigurer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
@@ -23,6 +24,7 @@ public class CorePlatformUniqueService extends TsServiceBase<CorePlatformUniqueM
CoreLogService coreLogService;
@Override
@Transactional(rollbackFor = Exception.class)
public TokenBean doLogin(DoLoginInfo loginInfo) {
CorePlatformUnique platformUnique = getOneByColumn("unique_id", loginInfo.getUnique());
@@ -48,6 +50,10 @@ public class CorePlatformUniqueService extends TsServiceBase<CorePlatformUniqueM
tieshengWebConfigurer.redirect(bean, to, extra, response);
}
@Override
public void onSignError(HttpServletResponse response) {
tieshengWebConfigurer.onSignError(response);
}
/**
* 更新用户id

View File

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

View File

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

View File

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

View File

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