publish 2.0.0.rc15

This commit is contained in:
曾文豪
2024-08-05 19:11:17 +08:00
parent a22467d4f1
commit bb38428708
17 changed files with 133 additions and 86 deletions

22
pom.xml
View File

@@ -6,7 +6,7 @@
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.0.rc14</version> <version>2.0.0.rc15</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>springboot-parent</name> <name>springboot-parent</name>
<description>杭州铁晟科技有限公司基础依赖</description> <description>杭州铁晟科技有限公司基础依赖</description>
@@ -58,61 +58,61 @@
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-database</artifactId> <artifactId>springboot-database</artifactId>
<version>2.0.0.rc14</version> <version>2.0.0.rc15</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-login</artifactId> <artifactId>springboot-login</artifactId>
<version>2.0.0.rc14</version> <version>2.0.0.rc15</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-web</artifactId> <artifactId>springboot-web</artifactId>
<version>2.0.0.rc14</version> <version>2.0.0.rc15</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-util</artifactId> <artifactId>springboot-util</artifactId>
<version>2.0.0.rc14</version> <version>2.0.0.rc15</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-platform</artifactId> <artifactId>springboot-platform</artifactId>
<version>2.0.0.rc14</version> <version>2.0.0.rc15</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-message</artifactId> <artifactId>springboot-message</artifactId>
<version>2.0.0.rc14</version> <version>2.0.0.rc15</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-encrypt</artifactId> <artifactId>springboot-encrypt</artifactId>
<version>2.0.0.rc14</version> <version>2.0.0.rc15</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-role</artifactId> <artifactId>springboot-role</artifactId>
<version>2.0.0.rc14</version> <version>2.0.0.rc15</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-annotation</artifactId> <artifactId>springboot-annotation</artifactId>
<version>2.0.0.rc14</version> <version>2.0.0.rc15</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-poi</artifactId> <artifactId>springboot-poi</artifactId>
<version>2.0.0.rc14</version> <version>2.0.0.rc15</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@@ -6,11 +6,11 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.0.rc14</version> <version>2.0.0.rc15</version>
</parent> </parent>
<artifactId>springboot-ademo</artifactId> <artifactId>springboot-ademo</artifactId>
<version>2.0.0.rc14</version> <version>2.0.0.rc15</version>
<properties> <properties>
<maven.compiler.source>8</maven.compiler.source> <maven.compiler.source>8</maven.compiler.source>

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.0.rc14</version> <version>2.0.0.rc15</version>
</parent> </parent>
<artifactId>springboot-annotation</artifactId> <artifactId>springboot-annotation</artifactId>

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.0.rc14</version> <version>2.0.0.rc15</version>
</parent> </parent>
<artifactId>springboot-database</artifactId> <artifactId>springboot-database</artifactId>

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.0.rc14</version> <version>2.0.0.rc15</version>
</parent> </parent>
<artifactId>springboot-encrypt</artifactId> <artifactId>springboot-encrypt</artifactId>

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.0.rc14</version> <version>2.0.0.rc15</version>
</parent> </parent>
<artifactId>springboot-login</artifactId> <artifactId>springboot-login</artifactId>

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.0.rc14</version> <version>2.0.0.rc15</version>
</parent> </parent>
<artifactId>springboot-message</artifactId> <artifactId>springboot-message</artifactId>

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.0.rc14</version> <version>2.0.0.rc15</version>
</parent> </parent>
<artifactId>springboot-platform</artifactId> <artifactId>springboot-platform</artifactId>

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.0.rc14</version> <version>2.0.0.rc15</version>
</parent> </parent>
<artifactId>springboot-poi</artifactId> <artifactId>springboot-poi</artifactId>

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.0.rc14</version> <version>2.0.0.rc15</version>
</parent> </parent>
<artifactId>springboot-role</artifactId> <artifactId>springboot-role</artifactId>

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.0.rc14</version> <version>2.0.0.rc15</version>
</parent> </parent>
<artifactId>springboot-util</artifactId> <artifactId>springboot-util</artifactId>

