Compare commits

...

12 Commits

Author SHA1 Message Date
曾文豪
6aaf91a755 publish 2.0.12
All checks were successful
/ local-deploy (push) Successful in 32s
2024-10-10 15:52:53 +08:00
曾文豪
f1ac7d6886 publish 2.0.12 2024-10-10 15:51:40 +08:00
曾文豪
2f07f9eb66 publish 2.0.11 2024-09-30 11:46:43 +08:00
曾文豪
919cd47623 publish 2.0.10 2024-09-23 15:50:36 +08:00
曾文豪
eb1c20b033 feat:授权增加一个备注字段 2024-09-19 14:13:13 +08:00
曾文豪
c1559e96be publish 2.0.9 2024-09-18 23:09:53 +08:00
曾文豪
9ef7d2d4a2 publish 2.0.8 2024-09-18 22:59:28 +08:00
曾文豪
b90e92f4cb perf: token兼容旧版本,旧版本使用的是10位数的秒作为数据 2024-09-18 22:59:10 +08:00
曾文豪
cb816d0ff0 publish 2.0.7 2024-09-18 17:27:45 +08:00
曾文豪
0470ca0b9a perf:空指针调整 2024-09-18 17:25:19 +08:00
曾文豪
d38077b0f8 perf:代码调整 2024-09-18 17:13:40 +08:00
曾文豪
2621c6dedc perf:可以不实现TsAuthorityHandler类 2024-09-18 16:47:29 +08:00
36 changed files with 210 additions and 89 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -0,0 +1,25 @@
## 工作流触发时机
on:
push:
tags:
- '*'
jobs:
## 任务名称
local-deploy:
## 任务执行的服务器
runs-on: tiesheng-local
## 任务步骤
steps:
## 检出代码(固定配置)
- name: Check out repository code
uses: https://git.tieshengkeji.com/actions/checkout@v4
## maven打包
- name: Maven deploy
run: |
mvn deploy

View File

@@ -1,3 +1,8 @@
## 2.0.12
- 调整OkHttp日志
## 2.0.0.rc46
现在导入导出都接入底层流程,无需新增接口,只需要实现接口即可。

25
pom.xml
View File

@@ -6,7 +6,7 @@
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.6</version>
<version>2.0.12</version>
<packaging>pom</packaging>
<name>springboot-parent</name>
<description>杭州铁晟科技有限公司基础依赖</description>
@@ -58,49 +58,49 @@
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-database</artifactId>
<version>2.0.6</version>
<version>2.0.12</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-login</artifactId>
<version>2.0.6</version>
<version>2.0.12</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-web</artifactId>
<version>2.0.6</version>
<version>2.0.12</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-util</artifactId>
<version>2.0.6</version>
<version>2.0.12</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-platform</artifactId>
<version>2.0.6</version>
<version>2.0.12</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-message</artifactId>
<version>2.0.6</version>
<version>2.0.12</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-role</artifactId>
<version>2.0.6</version>
<version>2.0.12</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-annotation</artifactId>
<version>2.0.6</version>
<version>2.0.12</version>
</dependency>
<dependency>
@@ -125,6 +125,13 @@
</pluginRepository>
</pluginRepositories>
<distributionManagement>
<repository>
<id>gitea</id>
<url>https://git.tieshengkeji.com/api/packages/tieshengkeji/maven</url>
</repository>
</distributionManagement>
<build>
<pluginManagement>
<plugins>

31
qodana.yaml Normal file
View File

@@ -0,0 +1,31 @@
#-------------------------------------------------------------------------------#
# Qodana analysis is configured by qodana.yaml file #
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
#-------------------------------------------------------------------------------#
version: "1.0"
#Specify inspection profile for code analysis
profile:
name: qodana.starter
#Enable inspections
#include:
# - name: <SomeEnabledInspectionId>
#Disable inspections
#exclude:
# - name: <SomeDisabledInspectionId>
# paths:
# - <path/where/not/run/inspection>
projectJDK: 17 #(Applied in CI/CD pipeline)
#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
#bootstrap: sh ./prepare-qodana.sh
#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
#plugins:
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)
#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
linter: jetbrains/qodana-jvm:latest

