diff --git a/pom.xml b/pom.xml
index fd780bb..fe32360 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,9 +6,9 @@
com.tsl3060.open.extend
tsl-open-sdk-java-wanshun
- 0.3.14
+ 0.3.15
-
+
UTF-8
8
8
@@ -16,7 +16,7 @@
UTF-8
5.8.19
- 1.4.7
+ 1.4.14
@@ -42,7 +42,7 @@
org.bouncycastle
bcprov-jdk15to18
- 1.69
+ 1.74
org.junit.jupiter
@@ -53,7 +53,7 @@
com.squareup.okhttp3
okhttp
- 4.10.0
+ 4.11.0
com.alibaba.fastjson2
diff --git a/src/main/java/com/tsl3060/open/extend/core/ApiClient.java b/src/main/java/com/tsl3060/open/extend/core/ApiClient.java
index 10ca506..d83130b 100644
--- a/src/main/java/com/tsl3060/open/extend/core/ApiClient.java
+++ b/src/main/java/com/tsl3060/open/extend/core/ApiClient.java
@@ -6,7 +6,7 @@ import cn.hutool.core.util.XmlUtil;
import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;
import com.alibaba.fastjson2.JSON;
-import com.alibaba.fastjson2.JSONObject;
+import com.alibaba.fastjson2.JSONWriter;
import com.tsl3060.open.extend.core.constant.BuildInfo;
import com.tsl3060.open.extend.core.exception.ApiException;
import com.tsl3060.open.extend.core.exception.BadResourceException;
@@ -132,7 +132,7 @@ public class ApiClient {
ISecure iSecure = getSecureTool().getSecure(apiRequest.getSignType());
String signStr = iSecure.requestSign(apiRequest);
apiRequest.setSign(signStr);
- String fBody = JSON.toJSONString(apiRequest);
+ String fBody = JSON.toJSONString(apiRequest, JSONWriter.Feature.WriteNullStringAsEmpty, JSONWriter.Feature.WriteNullListAsEmpty);
log.debug(">>> {}", fBody);
RequestBody requestBody = RequestBody.create(fBody, contentType);
/**
diff --git a/src/main/java/com/tsl3060/open/extend/core/payload/UserRelationPayload.java b/src/main/java/com/tsl3060/open/extend/core/payload/UserRelationPayload.java
new file mode 100644
index 0000000..1dd159c
--- /dev/null
+++ b/src/main/java/com/tsl3060/open/extend/core/payload/UserRelationPayload.java
@@ -0,0 +1,41 @@
+package com.tsl3060.open.extend.core.payload;
+
+import com.tsl3060.open.extend.core.IApiRequest;
+
+import java.util.List;
+
+public class UserRelationPayload extends RequestPayload implements IApiRequest {
+ @Override
+ public String path() {
+ return "/v1/wanshun/user/relation";
+ }
+
+ private String openid;
+ private String parentId;
+ private List children;
+
+
+ public String getOpenid() {
+ return openid;
+ }
+
+ public void setOpenid(String openid) {
+ this.openid = openid;
+ }
+
+ public String getParentId() {
+ return parentId;
+ }
+
+ public void setParentId(String parentId) {
+ this.parentId = parentId;
+ }
+
+ public List getChildren() {
+ return children;
+ }
+
+ public void setChildren(List children) {
+ this.children = children;
+ }
+}
diff --git a/src/main/java/com/tsl3060/open/extend/core/response/UserRelationResponse.java b/src/main/java/com/tsl3060/open/extend/core/response/UserRelationResponse.java
new file mode 100644
index 0000000..5dcb4aa
--- /dev/null
+++ b/src/main/java/com/tsl3060/open/extend/core/response/UserRelationResponse.java
@@ -0,0 +1,13 @@
+package com.tsl3060.open.extend.core.response;
+
+public class UserRelationResponse {
+ private boolean result;
+
+ public boolean isResult() {
+ return result;
+ }
+
+ public void setResult(boolean result) {
+ this.result = result;
+ }
+}
diff --git a/src/main/java/com/tsl3060/open/extend/core/secure/RSASecure.java b/src/main/java/com/tsl3060/open/extend/core/secure/RSASecure.java
index 6f711cb..929fad4 100644
--- a/src/main/java/com/tsl3060/open/extend/core/secure/RSASecure.java
+++ b/src/main/java/com/tsl3060/open/extend/core/secure/RSASecure.java
@@ -1,14 +1,13 @@
package com.tsl3060.open.extend.core.secure;
-import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.HexUtil;
+import cn.hutool.core.util.StrUtil;
import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;
import com.alibaba.fastjson2.JSONObject;
import com.tsl3060.open.extend.core.*;
import java.io.UnsupportedEncodingException;
-import java.math.BigDecimal;
import java.nio.charset.Charset;
import java.security.*;
import java.security.spec.InvalidKeySpecException;
@@ -36,33 +35,53 @@ public class RSASecure implements ISecure {
}
private String object2LinkStr(Object ob) {
- List payloadStr = new ArrayList<>();
- if (ob != null) {
- JSONObject j = JSONObject.from(ob);
- //排序
- Set _keys = j.keySet();
- List keys = _keys.stream().sorted(Comparator.naturalOrder()).collect(Collectors.toList());
-
- for (String key : keys) {
- if (j.get(key) != null) {
- Object v = j.get(key);
- String vx;
- if (v instanceof Double) {
- vx = String.format("%s", v);
- } else if (v instanceof Float) {
- vx = String.format("%s", v);
- } else if (v instanceof Boolean) {
- vx = String.format("%s", v);
- } else if (v instanceof BigDecimal) {
- vx = String.format("%s", v);
- } else {
- vx = String.valueOf(v);
+ if (ob == null) {
+ return "";
+ }
+ if (ob instanceof String) {
+ if (StrUtil.isEmpty(ob.toString())) {
+ return "";
+ }
+ }
+
+ JSONObject root = JSONObject.from(ob);
+ Set _keys = root.keySet();
+ List keys = new ArrayList<>(_keys);
+
+ List keyValuePairs = new ArrayList<>();
+
+ keys.forEach(key -> {
+ Object valueNode = root.get(key);
+
+ String valueStr;
+ if (valueNode instanceof Number) {
+ valueStr = String.format("%s", valueNode);
+ } else if (valueNode instanceof Boolean) {
+ valueStr = String.format("%s", valueNode);
+ } else if (valueNode instanceof List) {
+ List arrayValues = new ArrayList<>();
+ List> values = (List>) valueNode;
+ values.forEach(value -> {
+ if (value instanceof String) {
+ arrayValues.add(String.format("%s", value));
+ }else{
+ arrayValues.add(object2LinkStr(value));
}
- payloadStr.add(String.format("%s=%s", key, vx));
+ });
+
+ valueStr = String.join(",", arrayValues);
+ } else {
+ if(valueNode==null){
+ valueNode="";
}
+ valueStr = String.format("%s", valueNode);
}
- }
- return CollectionUtil.join(payloadStr, "&");
+ keyValuePairs.add(String.format("%s=%s",key,valueStr));
+ });
+ return keyValuePairs.stream()
+ .sorted()
+ .collect(Collectors.joining("&"));
+
}
public String sign(String content, String charset) {
@@ -110,7 +129,6 @@ public class RSASecure implements ISecure {
request.getTime(),
waitStr
);
- log.debug("req: {}", content);
return this.sign(content, request.getCharset());