feat:jwt中的hutool-json改为fastjson

This commit is contained in:
曾文豪
2024-08-23 14:10:47 +08:00
parent 856a9f01dd
commit 9bab4cdb25
15 changed files with 105 additions and 233 deletions

View File

@@ -3,7 +3,7 @@ package com.tiesheng.encrypt.config;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.tiesheng.util.config.EncryptConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.MethodParameter;
@@ -66,7 +66,7 @@ public class DecryptRequestBodyAdvice implements RequestBodyAdvice {
DecryptHttpInputMessage(HttpInputMessage inputMessage, EncryptConfig encryptConfig) throws Exception {
this.headers = inputMessage.getHeaders();
String bodyStr = IoUtil.read(inputMessage.getBody(), CharsetUtil.CHARSET_UTF_8);
String encryptData = JSONUtil.parseObj(bodyStr).getStr("encryptData");
String encryptData = JSON.parseObject(bodyStr).getString("encryptData");
if (!StrUtil.isEmpty(encryptData)) {
String decrypt = encryptConfig.decrypt(encryptData);
this.body = IoUtil.toStream(decrypt, Charset.defaultCharset());

View File

@@ -2,7 +2,7 @@ package com.tiesheng.encrypt.config;
import cn.hutool.core.annotation.AnnotationUtil;
import cn.hutool.log.LogFactory;
import com.tiesheng.util.CommonUtil;
import com.alibaba.fastjson.JSON;
import com.tiesheng.util.config.EncryptConfig;
import com.tiesheng.util.pojos.ApiResp;
import org.springframework.beans.factory.annotation.Autowired;
@@ -42,7 +42,7 @@ public class EncryptResponseBodyAdvice implements ResponseBodyAdvice<ApiResp> {
}
body.setEncrypt(true);
body.setData(encryptConfig.encrypt(CommonUtil.writeJsonString(data)));
body.setData(encryptConfig.encrypt(JSON.toJSONString(data)));
return body;
} catch (Exception var17) {
LogFactory.get().info("加密数据异常", var17);