|
|
@@ -6,7 +6,9 @@ import com.jfinal.kit.HttpKit;
|
|
|
import com.jfinal.kit.StrKit;
|
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
public class HygSDK {
|
|
|
@@ -16,9 +18,6 @@ public class HygSDK {
|
|
|
private final static String AES_KEY = System.getenv("HYG_AES_KEY");
|
|
|
private final static String COOPERATOR_ID = System.getenv("HYG_COOPERATOR_ID");
|
|
|
|
|
|
- // API 路径常量
|
|
|
- private static final String FIND_DETAILS_API = "/api/v2/hire/worker/findDetails";
|
|
|
-
|
|
|
/**
|
|
|
* 自由职业者信息详情查询接口
|
|
|
* 接口地址: https://${domain}/api/v2/hire/worker/findDetails
|
|
|
@@ -28,11 +27,20 @@ public class HygSDK {
|
|
|
* @throws Exception 如果请求或签名发生错误
|
|
|
*/
|
|
|
public static JSONObject findWorkerDetails(String workerId) throws Exception {
|
|
|
- // 构建业务请求参数 Map
|
|
|
Map<String, Object> bizParams = new HashMap<>();
|
|
|
- bizParams.put("workerId", workerId); // 自由职业者ID
|
|
|
+ bizParams.put("workerId", workerId);
|
|
|
+
|
|
|
+ return HygSDK.invokeApi("/api/v2/hire/worker/findDetails", bizParams);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static JSONObject findDepositAccount() throws Exception {
|
|
|
+ Map<String, Object> bizParams = new HashMap<>();
|
|
|
+
|
|
|
+ List<String> cooperatorIdList = new ArrayList<>();
|
|
|
+ cooperatorIdList.add(COOPERATOR_ID);
|
|
|
+ bizParams.put("cooperatorIdList", cooperatorIdList);
|
|
|
|
|
|
- return HygSDK.invokeApi(FIND_DETAILS_API, bizParams);
|
|
|
+ return HygSDK.invokeApi("/batch/query/cooperator/account", bizParams);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -54,7 +62,6 @@ public class HygSDK {
|
|
|
|
|
|
// 签名
|
|
|
String sortedParamString = RSAUtils.sortParam(fullParams);
|
|
|
- System.out.println(sortedParamString);
|
|
|
String sign = RSAUtils.sign(sortedParamString.getBytes(StandardCharsets.UTF_8), RSA_PRIVATE_KEY);
|
|
|
fullParams.put("sign", sign);
|
|
|
|
|
|
@@ -65,7 +72,6 @@ public class HygSDK {
|
|
|
Map<String, Object> finalParams = new HashMap<>();
|
|
|
finalParams.put("cooperatorId", COOPERATOR_ID);
|
|
|
String jsonStr = JSONObject.toJSONString(fullParams);
|
|
|
- System.out.println(jsonStr);
|
|
|
finalParams.put("businessBody", AESUtils.encrypt2Hex(jsonStr, AES_KEY));
|
|
|
|
|
|
// 请求头
|
|
|
@@ -82,14 +88,16 @@ public class HygSDK {
|
|
|
|
|
|
// 解密返回值
|
|
|
JSONObject responseJson = JSON.parseObject(responseBody);
|
|
|
- responseJson.put("data", JSONObject.parseObject(AESUtils.decryptByHex(responseJson.getString("data"))));
|
|
|
+ String decodeRest = AESUtils.decryptByHex(responseJson.getString("data"));
|
|
|
+ responseJson.put("data", JSONObject.parse(decodeRest));
|
|
|
|
|
|
return responseJson;
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
try {
|
|
|
- System.out.println(HygSDK.findWorkerDetails("W1417202514024992768"));
|
|
|
+ // System.out.println(HygSDK.findWorkerDetails(""));
|
|
|
+ System.out.println(HygSDK.findDepositAccount());
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|