View File

@@ -109,7 +109,7 @@ public class EncryptConfig {
if (num > 5) { if (num > 5) {
throw new ApiException("登录失败已达6次请10分钟后再试"); throw new ApiException("登录失败已达6次请10分钟后再试");
} }
TsCacheService.of().put(clientIp, String.valueOf(num + 1), 10 * 60 * 1000); TsCacheService.of().put(clientIp, String.valueOf(num + 1), 10 * 60);
throw new ApiException("账号或密码错误"); throw new ApiException("账号或密码错误");
} }
} }

View File

@@ -29,24 +29,24 @@ public class TsCacheService {
tsCacheHandler.put(key, value); tsCacheHandler.put(key, value);
} }
public void put(String key, String value, long timeout) { public void put(String key, String value, long seconds) {
tsCacheHandler.put(key, value, timeout); tsCacheHandler.put(key, value, seconds);
} }
public void putObj(String key, Object value, long timeout) { public void putObj(String key, Object value, long seconds) {
tsCacheHandler.put(key, JSONUtil.toJsonStr(value), timeout); tsCacheHandler.put(key, JSONUtil.toJsonStr(value), seconds);
} }
public String get(String key) { public String get(String key) {
return tsCacheHandler.get(key); return tsCacheHandler.get(key);
} }
public String get(String key, long timeout) { public String get(String key, long seconds) {
return tsCacheHandler.get(key, timeout); return tsCacheHandler.get(key, seconds);
} }
public <T> T getObj(String key, Class<T> tClass, long timeout) { public <T> T getObj(String key, Class<T> tClass, long seconds) {
return JSONUtil.toBean(get(key, timeout), tClass, true); return JSONUtil.toBean(get(key, seconds), tClass, true);
} }
public void remove(String key) { public void remove(String key) {

View File

@@ -3,7 +3,6 @@ package com.tiesheng.util.service.cache;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@@ -23,12 +22,12 @@ public class TsCacheRedisHandler implements TsCacheHandler {
@Override @Override
public void put(String key, String value) { public void put(String key, String value) {
redisTemplate.opsForValue().set(key, value); redisTemplate.opsForValue().set(key, value, 2 * 60, TimeUnit.SECONDS);
} }
@Override @Override
public void put(String key, String value, long timeout) { public void put(String key, String value, long seconds) {
redisTemplate.opsForValue().set(key, value, timeout, TimeUnit.MICROSECONDS); redisTemplate.opsForValue().set(key, value, seconds, TimeUnit.SECONDS);
} }
@@ -38,10 +37,10 @@ public class TsCacheRedisHandler implements TsCacheHandler {
} }
@Override @Override
public String get(String key, long timeout) { public String get(String key, long seconds) {
if (timeout > 0) { if (seconds > 0) {
return redisTemplate.opsForValue().getAndExpire(key, timeout, TimeUnit.MICROSECONDS); return redisTemplate.opsForValue().getAndExpire(key, seconds, TimeUnit.SECONDS);
} else if (timeout == 0) { } else if (seconds == 0) {
return redisTemplate.opsForValue().getAndDelete(key); return redisTemplate.opsForValue().getAndDelete(key);
} }
return redisTemplate.opsForValue().get(key); return redisTemplate.opsForValue().get(key);

View File

@@ -37,8 +37,8 @@ public class TsCacheTimedHandler implements TsCacheHandler {
} }
@Override @Override
public void put(String key, String value, long timeout) { public void put(String key, String value, long seconds) {
getTimedCache().put(key, value, timeout); getTimedCache().put(key, value, seconds * 1000);
} }
@@ -48,11 +48,11 @@ public class TsCacheTimedHandler implements TsCacheHandler {
} }
@Override @Override
public String get(String key, long timeout) { public String get(String key, long seconds) {
String value = getTimedCache().get(key, false); String value = getTimedCache().get(key, false);
if (timeout > 0) { if (seconds > 0) {
getTimedCache().put(key, value, timeout); getTimedCache().put(key, value, seconds * 1000);
} else if (timeout == 0) { } else if (seconds == 0) {
getTimedCache().remove(key); getTimedCache().remove(key);
} }
return value; return value;

View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId> <artifactId>springboot-parent</artifactId>
<version>2.0.0.rc14</version> <version>2.0.0.rc15</version>
</parent> </parent>
<artifactId>springboot-web</artifactId> <artifactId>springboot-web</artifactId>

View File

@@ -1,40 +1,88 @@
//package com.tiesheng.web.service; package com.tiesheng.web.service;
//
//import cn.hutool.json.JSONUtil; import cn.hutool.core.thread.ThreadUtil;
//import cn.hutool.log.LogFactory; import cn.hutool.json.JSONObject;
//import com.tiesheng.util.service.http.OkHttpUtil; import cn.hutool.json.JSONUtil;
//import okhttp3.Interceptor; import com.tiesheng.util.service.http.OkHttpUtil;
//import okhttp3.Request; import com.tiesheng.web.mapper.CoreLogApiMapper;
//import okhttp3.Response; import com.tiesheng.web.pojos.dao.CoreLogApi;
//import org.springframework.stereotype.Component; import okhttp3.*;
// import okio.Buffer;
//import javax.validation.constraints.NotNull; import org.springframework.stereotype.Component;
//
//@Component import javax.annotation.Resource;
//public class LogApiOkHttpInterceptor implements Interceptor { import javax.validation.constraints.NotNull;
//
// @NotNull @Component
// @Override public class LogApiOkHttpInterceptor implements Interceptor {
// public Response intercept(@NotNull Chain chain) {
// @Resource
// Request request = chain.request(); CoreLogApiMapper coreLogApiMapper;
//
// Response response;
// try { @NotNull
// response = chain.proceed(request); @Override
// } catch (Exception e) { public Response intercept(@NotNull Chain chain) {
// response = new Response.Builder()
// .request(request) CoreLogApi logApi = new CoreLogApi();
// .body(OkHttpUtil.ofJsonResponse(JSONUtil.createObj()
// .putOpt("code", -1) Request request = chain.request();
// .putOpt("message", e.getMessage()) logApi.setUrl(request.url().toString());
// .putOpt("exception", e) logApi.setContent(requestBody2String(request));
// .toString()))
// .code(200).build(); Response response;
// } try {
// response = chain.proceed(request);
// LogFactory.get().info("url: {}body: {}", request.url(), response.body().contentType().toString()); ResponseBody peekBody = response.peekBody(Long.MAX_VALUE);
// logApi.setRespBody(peekBody.string());
// return response; logApi.setResult(response.code());
// } peekBody.close();
//} } catch (Exception e) {
logApi.setRespBody(JSONUtil.createObj()
.putOpt("code", -1)
.putOpt("message", e.getMessage())
.putOpt("exception", e)
.toString());
response = new Response.Builder()
.request(request)
.body(OkHttpUtil.ofJsonResponse(logApi.getRespBody()))
.build();
}
ThreadUtil.execute(() -> coreLogApiMapper.insert(logApi));
return response;
}
private String requestBody2String(@NotNull Request request) {
final Request copy = request.newBuilder().build();
RequestBody requestBody = copy.body();
if (requestBody == null) {
return null;
}
if (requestBody instanceof MultipartBody) {
return null;
}
if (requestBody instanceof FormBody) {
JSONObject jsonObject = JSONUtil.createObj();
FormBody formBody = (FormBody) requestBody;
for (int i = 0; i < formBody.size(); i++) {
jsonObject.putOpt(formBody.encodedName(i), formBody.encodedValue(i));
}
return jsonObject.toString();
}
final Buffer buffer = new Buffer();
try {
if (copy.body() != null) {
copy.body().writeTo(buffer);
}
} catch (Exception e) {
return "occurs error when show requestBody";
}
return buffer.readUtf8();
}
}