mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
2.5.3
This commit is contained in:
@@ -1,19 +1,15 @@
|
||||
package com.gitee.sop.servercommon.manager;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.gitee.sop.servercommon.bean.ServiceApiInfo;
|
||||
import com.gitee.sop.servercommon.route.RouteDefinition;
|
||||
import com.gitee.sop.servercommon.route.ServiceRouteInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.util.DigestUtils;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author tanghc
|
||||
@@ -83,7 +79,7 @@ public class ServiceRouteInfoBuilder {
|
||||
}
|
||||
|
||||
protected String buildServletPath(ServiceApiInfo serviceApiInfo, ServiceApiInfo.ApiMeta apiMeta) {
|
||||
String contextPath = environment.getProperty("server.servlet.context-path", DEFAULT_CONTEXT_PATH);
|
||||
String contextPath = environment.getProperty("server.servlet.context-path", getContextPathForOld());
|
||||
String servletPath = apiMeta.getPath();
|
||||
if (servletPath == null) {
|
||||
servletPath = "";
|
||||
@@ -98,6 +94,14 @@ public class ServiceRouteInfoBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 兼容老版本获取context-path
|
||||
* @return 返回context-path,没有返回/
|
||||
*/
|
||||
private String getContextPathForOld() {
|
||||
return environment.getProperty("server.context-path", DEFAULT_CONTEXT_PATH);
|
||||
}
|
||||
|
||||
private void checkPath(String path, String errorMsg) {
|
||||
if (path.contains(PATH_SPLIT)) {
|
||||
throw new IllegalArgumentException(errorMsg);
|
||||
|
@@ -234,6 +234,13 @@ public class AlipayController {
|
||||
return Arrays.asList(storyVO, storyVO2);
|
||||
}
|
||||
|
||||
@ApiAbility
|
||||
@RequestMapping("getJson")
|
||||
public Object getJson(@RequestBody JSONObject param) {
|
||||
return param;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 演示文档表格树
|
||||
*
|
||||
|
@@ -264,4 +264,37 @@ public class AlipayClientPostTest extends TestBase {
|
||||
System.out.println(responseData);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetJson() throws AlipayApiException {
|
||||
// 公共请求参数
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("app_id", appId);
|
||||
params.put("method", "getJson");
|
||||
params.put("version", "1.0");
|
||||
params.put("format", "json");
|
||||
params.put("charset", "utf-8");
|
||||
params.put("sign_type", "RSA2");
|
||||
params.put("timestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
||||
// 业务参数
|
||||
Map<String, String> bizContent = new HashMap<>();
|
||||
bizContent.put("name", "Jim");
|
||||
bizContent.put("age", "2");
|
||||
|
||||
params.put("biz_content", JSON.toJSONString(bizContent));
|
||||
|
||||
System.out.println("----------- 请求信息 -----------");
|
||||
System.out.println("请求参数:" + buildParamQuery(params));
|
||||
System.out.println("商户秘钥:" + privateKey);
|
||||
String content = AlipaySignature.getSignContent(params);
|
||||
System.out.println("待签名内容:" + content);
|
||||
String sign = AlipaySignature.rsa256Sign(content, privateKey, "utf-8");
|
||||
System.out.println("签名(sign):" + sign);
|
||||
|
||||
params.put("sign", sign);
|
||||
|
||||
System.out.println("----------- 返回结果 -----------");
|
||||
String responseData = get(url, params);// 发送请求
|
||||
System.out.println(responseData);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user