perf:移除hutool-json,直接使用fastjson
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
package com.tiesheng.demo.config;
|
package com.tiesheng.demo.config;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
|
||||||
import cn.hutool.log.LogFactory;
|
|
||||||
import com.tiesheng.login.pojos.RequestUserInfo;
|
import com.tiesheng.login.pojos.RequestUserInfo;
|
||||||
import com.tiesheng.login.pojos.dao.CorePlatformUnique;
|
import com.tiesheng.login.pojos.dao.CorePlatformUnique;
|
||||||
import com.tiesheng.login.service.TsLoginConfigurer;
|
import com.tiesheng.login.service.TsLoginConfigurer;
|
||||||
@@ -21,15 +19,6 @@ public class DemoWebConfigurer implements TieshengWebConfigurer, TsLoginConfigur
|
|||||||
@Autowired
|
@Autowired
|
||||||
GlobalConfig globalConfig;
|
GlobalConfig globalConfig;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
RequestUserInfo info = new RequestUserInfo();
|
|
||||||
info.setId("1");
|
|
||||||
info.setName("name");
|
|
||||||
info.setData(info);
|
|
||||||
String jsonStr = JSONUtil.toJsonStr(info);
|
|
||||||
LogFactory.get().info(jsonStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RequestUserInfo getCurrentUserName(TokenBean tokenBean) {
|
public RequestUserInfo getCurrentUserName(TokenBean tokenBean) {
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ public class JsonTest {
|
|||||||
private String no;
|
private String no;
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
private JsonTest child;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// setter\getter
|
// setter\getter
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
@@ -47,4 +49,12 @@ public class JsonTest {
|
|||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JsonTest getChild() {
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChild(JsonTest child) {
|
||||||
|
this.child = child;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
package com.tiesheng.demo.service;
|
package com.tiesheng.demo.service;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.json.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import cn.hutool.json.JSONUtil;
|
|
||||||
import com.tiesheng.message.config.aliyun.AliyunSmsHandler;
|
import com.tiesheng.message.config.aliyun.AliyunSmsHandler;
|
||||||
import com.tiesheng.message.config.aliyun.AliyunTempParam;
|
import com.tiesheng.message.config.aliyun.AliyunTempParam;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -15,16 +14,17 @@ public class DemoSmsHandler implements AliyunSmsHandler {
|
|||||||
@Override
|
@Override
|
||||||
public AliyunTempParam handler(JSONObject obj) {
|
public AliyunTempParam handler(JSONObject obj) {
|
||||||
|
|
||||||
String action = obj.getStr("action");
|
String action = obj.getString("action");
|
||||||
|
|
||||||
AliyunTempParam param = new AliyunTempParam();
|
AliyunTempParam param = new AliyunTempParam();
|
||||||
param.setSignName("智慧校园");
|
param.setSignName("智慧校园");
|
||||||
|
|
||||||
if (Objects.equals(action, "sms-visitor-invite")) {
|
if (Objects.equals(action, "sms-visitor-invite")) {
|
||||||
param.setTemplateCode("SMS_276125463");
|
param.setTemplateCode("SMS_276125463");
|
||||||
param.setTemplateParam(JSONUtil.createObj()
|
|
||||||
.putOpt("date", DateUtil.today())
|
JSONObject object = new JSONObject();
|
||||||
);
|
object.put("date", DateUtil.today());
|
||||||
|
param.setTemplateParam(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
return param;
|
return param;
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.tiesheng.demo;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.log.LogFactory;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONPath;
|
||||||
|
import com.tiesheng.demo.pojos.JsonTest;
|
||||||
|
import com.tiesheng.login.pojos.RequestUserInfo;
|
||||||
|
|
||||||
|
public class MainTest {
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
MainTest test = new MainTest();
|
||||||
|
test.testJsonSelf();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testJsonSelf() {
|
||||||
|
RequestUserInfo info = new RequestUserInfo();
|
||||||
|
info.setId("1");
|
||||||
|
info.setName("name");
|
||||||
|
info.setData(info);
|
||||||
|
String jsonStr = JSON.toJSONString(info);
|
||||||
|
LogFactory.get().info(jsonStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void testJsonPath() {
|
||||||
|
JsonTest jsonTest = new JsonTest();
|
||||||
|
jsonTest.setNo("1111");
|
||||||
|
jsonTest.setName("1111");
|
||||||
|
jsonTest.setNow(DateUtil.date());
|
||||||
|
jsonTest.setChild(jsonTest);
|
||||||
|
|
||||||
|
JSONPath jsonPath = JSONPath.compile("child.no");
|
||||||
|
String eval = jsonPath.eval(jsonTest, String.class);
|
||||||
|
LogFactory.get().info(eval);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.tiesheng.message.config.aliyun;
|
package com.tiesheng.message.config.aliyun;
|
||||||
|
|
||||||
import cn.hutool.json.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
public interface AliyunSmsHandler {
|
public interface AliyunSmsHandler {
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import cn.hutool.core.lang.Validator;
|
|||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.crypto.SecureUtil;
|
import cn.hutool.crypto.SecureUtil;
|
||||||
import cn.hutool.json.JSONObject;
|
import com.alibaba.fastjson.JSON;
|
||||||
import cn.hutool.json.JSONUtil;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.tiesheng.message.service.TsMessageSender;
|
import com.tiesheng.message.service.TsMessageSender;
|
||||||
import com.tiesheng.util.exception.ApiException;
|
import com.tiesheng.util.exception.ApiException;
|
||||||
import com.tiesheng.util.pojos.ApiResp;
|
import com.tiesheng.util.pojos.ApiResp;
|
||||||
@@ -103,10 +103,10 @@ public class AliyunSmsSender implements TsMessageSender {
|
|||||||
try {
|
try {
|
||||||
respBody = OkHttpUtil.get(ENDPOINT + "?Signature=" + signature + sortQueryStringTmp);
|
respBody = OkHttpUtil.get(ENDPOINT + "?Signature=" + signature + sortQueryStringTmp);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
respBody = JSONUtil.createObj()
|
JSONObject object = new JSONObject();
|
||||||
.putOpt("Code", "Error")
|
object.put("Code", "Error");
|
||||||
.putOpt("Message", "消息通道异常")
|
object.put("Message", "消息通道异常");
|
||||||
.toString();
|
respBody = object.toJSONString();
|
||||||
}
|
}
|
||||||
return respBody;
|
return respBody;
|
||||||
}
|
}
|
||||||
@@ -130,9 +130,9 @@ public class AliyunSmsSender implements TsMessageSender {
|
|||||||
queryMap.put("TemplateParam", tempParam.getTemplateParam().toString());
|
queryMap.put("TemplateParam", tempParam.getTemplateParam().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject respObj = JSONUtil.parseObj(request("SendSms", queryMap));
|
JSONObject respObj = JSON.parseObject(request("SendSms", queryMap));
|
||||||
if (!Objects.equals(respObj.getStr("Code"), "OK")) {
|
if (!Objects.equals(respObj.getString("Code"), "OK")) {
|
||||||
return ApiResp.resp130(respObj.getStr("Message"));
|
return ApiResp.resp130(respObj.getString("Message"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ApiResp.respOK("");
|
return ApiResp.respOK("");
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.tiesheng.message.config.aliyun;
|
package com.tiesheng.message.config.aliyun;
|
||||||
|
|
||||||
import cn.hutool.json.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
public class AliyunTempParam {
|
public class AliyunTempParam {
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.tiesheng.message.service;
|
package com.tiesheng.message.service;
|
||||||
|
|
||||||
|
|
||||||
import cn.hutool.json.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.tiesheng.util.pojos.ApiResp;
|
import com.tiesheng.util.pojos.ApiResp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.tiesheng.message.service;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.tiesheng.message.pojos.UserChannel;
|
import com.tiesheng.message.pojos.UserChannel;
|
||||||
import com.tiesheng.util.pojos.ApiResp;
|
import com.tiesheng.util.pojos.ApiResp;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package com.tiesheng.platform.config.ding;
|
package com.tiesheng.platform.config.ding;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.lang.TypeReference;
|
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONObject;
|
|
||||||
import cn.hutool.json.JSONUtil;
|
|
||||||
import cn.hutool.log.LogFactory;
|
import cn.hutool.log.LogFactory;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.fastjson.TypeReference;
|
||||||
import com.tiesheng.platform.config.ding.bean.*;
|
import com.tiesheng.platform.config.ding.bean.*;
|
||||||
import com.tiesheng.util.exception.ApiException;
|
import com.tiesheng.util.exception.ApiException;
|
||||||
import com.tiesheng.util.service.TsCacheService;
|
import com.tiesheng.util.service.TsCacheService;
|
||||||
@@ -80,7 +80,7 @@ public class PlatformDingConfig {
|
|||||||
Response response = OkHttpUtil.ofHttpClient().build().newCall(request).execute();
|
Response response = OkHttpUtil.ofHttpClient().build().newCall(request).execute();
|
||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
String rawBody = response.body().string();
|
String rawBody = response.body().string();
|
||||||
DingResponse<T> bean = JSONUtil.toBean(rawBody, typeReference, true);
|
DingResponse<T> bean = JSON.parseObject(rawBody, typeReference);
|
||||||
bean.setRawBody(rawBody);
|
bean.setRawBody(rawBody);
|
||||||
return bean;
|
return bean;
|
||||||
} else {
|
} else {
|
||||||
@@ -116,8 +116,8 @@ public class PlatformDingConfig {
|
|||||||
query.put("appkey", dingConfigBean.getAppKey());
|
query.put("appkey", dingConfigBean.getAppKey());
|
||||||
query.put("appsecret", dingConfigBean.getAppSecret());
|
query.put("appsecret", dingConfigBean.getAppSecret());
|
||||||
String response = OkHttpUtil.get("https://oapi.dingtalk.com/gettoken", query);
|
String response = OkHttpUtil.get("https://oapi.dingtalk.com/gettoken", query);
|
||||||
JSONObject respJson = JSONUtil.parseObj(response);
|
JSONObject respJson = JSON.parseObject(response);
|
||||||
accessToken = respJson.getStr("access_token");
|
accessToken = respJson.getString("access_token");
|
||||||
TsCacheService.of().put(CACHE_ACCESS_TOKEN + dingConfigBean.getAppKey(),
|
TsCacheService.of().put(CACHE_ACCESS_TOKEN + dingConfigBean.getAppKey(),
|
||||||
accessToken, respJson.getLong("expires_in"));
|
accessToken, respJson.getLong("expires_in"));
|
||||||
|
|
||||||
@@ -174,8 +174,12 @@ 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>
|
* @see <a href="https://open.dingtalk.com/document/isvapp-server/obtain-the-userid-of-a-user-by-using-the-log-free"></a>
|
||||||
*/
|
*/
|
||||||
public DingUserSimple getUserIdByCode(String service, String code) {
|
public DingUserSimple getUserIdByCode(String service, String code) {
|
||||||
|
|
||||||
|
JSONObject object = new JSONObject();
|
||||||
|
object.put("code", code);
|
||||||
|
|
||||||
DingResponse<DingUserSimple> resp = doRequest(service, "https://oapi.dingtalk.com/topapi/v2/user/getuserinfo",
|
DingResponse<DingUserSimple> resp = doRequest(service, "https://oapi.dingtalk.com/topapi/v2/user/getuserinfo",
|
||||||
JSONUtil.createObj().putOpt("code", code), new TypeReference<DingResponse<DingUserSimple>>() {
|
object, new TypeReference<DingResponse<DingUserSimple>>() {
|
||||||
});
|
});
|
||||||
return resp.getResult();
|
return resp.getResult();
|
||||||
}
|
}
|
||||||
@@ -192,9 +196,13 @@ public class PlatformDingConfig {
|
|||||||
public DingUserInfo topapiV2UserGet(String service, String ddUserId) {
|
public DingUserInfo topapiV2UserGet(String service, String ddUserId) {
|
||||||
DingConfigBean dingConfigBean = getConfigBean(service);
|
DingConfigBean dingConfigBean = getConfigBean(service);
|
||||||
|
|
||||||
|
JSONObject object = new JSONObject();
|
||||||
|
object.put("userid", ddUserId);
|
||||||
|
|
||||||
DingUserInfo userInfo = doRequest(service, "https://oapi.dingtalk.com/topapi/v2/user/get",
|
DingUserInfo userInfo = doRequest(service, "https://oapi.dingtalk.com/topapi/v2/user/get",
|
||||||
JSONUtil.createObj().putOpt("userid", ddUserId), new TypeReference<DingResponse<DingUserInfo>>() {
|
object, new TypeReference<DingResponse<DingUserInfo>>() {
|
||||||
}).getResult();
|
}).getResult();
|
||||||
|
|
||||||
// 设置一下job_number
|
// 设置一下job_number
|
||||||
userInfo.setJobNumber(userInfo.getJobNumber());
|
userInfo.setJobNumber(userInfo.getJobNumber());
|
||||||
userInfo.setAppId(dingConfigBean.getAppKey());
|
userInfo.setAppId(dingConfigBean.getAppKey());
|
||||||
@@ -214,8 +222,11 @@ public class PlatformDingConfig {
|
|||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JSONObject object = new JSONObject();
|
||||||
|
object.put("dept_id", deptId);
|
||||||
|
|
||||||
return doRequest(service, "https://oapi.dingtalk.com/topapi/v2/department/listsub",
|
return doRequest(service, "https://oapi.dingtalk.com/topapi/v2/department/listsub",
|
||||||
JSONUtil.createObj().putOpt("dept_id", deptId), new TypeReference<DingResponse<List<DingDeptVo>>>() {
|
object, new TypeReference<DingResponse<List<DingDeptVo>>>() {
|
||||||
}).getResult();
|
}).getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,9 +243,13 @@ public class PlatformDingConfig {
|
|||||||
return DingUserListVo.fail();
|
return DingUserListVo.fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JSONObject object = new JSONObject();
|
||||||
|
object.put("dept_id", deptId);
|
||||||
|
object.put("cursor", cursor);
|
||||||
|
object.put("size", 100);
|
||||||
|
|
||||||
return doRequest(service, "https://oapi.dingtalk.com/topapi/v2/user/list",
|
return doRequest(service, "https://oapi.dingtalk.com/topapi/v2/user/list",
|
||||||
JSONUtil.createObj().putOpt("dept_id", deptId).putOpt("cursor", cursor).putOpt("size", 100),
|
object, new TypeReference<DingResponse<DingUserListVo>>() {
|
||||||
new TypeReference<DingResponse<DingUserListVo>>() {
|
|
||||||
}).getResult();
|
}).getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,24 +308,28 @@ public class PlatformDingConfig {
|
|||||||
DingConfigBean configBean = getConfigBean(service);
|
DingConfigBean configBean = getConfigBean(service);
|
||||||
|
|
||||||
JSONObject msg = new JSONObject();
|
JSONObject msg = new JSONObject();
|
||||||
|
|
||||||
if (StrUtil.isEmpty(actionUrl)) {
|
if (StrUtil.isEmpty(actionUrl)) {
|
||||||
msg.set("msgtype", "markdown");
|
JSONObject markdownObj = new JSONObject();
|
||||||
msg.set("markdown", JSONUtil.createObj()
|
markdownObj.put("title", title);
|
||||||
.set("title", title).set("text", markdown)
|
markdownObj.put("text", markdown);
|
||||||
);
|
|
||||||
|
msg.put("msgtype", "markdown");
|
||||||
|
msg.put("markdown", markdownObj);
|
||||||
} else {
|
} else {
|
||||||
msg.set("msgtype", "action_card");
|
JSONObject actionCard = new JSONObject();
|
||||||
msg.set("action_card", JSONUtil.createObj()
|
actionCard.put("title", title);
|
||||||
.set("title", title).set("markdown", markdown)
|
actionCard.put("markdown", markdown);
|
||||||
.set("single_title", "点击查看").set("single_url", actionUrl)
|
actionCard.put("single_title", "点击查看");
|
||||||
);
|
actionCard.put("single_url", actionUrl);
|
||||||
|
|
||||||
|
msg.put("msgtype", "action_card");
|
||||||
|
msg.put("action_card", actionCard);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject body = new JSONObject();
|
JSONObject body = new JSONObject();
|
||||||
body.putOpt("agent_id", configBean.getAgentId());
|
body.put("agent_id", configBean.getAgentId());
|
||||||
body.putOpt("userid_list", CollUtil.join(userIds, ","));
|
body.put("userid_list", CollUtil.join(userIds, ","));
|
||||||
body.putOpt("msg", msg);
|
body.put("msg", msg);
|
||||||
return doRequest(service, "https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2", body,
|
return doRequest(service, "https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2", body,
|
||||||
new TypeReference<DingResponse<String>>() {
|
new TypeReference<DingResponse<String>>() {
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.tiesheng.platform.config.ding.bean;
|
package com.tiesheng.platform.config.ding.bean;
|
||||||
|
|
||||||
import cn.hutool.json.JSONUtil;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONPath;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@@ -41,7 +42,8 @@ public class DingResponse<T> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public <E> E getRawValue(String path, Class<E> tClass) {
|
public <E> E getRawValue(String path, Class<E> tClass) {
|
||||||
return JSONUtil.parse(getRawBody()).getByPath(path, tClass);
|
JSONPath jsonPath = JSONPath.compile(path);
|
||||||
|
return jsonPath.eval(JSON.parseObject(getRawBody()), tClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package com.tiesheng.platform.config.wxmini;
|
|||||||
|
|
||||||
|
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.json.JSONObject;
|
import com.alibaba.fastjson.JSON;
|
||||||
import cn.hutool.json.JSONUtil;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.tiesheng.platform.config.wxmp.bean.WxConfigBean;
|
import com.tiesheng.platform.config.wxmp.bean.WxConfigBean;
|
||||||
import com.tiesheng.util.exception.ApiException;
|
import com.tiesheng.util.exception.ApiException;
|
||||||
import com.tiesheng.util.service.http.OkHttpUtil;
|
import com.tiesheng.util.service.http.OkHttpUtil;
|
||||||
@@ -56,8 +56,8 @@ public class PlatformWxminiConfig {
|
|||||||
+ "&secret=" + configBean.getAppSecret()
|
+ "&secret=" + configBean.getAppSecret()
|
||||||
+ "&js_code=" + code + "&grant_type=authorization_code");
|
+ "&js_code=" + code + "&grant_type=authorization_code");
|
||||||
|
|
||||||
JSONObject object = JSONUtil.parseObj(body);
|
JSONObject object = JSON.parseObject(body);
|
||||||
return object.getStr("openid");
|
return object.getString("openid");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,8 +72,8 @@ public class PlatformWxminiConfig {
|
|||||||
+ "?grant_type=client_credential&appid=" + configBean.getAppId()
|
+ "?grant_type=client_credential&appid=" + configBean.getAppId()
|
||||||
+ "&secret=" + configBean.getAppSecret());
|
+ "&secret=" + configBean.getAppSecret());
|
||||||
|
|
||||||
JSONObject object = JSONUtil.parseObj(body);
|
JSONObject object = JSON.parseObject(body);
|
||||||
return object.getStr("access_token");
|
return object.getString("access_token");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ package com.tiesheng.platform.config.wxmp;
|
|||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.core.util.URLUtil;
|
import cn.hutool.core.util.URLUtil;
|
||||||
import cn.hutool.json.JSONObject;
|
|
||||||
import cn.hutool.json.JSONUtil;
|
|
||||||
import cn.hutool.log.LogFactory;
|
import cn.hutool.log.LogFactory;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.tiesheng.platform.config.wxmp.bean.WxConfigBean;
|
import com.tiesheng.platform.config.wxmp.bean.WxConfigBean;
|
||||||
import com.tiesheng.platform.config.wxmp.bean.WxJsapiSignature;
|
import com.tiesheng.platform.config.wxmp.bean.WxJsapiSignature;
|
||||||
import com.tiesheng.platform.config.wxmp.bean.WxOAuth2AccessToken;
|
import com.tiesheng.platform.config.wxmp.bean.WxOAuth2AccessToken;
|
||||||
@@ -70,8 +70,8 @@ public class PlatformWxmpConfig {
|
|||||||
query.put("appid", configBean.getAppId());
|
query.put("appid", configBean.getAppId());
|
||||||
query.put("secret", configBean.getAppSecret());
|
query.put("secret", configBean.getAppSecret());
|
||||||
String response = OkHttpUtil.get("https://api.weixin.qq.com/cgi-bin/token", query);
|
String response = OkHttpUtil.get("https://api.weixin.qq.com/cgi-bin/token", query);
|
||||||
JSONObject respJson = JSONUtil.parseObj(response);
|
JSONObject respJson = JSON.parseObject(response);
|
||||||
accessToken = respJson.getStr("access_token");
|
accessToken = respJson.getString("access_token");
|
||||||
TsCacheService.of().put(CACHE_ACCESS_TOKEN + configBean.getAppId(), accessToken,
|
TsCacheService.of().put(CACHE_ACCESS_TOKEN + configBean.getAppId(), accessToken,
|
||||||
respJson.getLong("expires_in"));
|
respJson.getLong("expires_in"));
|
||||||
}
|
}
|
||||||
@@ -93,8 +93,8 @@ public class PlatformWxmpConfig {
|
|||||||
query.put("type", "jsapi");
|
query.put("type", "jsapi");
|
||||||
String response = OkHttpUtil.get("https://api.weixin.qq.com/cgi-bin/ticket/getticket", query);
|
String response = OkHttpUtil.get("https://api.weixin.qq.com/cgi-bin/ticket/getticket", query);
|
||||||
LogFactory.get().info("getJsapiTicket: " + response);
|
LogFactory.get().info("getJsapiTicket: " + response);
|
||||||
JSONObject respJson = JSONUtil.parseObj(response);
|
JSONObject respJson = JSON.parseObject(response);
|
||||||
jsapiTicket = respJson.getStr("ticket");
|
jsapiTicket = respJson.getString("ticket");
|
||||||
TsCacheService.of().put(CACHE_JSAPI_TICKET + configBean.getAppId(), jsapiTicket,
|
TsCacheService.of().put(CACHE_JSAPI_TICKET + configBean.getAppId(), jsapiTicket,
|
||||||
respJson.getLong("expires_in"));
|
respJson.getLong("expires_in"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.tiesheng.platform.config.wxmp.bean;
|
package com.tiesheng.platform.config.wxmp.bean;
|
||||||
|
|
||||||
import cn.hutool.json.JSONObject;
|
import com.alibaba.fastjson.JSON;
|
||||||
import cn.hutool.json.JSONUtil;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.tiesheng.util.service.http.OkHttpUtil;
|
import com.tiesheng.util.service.http.OkHttpUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -15,11 +15,11 @@ public class WxOAuth2AccessToken {
|
|||||||
public static WxOAuth2AccessToken create(String appId, String secret, String code) {
|
public static WxOAuth2AccessToken create(String appId, String secret, String code) {
|
||||||
String response = OkHttpUtil.get("https://api.weixin.qq.com/sns/oauth2/access_token" +
|
String response = OkHttpUtil.get("https://api.weixin.qq.com/sns/oauth2/access_token" +
|
||||||
"?appid=" + appId + "&secret=" + secret + "&code=" + code + "&grant_type=authorization_code");
|
"?appid=" + appId + "&secret=" + secret + "&code=" + code + "&grant_type=authorization_code");
|
||||||
JSONObject respJson = JSONUtil.parseObj(response);
|
JSONObject respJson = JSON.parseObject(response);
|
||||||
|
|
||||||
WxOAuth2AccessToken oAuth2AccessToken = new WxOAuth2AccessToken();
|
WxOAuth2AccessToken oAuth2AccessToken = new WxOAuth2AccessToken();
|
||||||
oAuth2AccessToken.setOpenid(respJson.getStr("openid"));
|
oAuth2AccessToken.setOpenid(respJson.getString("openid"));
|
||||||
oAuth2AccessToken.setAccessToken(respJson.getStr("access_token"));
|
oAuth2AccessToken.setAccessToken(respJson.getString("access_token"));
|
||||||
return oAuth2AccessToken;
|
return oAuth2AccessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.tiesheng.platform.config.wxmp.bean;
|
package com.tiesheng.platform.config.wxmp.bean;
|
||||||
|
|
||||||
import cn.hutool.json.JSONUtil;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.tiesheng.util.service.http.OkHttpUtil;
|
import com.tiesheng.util.service.http.OkHttpUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,7 +33,7 @@ public class WxUserInfo {
|
|||||||
String s = OkHttpUtil.get("https://api.weixin.qq.com/sns/userinfo"
|
String s = OkHttpUtil.get("https://api.weixin.qq.com/sns/userinfo"
|
||||||
+ "?access_token=" + oAuth2AccessToken.getAccessToken()
|
+ "?access_token=" + oAuth2AccessToken.getAccessToken()
|
||||||
+ "&openid=" + oAuth2AccessToken.getOpenid() + "&lang=zh_CN");
|
+ "&openid=" + oAuth2AccessToken.getOpenid() + "&lang=zh_CN");
|
||||||
return JSONUtil.toBean(s, WxUserInfo.class);
|
return JSON.parseObject(s, WxUserInfo.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import cn.hutool.core.collection.CollUtil;
|
|||||||
import cn.hutool.core.lang.Validator;
|
import cn.hutool.core.lang.Validator;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.tiesheng.role.mapper.*;
|
import com.tiesheng.role.mapper.*;
|
||||||
import com.tiesheng.role.pojos.dao.CoreRoleAuthority;
|
import com.tiesheng.role.pojos.dao.CoreRoleAuthority;
|
||||||
@@ -124,7 +124,7 @@ public class CoreRoleService extends TsServiceBase<CoreRoleGroupMapper, CoreRole
|
|||||||
coreRoleGroupRx.setType("bind");
|
coreRoleGroupRx.setType("bind");
|
||||||
list.add(coreRoleGroupRx);
|
list.add(coreRoleGroupRx);
|
||||||
|
|
||||||
List<String> deps = JSONUtil.toList(authority.getDeps(), String.class);
|
List<String> deps = JSON.parseArray(authority.getDeps(), String.class);
|
||||||
for (String dep : deps) {
|
for (String dep : deps) {
|
||||||
CoreRoleGroupRx depRx = new CoreRoleGroupRx();
|
CoreRoleGroupRx depRx = new CoreRoleGroupRx();
|
||||||
depRx.setGroupId(roleGroup.getId());
|
depRx.setGroupId(roleGroup.getId());
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.tiesheng.role.service;
|
package com.tiesheng.role.service;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.tiesheng.annotation.role.RoleAuthority;
|
import com.tiesheng.annotation.role.RoleAuthority;
|
||||||
import com.tiesheng.role.mapper.CoreRoleAuthorityMapper;
|
import com.tiesheng.role.mapper.CoreRoleAuthorityMapper;
|
||||||
@@ -76,7 +76,7 @@ public class RoleAuthorityHandler implements TsAuthorityHandler {
|
|||||||
menuAuthority.setPlatform(menuPlatform);
|
menuAuthority.setPlatform(menuPlatform);
|
||||||
menuAuthority.setVersion(version);
|
menuAuthority.setVersion(version);
|
||||||
menuAuthority.setSource("auto");
|
menuAuthority.setSource("auto");
|
||||||
menuAuthority.setDeps(JSONUtil.toJsonStr(menu.deps()));
|
menuAuthority.setDeps(JSON.toJSONString(menu.deps()));
|
||||||
menuAuthority.setId(StrUtil.join("_", menuAuthority.getService(), menuAuthority.getNo()));
|
menuAuthority.setId(StrUtil.join("_", menuAuthority.getService(), menuAuthority.getNo()));
|
||||||
list.add(menuAuthority);
|
list.add(menuAuthority);
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ public class RoleAuthorityHandler implements TsAuthorityHandler {
|
|||||||
point.setParent(menuAuthority.getId());
|
point.setParent(menuAuthority.getId());
|
||||||
point.setVersion(version);
|
point.setVersion(version);
|
||||||
point.setSource("auto");
|
point.setSource("auto");
|
||||||
point.setDeps(JSONUtil.toJsonStr(authority.deps()));
|
point.setDeps(JSON.toJSONString(authority.deps()));
|
||||||
point.setPlatform(StrUtil.emptyToDefault(authority.platform(), menuPlatform));
|
point.setPlatform(StrUtil.emptyToDefault(authority.platform(), menuPlatform));
|
||||||
point.setId(StrUtil.join("_", point.getService(), point.getNo()));
|
point.setId(StrUtil.join("_", point.getService(), point.getNo()));
|
||||||
list.add(point);
|
list.add(point);
|
||||||
|
|||||||
@@ -67,12 +67,6 @@
|
|||||||
<version>${hutool.version}</version>
|
<version>${hutool.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.hutool</groupId>
|
|
||||||
<artifactId>hutool-json</artifactId>
|
|
||||||
<version>${hutool.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-db</artifactId>
|
<artifactId>hutool-db</artifactId>
|
||||||
|
|||||||
@@ -4,10 +4,8 @@ package com.tiesheng.util;
|
|||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONObject;
|
import com.alibaba.fastjson.JSON;
|
||||||
import cn.hutool.json.JSONUtil;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class CharacterUtils {
|
public class CharacterUtils {
|
||||||
|
|
||||||
@@ -24,19 +22,24 @@ public class CharacterUtils {
|
|||||||
/**
|
/**
|
||||||
* 移除特殊字符
|
* 移除特殊字符
|
||||||
*
|
*
|
||||||
* @param o 类
|
* @param o 类
|
||||||
* @param searchStr 规则
|
* @param searchStr 规则
|
||||||
*/
|
*/
|
||||||
public static void removeSymbol(Object o, String searchStr) {
|
public static void removeSymbol(Object o, String searchStr) {
|
||||||
JSONObject object = JSONUtil.parseObj(o, false);
|
JSONObject object = JSON.parseObject(JSON.toJSONString(o));
|
||||||
for (Map.Entry<String, Object> entry : object) {
|
for (String key : object.keySet()) {
|
||||||
if (ObjectUtil.isEmpty(entry.getValue()) || StrUtil.equals("null", String.valueOf(entry.getValue()))) {
|
if (StrUtil.isEmpty(key)) {
|
||||||
entry.setValue("");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (StrUtil.isNotEmpty(entry.getKey())) {
|
|
||||||
entry.setValue(StrUtil.trim(StrUtil.replace(entry.getValue().toString(), searchStr, "")));
|
Object value = object.get(key);
|
||||||
|
if (ObjectUtil.isEmpty(value) || StrUtil.equals("null", String.valueOf(value))) {
|
||||||
|
object.put(key, "");
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String replace = StrUtil.replace(String.valueOf(value), searchStr, "");
|
||||||
|
object.put(key, StrUtil.trim(replace));
|
||||||
}
|
}
|
||||||
BeanUtil.copyProperties(object, o);
|
BeanUtil.copyProperties(object, o);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.tiesheng.util.service;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.extra.servlet.ServletUtil;
|
import cn.hutool.extra.servlet.ServletUtil;
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.tiesheng.util.ServletKit;
|
import com.tiesheng.util.ServletKit;
|
||||||
import com.tiesheng.util.exception.ApiException;
|
import com.tiesheng.util.exception.ApiException;
|
||||||
import com.tiesheng.util.service.cache.TsCacheHandler;
|
import com.tiesheng.util.service.cache.TsCacheHandler;
|
||||||
@@ -36,7 +36,7 @@ public class TsCacheService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void putObj(String key, Object value, long seconds) {
|
public void putObj(String key, Object value, long seconds) {
|
||||||
tsCacheHandler.put(key, JSONUtil.toJsonStr(value), seconds);
|
tsCacheHandler.put(key, JSON.toJSONString(value), seconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String get(String key) {
|
public String get(String key) {
|
||||||
@@ -58,7 +58,7 @@ public class TsCacheService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public <T> T getObj(String key, Class<T> tClass, long seconds) {
|
public <T> T getObj(String key, Class<T> tClass, long seconds) {
|
||||||
return JSONUtil.toBean(get(key, seconds), tClass, true);
|
return JSON.parseObject(get(key, seconds), tClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(String key) {
|
public void remove(String key) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import cn.hutool.core.io.FileUtil;
|
|||||||
import cn.hutool.core.net.url.UrlQuery;
|
import cn.hutool.core.net.url.UrlQuery;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import okhttp3.*;
|
import okhttp3.*;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import cn.hutool.core.collection.CollUtil;
|
|||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.thread.ThreadUtil;
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.tiesheng.login.mapper.CoreLogLoginMapper;
|
import com.tiesheng.login.mapper.CoreLogLoginMapper;
|
||||||
import com.tiesheng.login.pojos.RequestUserInfo;
|
import com.tiesheng.login.pojos.RequestUserInfo;
|
||||||
@@ -94,14 +94,14 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
|
|||||||
coreLogProcess.setProcess(coreLogProcess.getProcess() + it.size());
|
coreLogProcess.setProcess(coreLogProcess.getProcess() + it.size());
|
||||||
coreLogProcess.setSuccessNum(coreLogProcess.getSuccessNum() + accept);
|
coreLogProcess.setSuccessNum(coreLogProcess.getSuccessNum() + accept);
|
||||||
coreLogProcess.setFailNum(coreLogProcess.getFailNum() + it.size() - accept);
|
coreLogProcess.setFailNum(coreLogProcess.getFailNum() + it.size() - accept);
|
||||||
coreLogProcess.setError(JSONUtil.toJsonStr(errorList));
|
coreLogProcess.setError(JSON.toJSONString(errorList));
|
||||||
coreLogProcessMapper.updateById(coreLogProcess);
|
coreLogProcessMapper.updateById(coreLogProcess);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 执行结束
|
// 执行结束
|
||||||
coreLogProcess.setFailFile(consumer.getFailFile());
|
coreLogProcess.setFailFile(consumer.getFailFile());
|
||||||
coreLogProcess.setStatus(1);
|
coreLogProcess.setStatus(1);
|
||||||
coreLogProcess.setError(JSONUtil.toJsonStr(errorList));
|
coreLogProcess.setError(JSON.toJSONString(errorList));
|
||||||
coreLogProcessMapper.updateById(coreLogProcess);
|
coreLogProcessMapper.updateById(coreLogProcess);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
|
|||||||
lastCount = consumer.accept(pageNum, pageSize);
|
lastCount = consumer.accept(pageNum, pageSize);
|
||||||
coreLogProcess.setTotal(coreLogProcess.getTotal() + lastCount);
|
coreLogProcess.setTotal(coreLogProcess.getTotal() + lastCount);
|
||||||
coreLogProcess.setProcess(coreLogProcess.getTotal());
|
coreLogProcess.setProcess(coreLogProcess.getTotal());
|
||||||
coreLogProcess.setError(JSONUtil.toJsonStr(errorList));
|
coreLogProcess.setError(JSON.toJSONString(errorList));
|
||||||
coreLogProcess.setSuccessNum(coreLogProcess.getSuccessNum() + lastCount);
|
coreLogProcess.setSuccessNum(coreLogProcess.getSuccessNum() + lastCount);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorList.add(e);
|
errorList.add(e);
|
||||||
@@ -148,7 +148,7 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 执行结束
|
// 执行结束
|
||||||
coreLogProcess.setError(JSONUtil.toJsonStr(errorList));
|
coreLogProcess.setError(JSON.toJSONString(errorList));
|
||||||
coreLogProcess.setStatus(1);
|
coreLogProcess.setStatus(1);
|
||||||
coreLogProcessMapper.updateById(coreLogProcess);
|
coreLogProcessMapper.updateById(coreLogProcess);
|
||||||
});
|
});
|
||||||
@@ -192,7 +192,7 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
|
|||||||
operation.setTitle(title);
|
operation.setTitle(title);
|
||||||
operation.setSubject(subject);
|
operation.setSubject(subject);
|
||||||
if (params != null) {
|
if (params != null) {
|
||||||
operation.setParams(JSONUtil.toJsonStr(params));
|
operation.setParams(JSON.toJSONString(params));
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized (CoreLogOperation.class) {
|
synchronized (CoreLogOperation.class) {
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
package com.tiesheng.web.service;
|
package com.tiesheng.web.service;
|
||||||
|
|
||||||
import cn.hutool.core.thread.ThreadUtil;
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
import cn.hutool.json.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import cn.hutool.json.JSONUtil;
|
|
||||||
import com.tiesheng.util.service.http.OkHttpUtil;
|
import com.tiesheng.util.service.http.OkHttpUtil;
|
||||||
import com.tiesheng.web.mapper.CoreLogApiMapper;
|
import com.tiesheng.web.mapper.CoreLogApiMapper;
|
||||||
import com.tiesheng.web.pojos.dao.CoreLogApi;
|
import com.tiesheng.web.pojos.dao.CoreLogApi;
|
||||||
@@ -38,11 +37,13 @@ public class LogApiOkHttpInterceptor implements Interceptor {
|
|||||||
logApi.setResult(response.code());
|
logApi.setResult(response.code());
|
||||||
peekBody.close();
|
peekBody.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logApi.setRespBody(JSONUtil.createObj()
|
|
||||||
.putOpt("code", -1)
|
JSONObject object = new JSONObject();
|
||||||
.putOpt("message", e.getMessage())
|
object.put("code", -1);
|
||||||
.putOpt("exception", e)
|
object.put("message", e.getMessage());
|
||||||
.toString());
|
object.put("exception", e);
|
||||||
|
logApi.setRespBody(object.toJSONString());
|
||||||
|
|
||||||
response = new Response.Builder()
|
response = new Response.Builder()
|
||||||
.request(request)
|
.request(request)
|
||||||
.body(OkHttpUtil.ofJsonResponse(logApi.getRespBody()))
|
.body(OkHttpUtil.ofJsonResponse(logApi.getRespBody()))
|
||||||
@@ -65,10 +66,10 @@ public class LogApiOkHttpInterceptor implements Interceptor {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (requestBody instanceof FormBody) {
|
if (requestBody instanceof FormBody) {
|
||||||
JSONObject jsonObject = JSONUtil.createObj();
|
JSONObject jsonObject = new JSONObject();
|
||||||
FormBody formBody = (FormBody) requestBody;
|
FormBody formBody = (FormBody) requestBody;
|
||||||
for (int i = 0; i < formBody.size(); i++) {
|
for (int i = 0; i < formBody.size(); i++) {
|
||||||
jsonObject.putOpt(formBody.encodedName(i), formBody.encodedValue(i));
|
jsonObject.put(formBody.encodedName(i), formBody.encodedValue(i));
|
||||||
}
|
}
|
||||||
return jsonObject.toString();
|
return jsonObject.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user