View File

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

View File

@@ -16,10 +16,6 @@ import java.util.Objects;
@Component
public class DemoWebConfigurer implements TieshengWebConfigurer, TsLoginConfigurer {
@Autowired
GlobalConfig globalConfig;
@Override
public RequestUserInfo getCurrentUserName(TokenBean tokenBean) {
RequestUserInfo info = new RequestUserInfo();

View File

@@ -1,8 +1,6 @@
package com.tiesheng.demo.config;
import com.tiesheng.web.service.CoreConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@@ -13,9 +11,6 @@ import javax.annotation.PostConstruct;
@Component
public class TestJobConfig {
@Autowired
CoreConfigService coreConfigService;
@PostConstruct
public void init() {
}

View File

@@ -219,8 +219,10 @@ public class TestController {
"83_7xqG36kdgwuf8zzWLY3jtz7bg4ucziN-0oxbE0X9zBzwbjZ4S4Ss2RM9uHeSIcRp2K-wEp6MLzWhqo2AXj0Jpzd6IiJdUsRxqdHPvEWqAdOgt83vzZwdDf7tZBkGNGeAFASZS",
paramJson);
Response execute1 = OkHttpUtil.ofHttpClient().build().newCall(request).execute();
FileUtil.writeFromStream(execute1.body().byteStream(), file.getAbsolutePath());
execute1.close();
if (execute1.body() != null) {
FileUtil.writeFromStream(execute1.body().byteStream(), file.getAbsolutePath());
execute1.close();
}
} catch (Exception e) {
throw new ApiException("每分钟最多生成5000个二维码请稍后再试");
}

View File

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

View File

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

View File

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

View File

@@ -20,8 +20,7 @@ public class DoLoginInfo {
this.info = info;
// 设置IP
HttpServletRequest request = ServletKit.getRequest();
this.loginIp = ServletKit.getClientIP(request);
this.loginIp = ServletKit.getClientIP();
}
///////////////////////////////////////////////////////////////////////////

View File

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

View File

@@ -99,7 +99,7 @@ public class AliyunSmsSender implements TsMessageSender {
String signature = specialUrlEncode(digest);
queryMap.put("Signature", signature);
String respBody = "";
String respBody;
try {
respBody = OkHttpUtil.get(ENDPOINT + "?Signature=" + signature + sortQueryStringTmp);
} catch (Exception e) {

View File

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

View File

@@ -76,15 +76,16 @@ public class PlatformDingConfig {
request = OkHttpUtil.ofPost(url, body);
}
request = request.newBuilder().header("x-acs-dingtalk-access-token", accessToken).build();
try {
Response response = OkHttpUtil.ofHttpClient().build().newCall(request).execute();
try (Response response = OkHttpUtil.ofHttpClient().build().newCall(request).execute()) {
if (response.isSuccessful() && response.body() != null) {
String rawBody = response.body().string();
DingResponse<T> bean = JSON.parseObject(rawBody, typeReference);
bean.setRawBody(rawBody);
return bean;
} else {
LogFactory.get().info(response.body().string());
if (response.body() != null) {
LogFactory.get().info(response.body().string());
}
}
} catch (Exception e) {
LogFactory.get().error(e);
@@ -246,7 +247,7 @@ public class PlatformDingConfig {
JSONObject object = new JSONObject();
object.put("dept_id", deptId);
object.put("cursor", cursor);
object.put("size", 200);
object.put("size", 100);
return doRequest(service, "https://oapi.dingtalk.com/topapi/v2/user/list",
object, new TypeReference<DingResponse<DingUserListVo>>() {

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.6</version>
<version>2.0.12</version>
</parent>
<artifactId>springboot-role</artifactId>

View File

@@ -49,6 +49,7 @@ public class CommRoleController {
.in("id", list)
.eq(CoreRoleServer.IS_DELETED, 0)
.eq("is_open", 1)
.orderByAsc("sort")
);
}

View File

@@ -6,6 +6,7 @@ import com.tiesheng.annotation.role.RoleAuthority;
import com.tiesheng.role.pojos.dao.CoreRoleAuthority;
import com.tiesheng.role.pojos.dao.CoreRoleServer;
import com.tiesheng.role.pojos.dto.MenuListDTO;
import com.tiesheng.role.pojos.dto.ServerListDTO;
import com.tiesheng.role.pojos.vo.ServiceMenuVO;
import com.tiesheng.role.service.CoreRoleService;
import com.tiesheng.util.pojos.ApiResp;
@@ -29,10 +30,11 @@ public class RoleServerController {
* @return
*/
@GetMapping("/server/list")
public ApiResp<List<CoreRoleServer>> list() {
public ApiResp<List<CoreRoleServer>> list(ServerListDTO dto) {
return ApiResp.respOK(coreRoleService.getServerMapper().selectList(new QueryWrapper<CoreRoleServer>()
.eq(CoreRoleServer.IS_DELETED, 0)
.eq("is_open", 1)
.eq(StrUtil.isNotEmpty(dto.getIsOpen()), "is_open", dto.getIsOpen())
.orderByAsc("sort")
));
}

View File

@@ -30,6 +30,12 @@ public class CoreRoleUser extends DaoBase {
@TableField(value = "type_id")
private String typeId;
/**
* 说明
*/
@TableField(value = "remark")
private String remark;
/**
* 过期时间,无则不过期
*/
@@ -108,6 +114,14 @@ public class CoreRoleUser extends DaoBase {
this.typeId = typeId;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
/**
* 获取过期时间,无则不过期
*
@@ -179,4 +193,4 @@ public class CoreRoleUser extends DaoBase {
public void setExt3(String ext3) {
this.ext3 = ext3;
}
}
}

View File

@@ -0,0 +1,15 @@
package com.tiesheng.role.pojos.dto;
public class ServerListDTO {
private String isOpen;
public String getIsOpen() {
return isOpen;
}
public void setIsOpen(String isOpen) {
this.isOpen = isOpen;
}
}

View File

@@ -108,4 +108,7 @@ alter table core_role_authority
alter table core_role_group_rx
add type varchar(10) null comment '关联类型dep-依赖bind-绑定';
alter table core_role_user
add remark varchar(500) null comment '说明' after type_id;
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -11,6 +11,7 @@
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="type" jdbcType="VARCHAR" property="type" />
<result column="type_id" jdbcType="VARCHAR" property="typeId" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="expire_time" jdbcType="TIMESTAMP" property="expireTime" />
<result column="ext1" jdbcType="VARCHAR" property="ext1" />
<result column="ext2" jdbcType="VARCHAR" property="ext2" />
@@ -18,7 +19,7 @@
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, create_time, update_time, is_deleted, user_id, `type`, type_id, expire_time,
id, create_time, update_time, is_deleted, user_id, `type`, type_id, remark, expire_time,
ext1, ext2, ext3
</sql>

View File

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

View File

@@ -17,7 +17,25 @@ public class ServletKit extends ServletUtil {
public static HttpServletRequest getRequest() {
ServletRequestAttributes attributes = (ServletRequestAttributes)
RequestContextHolder.getRequestAttributes();
return attributes.getRequest();
if (attributes != null) {
return attributes.getRequest();
}
return null;
}
/**
* 获取请求头
*
* @param name 请求头
* @return 请求头
*/
public static String getHeader(String name) {
HttpServletRequest request = getRequest();
if (request == null) {
return "";
}
return getHeader(request, name, "utf-8");
}
/**
@@ -27,6 +45,9 @@ public class ServletKit extends ServletUtil {
*/
public static String getClientIP() {
HttpServletRequest request = getRequest();
if (request == null) {
return "";
}
return getClientIP(request);
}

View File

@@ -384,7 +384,7 @@ public class JWT implements RegisteredPayload<JWT> {
* @since 5.7.4
*/
public boolean validate(long leeway) {
if (false == verify()) {
if (!verify()) {
return false;
}

View File

@@ -2,6 +2,7 @@ package com.tiesheng.util.jwt;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.exceptions.ValidateException;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.tiesheng.util.jwt.signers.JWTSigner;
import com.tiesheng.util.jwt.signers.NoneJWTSigner;
@@ -160,13 +161,13 @@ public class JWTValidator {
}
final String algorithmIdInSigner = signer.getAlgorithmId();
if (false == StrUtil.equals(algorithmId, algorithmIdInSigner)) {
if (!StrUtil.equals(algorithmId, algorithmIdInSigner)) {
throw new ValidateException("Algorithm [{}] defined in header doesn't match to [{}]!"
, algorithmId, algorithmIdInSigner);
}
// 通过算法验证签名是否正确
if (false == jwt.verify(signer)) {
if (!jwt.verify(signer)) {
throw new ValidateException("Signature verification failed!");
}
}
@@ -200,7 +201,10 @@ public class JWTValidator {
validateNotAfter(JWTPayload.NOT_BEFORE, notBefore, now, leeway);
// 检查失效时间(失效时间不能早于当前时间)
final Date expiresAt = payload.getClaimsJson().getDate(JWTPayload.EXPIRES_AT);
// 这里兼容一下旧版本旧版本使用的是10位数的秒作为数据
String string = payload.getClaimsJson().getString(JWTPayload.EXPIRES_AT);
Date expiresAt = StrUtil.length(string) == 10 ? DateUtil.date(NumberUtil.parseLong(string) * 1000L)
: DateUtil.parse(string);
validateNotBefore(JWTPayload.EXPIRES_AT, expiresAt, now, leeway);
// 检查签发时间(签发时间不能晚于当前时间)

View File

@@ -84,7 +84,7 @@ public class TsCacheService {
* 验证 图片验证码
*/
public void verifyCaptcha(String value) {
String captchaKey = ServletUtil.getHeader(ServletKit.getRequest(), "captcha", "utf-8");
String captchaKey = ServletKit.getHeader("captcha");
String cache = get(captchaKey);
if (StrUtil.isEmpty(cache) || !StrUtil.equals(cache, value)) {
throw new ApiException("验证码不正确");

View File

@@ -10,7 +10,7 @@ import java.util.Set;
import java.util.stream.Collectors;
@Configuration
@ConditionalOnMissingBean(value = TsCacheHandler.class, ignored = {TsCacheTimedHandler.class, TsCacheTimedHandler.class})
@ConditionalOnMissingBean(value = TsCacheHandler.class, ignored = {TsCacheTimedHandler.class})
public class TsCacheTimedHandler implements TsCacheHandler {
private static volatile TimedCache<String, String> timedCache;

View File

@@ -83,9 +83,11 @@ public class OkHttpUtil {
}
public static String get(String urlString, int timeout) {
try {
return ofHttpClient().connectTimeout(timeout, TimeUnit.MILLISECONDS)
.build().newCall(ofGet(urlString)).execute().body().string();
try (Response execute = ofHttpClient().connectTimeout(timeout, TimeUnit.MILLISECONDS)
.build().newCall(ofGet(urlString)).execute()) {
if (execute.body() != null) {
return execute.body().string();
}
} catch (IOException ignored) {
}
return null;
@@ -117,9 +119,11 @@ public class OkHttpUtil {
}
public static String post(String urlString, RequestBody body, int timeout) {
try {
return ofHttpClient().connectTimeout(timeout, TimeUnit.MILLISECONDS)
.build().newCall(ofPost(urlString, body)).execute().body().string();
try (Response response = ofHttpClient().connectTimeout(timeout, TimeUnit.MILLISECONDS)
.build().newCall(ofPost(urlString, body)).execute()) {
if (response.body() != null) {
return response.body().string();
}
} catch (IOException ignored) {
}
return null;
@@ -135,11 +139,10 @@ public class OkHttpUtil {
}
public static File downloadFile(String url, File destFile) {
try {
Response response = ofHttpClient()
.connectTimeout(0, TimeUnit.MILLISECONDS)
.readTimeout(0, TimeUnit.MILLISECONDS)
.build().newCall(ofGet(url)).execute();
try (Response response = ofHttpClient()
.connectTimeout(0, TimeUnit.MILLISECONDS)
.readTimeout(0, TimeUnit.MILLISECONDS)
.build().newCall(ofGet(url)).execute()) {
if (response.isSuccessful() && response.body() != null) {
FileUtil.writeFromStream(response.body().byteStream(), destFile);
}
@@ -150,11 +153,10 @@ public class OkHttpUtil {
}
public static byte[] downloadBytes(String url) {
try {
Response response = ofHttpClient()
.connectTimeout(0, TimeUnit.MILLISECONDS)
.readTimeout(0, TimeUnit.MILLISECONDS)
.build().newCall(ofGet(url)).execute();
try (Response response = ofHttpClient()
.connectTimeout(0, TimeUnit.MILLISECONDS)
.readTimeout(0, TimeUnit.MILLISECONDS)
.build().newCall(ofGet(url)).execute()) {
if (response.isSuccessful() && response.body() != null) {
return response.body().bytes();
}

View File

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

View File

@@ -56,8 +56,12 @@ public class OperationAspect {
@Around("methodArgs()")
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
// GET请求不处理
HttpServletRequest request = ServletKit.getRequest();
if (request == null) {
return joinPoint.proceed();
}
// GET请求不处理
if (StrUtil.equalsIgnoreCase(request.getMethod(), "GET")) {
return joinPoint.proceed(joinPoint.getArgs());
}

View File

@@ -15,6 +15,7 @@ import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@@ -24,6 +25,7 @@ import java.util.stream.Collectors;
@Aspect
@Component
@ConditionalOnBean(value = TsAuthorityHandler.class)
public class RoleAuthorityAspect {
@Resource

View File

@@ -5,12 +5,13 @@ import cn.hutool.core.date.DateUtil;
import com.tiesheng.annotation.role.RoleAuthority;
import com.tiesheng.util.service.role.TsAuthorityHandler;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Date;
@@ -18,19 +19,15 @@ import java.util.List;
import java.util.Map;
@Service
@ConditionalOnBean(value = TsAuthorityHandler.class)
public class RoleAuthorityCreator implements ApplicationListener<ContextRefreshedEvent> {
@Autowired(required = false)
@Resource
TsAuthorityHandler tsAuthorityHandler;
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
if (tsAuthorityHandler == null) {
return;
}
ApplicationContext applicationContext = event.getApplicationContext();
Map<String, Object> beansOfType = applicationContext.getBeansWithAnnotation(RoleAuthority.class);

View File

@@ -2,8 +2,8 @@ package com.tiesheng.web.service;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.tiesheng.util.service.http.OkHttpUtil;
import com.tiesheng.web.mapper.CoreLogApiMapper;
import com.tiesheng.web.pojos.dao.CoreLogApi;
import okhttp3.*;
@@ -30,33 +30,27 @@ public class OkHttpLogInterceptor implements Interceptor {
logApi.setUrl(request.url().toString());
logApi.setContent(requestBody2String(request));
Response response;
Response response = null;
try {
response = chain.proceed(request);
logApi.setResult(response.code());
// 如果是json,xml,text则保存记录
if (response.body() != null && StrUtil.containsAll(response.body().contentType().toString(),
"json", "xml", "text")) {
ResponseBody peekBody = response.peekBody(Long.MAX_VALUE);
logApi.setRespBody(peekBody.string());
peekBody.close();
if (response.body() != null) {
MediaType mediaType = response.body().contentType();
String contentType = mediaType == null ? "" : mediaType.toString();
if (StrUtil.containsAny(contentType, "json", "xml", "text")) {
ResponseBody peekBody = response.peekBody(Long.MAX_VALUE);
logApi.setRespBody(peekBody.string());
peekBody.close();
}
}
} catch (Exception e) {
JSONObject object = new JSONObject();
object.put("code", -1);
object.put("message", e.getMessage());
object.put("message", JSON.toJSONString(e));
object.put("exception", e);
logApi.setRespBody(object.toJSONString());
response = new Response.Builder()
.request(request)
.protocol(Protocol.HTTP_1_1)
.code(logApi.getResult())
.message(e.getMessage())
.body(OkHttpUtil.ofJsonResponse(logApi.getRespBody()))
.build();
}
ThreadUtil.execute(() -> coreLogApiMapper.insert(logApi));