Commit 504be995 authored by hongguangwu's avatar hongguangwu

MVP1.7.12-对接瓜子接口

parent f20dbd51
package com.yifu.cloud.plus.v1.yifu.archives.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.web.client.RestTemplate;
import java.util.Date;
/**
* @Author: hgw
......@@ -24,4 +35,43 @@ public class GzConfig {
private String tid;
@Value("${gz.appUrl}")
private String appUrl;
private static final String APP_KEY = "appKey";
private static final String TIMESTAMP = "timestamp";
private static final String X_REQ_NONCE = "xReqNonce";
private static final String VERSION = "version";
public boolean getGzBankInfo(RestTemplate restTemplate, long expires, String signature, String pageNum
, String pageSize, String startTime, String endTime) {
String gzBankUrl = appUrl + "/eim-hr-induction/api/hr/induction/open/base/bank-branch?pageNum=%s&pageSize=%s&startTime=%s&endTime=%s&appkey=%s&expires=%s&signature=%s";
String requestUrl = String.format(gzBankUrl, pageNum, pageSize, startTime, endTime, appkey, expires, signature);
//String result = restTemplate.getForObject(requestUrl, String.class);
// 创建请求头并添加Authorization
HttpHeaders headers = new HttpHeaders();
headers.set("Authorization", "00000000"); // 设置Authorization头
// 创建HttpEntity,包含headers(GET请求没有body,所以为null)
HttpEntity<String> entity = new HttpEntity<>(null, headers);
// 发送GET请求
String result = restTemplate.exchange(requestUrl, HttpMethod.GET, entity, String.class).getBody();
if (result != null && result.contains("code") && result.contains("data")) {
JSONObject resultObject = JSON.parseObject(result);
String code = resultObject.getString("code");
if (Common.isNotNull(code) && "S00000".equals(code)) {
String data = resultObject.getString("data");
JSONObject dataObject = JSON.parseObject(data);
String bankCd = dataObject.getString("bankCd");
String cnapsId = dataObject.getString("cnapsId");
// TODO - 继续解析参数并存储
System.out.println("bankCd=" + bankCd);
System.out.println("cnapsId=" + cnapsId);
return true;
}
}
return false;
}
}
......@@ -26,9 +26,12 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
......@@ -50,12 +53,13 @@ public class TGzController {
private final TGzOfferInfoService tGzOfferInfoService;
private RestTemplate restTemplate = new RestTemplate();
/**
* 接收推送信息的接口
*
* @param params 包含业务参数和签名的Map
* @return 处理结果
*/
* @Description: 接收瓜子推送过来的Offer信息
* @Author: hgw
* @Date: 2025/6/23 15:27
* @return: com.yifu.cloud.plus.v1.yifu.archives.utils.ReturnGz<java.lang.String>
**/
@PostMapping("/saveOfferInfo")
public ReturnGz<String> saveOfferInfo(@RequestBody TGzOfferInfo tGzOfferInfo
, @RequestParam String appkey, @RequestParam String expires, @RequestParam String signature) {
......@@ -87,8 +91,6 @@ public class TGzController {
/**
* 处理推送的业务数据
*
* @param params 业务参数
* @return 处理结果
*/
private ReturnGz<String> saveData(TGzOfferInfo tGzOfferInfo) {
......@@ -101,5 +103,23 @@ public class TGzController {
return ReturnGz.ok();
}
/**
* @Description: 获取瓜子银行支行信息的接口
* @Author: hgw
* @Date: 2025/6/23 15:28
* @return: boolean
**/
@PostMapping("/getGzBank")
public boolean getGzBank(@RequestParam String pageNum, @RequestParam String pageSize
, @RequestParam String startTime, @RequestParam String endTime) {
Map<String, Object> params = new HashMap<>();
params.put("appkey", gzConfig.getAppkey());
long expires = new Date().getTime() + 30000;
params.put("expires", expires);
// 2. 计算期望的签名
String signature = GZSign.getSignature(params, gzConfig.getAppsecret());
return gzConfig.getGzBankInfo(restTemplate, expires, signature, pageNum,pageSize,startTime,endTime);
}
}
......@@ -58,6 +58,7 @@ security:
- /employeeregistrationpre/judgeIsSimple
- /tgzempinfo/getInfoByOfferId
- /gz/core/saveOfferInfo
- /gz/core/getGzBank
# 文件上传相关 支持阿里云、华为云、腾讯、minio
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment