refactor(dependencies): 更新 fastjson 版本并移除静态资源映射
- 将 fastjson 从 1.2.47 升级到 1.2.83 版本- 移除了 application-test.yml 中的静态资源映射配置 - 删除了 src/main/resources/static/index.html 文件 - 优化了 ApiController 中的 imports 和日志输出 - 移除了 ApiTest 中未使用的 BouncyCastle 相关代码
Showing
5 changed files
with
15 additions
and
39 deletions
| ... | @@ -24,6 +24,11 @@ | ... | @@ -24,6 +24,11 @@ |
| 24 | <version>1.5.36</version> | 24 | <version>1.5.36</version> |
| 25 | </dependency> | 25 | </dependency> |
| 26 | <dependency> | 26 | <dependency> |
| 27 | <groupId>com.alibaba</groupId> | ||
| 28 | <artifactId>fastjson</artifactId> | ||
| 29 | <version>1.2.83</version> | ||
| 30 | </dependency> | ||
| 31 | <dependency> | ||
| 27 | <groupId>cn.hutool</groupId> | 32 | <groupId>cn.hutool</groupId> |
| 28 | <artifactId>hutool-all</artifactId> | 33 | <artifactId>hutool-all</artifactId> |
| 29 | <version>5.8.26</version> | 34 | <version>5.8.26</version> | ... | ... |
| ... | @@ -2,7 +2,7 @@ package com.topdraw.dockingapi.controller; | ... | @@ -2,7 +2,7 @@ package com.topdraw.dockingapi.controller; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.map.MapBuilder; | 3 | import cn.hutool.core.map.MapBuilder; |
| 4 | import cn.hutool.core.util.StrUtil; | 4 | import cn.hutool.core.util.StrUtil; |
| 5 | import com.alibaba.fastjson.JSONArray; | 5 | import com.alibaba.fastjson.JSON; |
| 6 | import com.alibaba.fastjson.JSONObject; | 6 | import com.alibaba.fastjson.JSONObject; |
| 7 | import com.digital.szzz.gateway.sdk.api.GatewaySender; | 7 | import com.digital.szzz.gateway.sdk.api.GatewaySender; |
| 8 | import com.digital.szzz.gateway.sdk.bean.GatewayResponse; | 8 | import com.digital.szzz.gateway.sdk.bean.GatewayResponse; |
| ... | @@ -85,7 +85,8 @@ public class ApiController { | ... | @@ -85,7 +85,8 @@ public class ApiController { |
| 85 | param.put("appId", appId); | 85 | param.put("appId", appId); |
| 86 | String userId = data.getString("userId"); | 86 | String userId = data.getString("userId"); |
| 87 | param.put("userId", userId); | 87 | param.put("userId", userId); |
| 88 | param.put("forceScopes", new JSONArray().fluentAdd("ykb_user_info").fluentAdd("ykb_divide")); | 88 | param.put("forceScopes", new com.alibaba.fastjson.JSONArray() |
| 89 | .fluentAdd("ykb_user_info").fluentAdd("ykb_divide")); | ||
| 89 | Map<String, String> headerMap = new HashMap<>(); | 90 | Map<String, String> headerMap = new HashMap<>(); |
| 90 | return GatewaySender.send(url, appId, method, | 91 | return GatewaySender.send(url, appId, method, |
| 91 | iv, appKey, appSecretKey, | 92 | iv, appKey, appSecretKey, |
| ... | @@ -102,7 +103,7 @@ public class ApiController { | ... | @@ -102,7 +103,7 @@ public class ApiController { |
| 102 | GatewayResponse send = GatewaySender.send(url, appId, method, | 103 | GatewayResponse send = GatewaySender.send(url, appId, method, |
| 103 | iv, appKey, appSecretKey, param, authCode, | 104 | iv, appKey, appSecretKey, param, authCode, |
| 104 | headerMap, readTimeout, connTimeout); | 105 | headerMap, readTimeout, connTimeout); |
| 105 | log.info("获取手机号返回的结果是:{}", JSONArray.toJSONString(send)); | 106 | log.info("获取手机号返回的结果是:{}", JSON.toJSONString(send)); |
| 106 | String data = send.getData(); | 107 | String data = send.getData(); |
| 107 | return Optional.ofNullable(JSONObject.parseObject(data, JSONObject.class)) | 108 | return Optional.ofNullable(JSONObject.parseObject(data, JSONObject.class)) |
| 108 | .map(t -> t.getJSONObject("data")) | 109 | .map(t -> t.getJSONObject("data")) | ... | ... |
src/main/resources/static/index.html
deleted
100644 → 0
| ... | @@ -2,7 +2,6 @@ package com.topdraw.dockingapi; | ... | @@ -2,7 +2,6 @@ package com.topdraw.dockingapi; |
| 2 | 2 | ||
| 3 | import com.topdraw.dockingapi.util.DecryptUtils; | 3 | import com.topdraw.dockingapi.util.DecryptUtils; |
| 4 | import lombok.SneakyThrows; | 4 | import lombok.SneakyThrows; |
| 5 | import org.bouncycastle.jce.provider.BouncyCastleProvider; | ||
| 6 | import org.junit.jupiter.api.Test; | 5 | import org.junit.jupiter.api.Test; |
| 7 | 6 | ||
| 8 | import javax.crypto.Cipher; | 7 | import javax.crypto.Cipher; |
| ... | @@ -18,26 +17,7 @@ import java.security.Security; | ... | @@ -18,26 +17,7 @@ import java.security.Security; |
| 18 | public class ApiTest { | 17 | public class ApiTest { |
| 19 | 18 | ||
| 20 | 19 | ||
| 21 | @Test | 20 | |
| 22 | public void testMain() throws Exception { | ||
| 23 | // 添加BouncyCastle提供者 | ||
| 24 | Security.addProvider(new BouncyCastleProvider()); | ||
| 25 | // 密钥 | ||
| 26 | byte[] keyBytes = "wmsj2021".getBytes(StandardCharsets.UTF_8); // DES密钥长度为8字节 | ||
| 27 | // 需要加密的数据 | ||
| 28 | String text = "{\"phoneNum\":\"13627618074\"}"; | ||
| 29 | byte[] data = text.getBytes(StandardCharsets.UTF_8); | ||
| 30 | // 创建密钥 | ||
| 31 | SecretKeySpec secretKeySpec = new SecretKeySpec(keyBytes, "DES"); | ||
| 32 | // 创建Cipher实例 | ||
| 33 | Cipher cipher = Cipher.getInstance("DES/ECB/PKCS7Padding", "BC"); | ||
| 34 | // 初始化Cipher | ||
| 35 | cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec); | ||
| 36 | // 执行加密 | ||
| 37 | byte[] encryptedData = cipher.doFinal(data); | ||
| 38 | // 打印加密结果(通常加密后的数据进行Base64编码或者十六进制编码显示) | ||
| 39 | System.out.println("Encrypted Data: " + bytesToHex(encryptedData)); | ||
| 40 | } | ||
| 41 | 21 | ||
| 42 | // 将字节转换为十六进制字符串 | 22 | // 将字节转换为十六进制字符串 |
| 43 | public static String bytesToHex(byte[] bytes) { | 23 | public static String bytesToHex(byte[] bytes) { | ... | ... |
-
Please register or sign in to post a comment