publish 2.0.0.rc15
This commit is contained in:
22
pom.xml
22
pom.xml
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.0.rc14</version>
|
||||
<version>2.0.0.rc15</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>springboot-parent</name>
|
||||
<description>杭州铁晟科技有限公司基础依赖</description>
|
||||
@@ -58,61 +58,61 @@
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-database</artifactId>
|
||||
<version>2.0.0.rc14</version>
|
||||
<version>2.0.0.rc15</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-login</artifactId>
|
||||
<version>2.0.0.rc14</version>
|
||||
<version>2.0.0.rc15</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-web</artifactId>
|
||||
<version>2.0.0.rc14</version>
|
||||
<version>2.0.0.rc15</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-util</artifactId>
|
||||
<version>2.0.0.rc14</version>
|
||||
<version>2.0.0.rc15</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-platform</artifactId>
|
||||
<version>2.0.0.rc14</version>
|
||||
<version>2.0.0.rc15</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-message</artifactId>
|
||||
<version>2.0.0.rc14</version>
|
||||
<version>2.0.0.rc15</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-encrypt</artifactId>
|
||||
<version>2.0.0.rc14</version>
|
||||
<version>2.0.0.rc15</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-role</artifactId>
|
||||
<version>2.0.0.rc14</version>
|
||||
<version>2.0.0.rc15</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-annotation</artifactId>
|
||||
<version>2.0.0.rc14</version>
|
||||
<version>2.0.0.rc15</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-poi</artifactId>
|
||||
<version>2.0.0.rc14</version>
|
||||
<version>2.0.0.rc15</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.0.rc14</version>
|
||||
<version>2.0.0.rc15</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-ademo</artifactId>
|
||||
<version>2.0.0.rc14</version>
|
||||
<version>2.0.0.rc15</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.0.rc14</version>
|
||||
<version>2.0.0.rc15</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-annotation</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.0.rc14</version>
|
||||
<version>2.0.0.rc15</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-database</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.0.rc14</version>
|
||||
<version>2.0.0.rc15</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-encrypt</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.0.rc14</version>
|
||||
<version>2.0.0.rc15</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-login</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.0.rc14</version>
|
||||
<version>2.0.0.rc15</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-message</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.0.rc14</version>
|
||||
<version>2.0.0.rc15</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-platform</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.0.rc14</version>
|
||||
<version>2.0.0.rc15</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-poi</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.0.rc14</version>
|
||||
<version>2.0.0.rc15</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-role</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.0.rc14</version>
|
||||
<version>2.0.0.rc15</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-util</artifactId>
|
||||
|
||||
@@ -109,7 +109,7 @@ public class EncryptConfig {
|
||||
if (num > 5) {
|
||||
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("账号或密码错误");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,24 +29,24 @@ public class TsCacheService {
|
||||
tsCacheHandler.put(key, value);
|
||||
}
|
||||
|
||||
public void put(String key, String value, long timeout) {
|
||||
tsCacheHandler.put(key, value, timeout);
|
||||
public void put(String key, String value, long seconds) {
|
||||
tsCacheHandler.put(key, value, seconds);
|
||||
}
|
||||
|
||||
public void putObj(String key, Object value, long timeout) {
|
||||
tsCacheHandler.put(key, JSONUtil.toJsonStr(value), timeout);
|
||||
public void putObj(String key, Object value, long seconds) {
|
||||
tsCacheHandler.put(key, JSONUtil.toJsonStr(value), seconds);
|
||||
}
|
||||
|
||||
public String get(String key) {
|
||||
return tsCacheHandler.get(key);
|
||||
}
|
||||
|
||||
public String get(String key, long timeout) {
|
||||
return tsCacheHandler.get(key, timeout);
|
||||
public String get(String key, long seconds) {
|
||||
return tsCacheHandler.get(key, seconds);
|
||||
}
|
||||
|
||||
public <T> T getObj(String key, Class<T> tClass, long timeout) {
|
||||
return JSONUtil.toBean(get(key, timeout), tClass, true);
|
||||
public <T> T getObj(String key, Class<T> tClass, long seconds) {
|
||||
return JSONUtil.toBean(get(key, seconds), tClass, true);
|
||||
}
|
||||
|
||||
public void remove(String key) {
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.tiesheng.util.service.cache;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -23,12 +22,12 @@ public class TsCacheRedisHandler implements TsCacheHandler {
|
||||
|
||||
@Override
|
||||
public void put(String key, String value) {
|
||||
redisTemplate.opsForValue().set(key, value);
|
||||
redisTemplate.opsForValue().set(key, value, 2 * 60, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(String key, String value, long timeout) {
|
||||
redisTemplate.opsForValue().set(key, value, timeout, TimeUnit.MICROSECONDS);
|
||||
public void put(String key, String value, long seconds) {
|
||||
redisTemplate.opsForValue().set(key, value, seconds, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,10 +37,10 @@ public class TsCacheRedisHandler implements TsCacheHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(String key, long timeout) {
|
||||
if (timeout > 0) {
|
||||
return redisTemplate.opsForValue().getAndExpire(key, timeout, TimeUnit.MICROSECONDS);
|
||||
} else if (timeout == 0) {
|
||||
public String get(String key, long seconds) {
|
||||
if (seconds > 0) {
|
||||
return redisTemplate.opsForValue().getAndExpire(key, seconds, TimeUnit.SECONDS);
|
||||
} else if (seconds == 0) {
|
||||
return redisTemplate.opsForValue().getAndDelete(key);
|
||||
}
|
||||
return redisTemplate.opsForValue().get(key);
|
||||
|
||||
@@ -37,8 +37,8 @@ public class TsCacheTimedHandler implements TsCacheHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(String key, String value, long timeout) {
|
||||
getTimedCache().put(key, value, timeout);
|
||||
public void put(String key, String value, long seconds) {
|
||||
getTimedCache().put(key, value, seconds * 1000);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,11 +48,11 @@ public class TsCacheTimedHandler implements TsCacheHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(String key, long timeout) {
|
||||
public String get(String key, long seconds) {
|
||||
String value = getTimedCache().get(key, false);
|
||||
if (timeout > 0) {
|
||||
getTimedCache().put(key, value, timeout);
|
||||
} else if (timeout == 0) {
|
||||
if (seconds > 0) {
|
||||
getTimedCache().put(key, value, seconds * 1000);
|
||||
} else if (seconds == 0) {
|
||||
getTimedCache().remove(key);
|
||||
}
|
||||
return value;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.0.rc14</version>
|
||||
<version>2.0.0.rc15</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-web</artifactId>
|
||||
|
||||
@@ -1,40 +1,88 @@
|
||||
//package com.tiesheng.web.service;
|
||||
//
|
||||
//import cn.hutool.json.JSONUtil;
|
||||
//import cn.hutool.log.LogFactory;
|
||||
//import com.tiesheng.util.service.http.OkHttpUtil;
|
||||
//import okhttp3.Interceptor;
|
||||
//import okhttp3.Request;
|
||||
//import okhttp3.Response;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import javax.validation.constraints.NotNull;
|
||||
//
|
||||
//@Component
|
||||
//public class LogApiOkHttpInterceptor implements Interceptor {
|
||||
//
|
||||
// @NotNull
|
||||
// @Override
|
||||
// public Response intercept(@NotNull Chain chain) {
|
||||
//
|
||||
// Request request = chain.request();
|
||||
//
|
||||
// Response response;
|
||||
// try {
|
||||
// response = chain.proceed(request);
|
||||
// } catch (Exception e) {
|
||||
// response = new Response.Builder()
|
||||
// .request(request)
|
||||
// .body(OkHttpUtil.ofJsonResponse(JSONUtil.createObj()
|
||||
// .putOpt("code", -1)
|
||||
// .putOpt("message", e.getMessage())
|
||||
// .putOpt("exception", e)
|
||||
// .toString()))
|
||||
// .code(200).build();
|
||||
// }
|
||||
//
|
||||
// LogFactory.get().info("url: {},body: {}", request.url(), response.body().contentType().toString());
|
||||
//
|
||||
// return response;
|
||||
// }
|
||||
//}
|
||||
package com.tiesheng.web.service;
|
||||
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.tiesheng.util.service.http.OkHttpUtil;
|
||||
import com.tiesheng.web.mapper.CoreLogApiMapper;
|
||||
import com.tiesheng.web.pojos.dao.CoreLogApi;
|
||||
import okhttp3.*;
|
||||
import okio.Buffer;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Component
|
||||
public class LogApiOkHttpInterceptor implements Interceptor {
|
||||
|
||||
@Resource
|
||||
CoreLogApiMapper coreLogApiMapper;
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Response intercept(@NotNull Chain chain) {
|
||||
|
||||
CoreLogApi logApi = new CoreLogApi();
|
||||
|
||||
Request request = chain.request();
|
||||
logApi.setUrl(request.url().toString());
|
||||
logApi.setContent(requestBody2String(request));
|
||||
|
||||
Response response;
|
||||
try {
|
||||
response = chain.proceed(request);
|
||||
ResponseBody peekBody = response.peekBody(Long.MAX_VALUE);
|
||||
logApi.setRespBody(peekBody.string());
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user