mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
1.13.5
This commit is contained in:
@@ -30,7 +30,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.gitee.sop</groupId>
|
<groupId>com.gitee.sop</groupId>
|
||||||
<artifactId>sop-registry-api</artifactId>
|
<artifactId>sop-registry-api</artifactId>
|
||||||
<version>1.13.4-SNAPSHOT</version>
|
<version>1.13.5-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- easyopen starter -->
|
<!-- easyopen starter -->
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.gitee.sop</groupId>
|
<groupId>com.gitee.sop</groupId>
|
||||||
<artifactId>sop-common</artifactId>
|
<artifactId>sop-common</artifactId>
|
||||||
<version>1.13.4-SNAPSHOT</version>
|
<version>1.13.5-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
@@ -5,11 +5,11 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.gitee.sop</groupId>
|
<groupId>com.gitee.sop</groupId>
|
||||||
<artifactId>sop-common</artifactId>
|
<artifactId>sop-common</artifactId>
|
||||||
<version>1.13.4-SNAPSHOT</version>
|
<version>1.13.5-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>sop-gateway-common</artifactId>
|
<artifactId>sop-gateway-common</artifactId>
|
||||||
<version>1.13.4-SNAPSHOT</version>
|
<version>1.13.5-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>sop-gateway-common</name>
|
<name>sop-gateway-common</name>
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.gitee.sop</groupId>
|
<groupId>com.gitee.sop</groupId>
|
||||||
<artifactId>sop-registry-api</artifactId>
|
<artifactId>sop-registry-api</artifactId>
|
||||||
<version>1.13.4-SNAPSHOT</version>
|
<version>1.13.5-SNAPSHOT</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
@@ -6,11 +6,11 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.gitee.sop</groupId>
|
<groupId>com.gitee.sop</groupId>
|
||||||
<artifactId>sop-common</artifactId>
|
<artifactId>sop-common</artifactId>
|
||||||
<version>1.13.4-SNAPSHOT</version>
|
<version>1.13.5-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>sop-service-common</artifactId>
|
<artifactId>sop-service-common</artifactId>
|
||||||
<version>1.13.4-SNAPSHOT</version>
|
<version>1.13.5-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>sop-service-common</name>
|
<name>sop-service-common</name>
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.gitee.sop</groupId>
|
<groupId>com.gitee.sop</groupId>
|
||||||
<artifactId>sop-service-common</artifactId>
|
<artifactId>sop-service-common</artifactId>
|
||||||
<version>1.13.4-SNAPSHOT</version>
|
<version>1.13.5-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.gitee.sop</groupId>
|
<groupId>com.gitee.sop</groupId>
|
||||||
<artifactId>sop-service-common</artifactId>
|
<artifactId>sop-service-common</artifactId>
|
||||||
<version>1.13.4-SNAPSHOT</version>
|
<version>1.13.5-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.gitee.sop</groupId>
|
<groupId>com.gitee.sop</groupId>
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.gitee.sop</groupId>
|
<groupId>com.gitee.sop</groupId>
|
||||||
<artifactId>sop-service-common</artifactId>
|
<artifactId>sop-service-common</artifactId>
|
||||||
<version>1.13.4-SNAPSHOT</version>
|
<version>1.13.5-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.gitee.sop</groupId>
|
<groupId>com.gitee.sop</groupId>
|
||||||
<artifactId>sop-service-common</artifactId>
|
<artifactId>sop-service-common</artifactId>
|
||||||
<version>1.13.4-SNAPSHOT</version>
|
<version>1.13.5-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- eureka 服务发现 -->
|
<!-- eureka 服务发现 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.gitee.sop</groupId>
|
<groupId>com.gitee.sop</groupId>
|
||||||
<artifactId>sop-service-common</artifactId>
|
<artifactId>sop-service-common</artifactId>
|
||||||
<version>1.13.4-SNAPSHOT</version>
|
<version>1.13.5-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.gitee.sop</groupId>
|
<groupId>com.gitee.sop</groupId>
|
||||||
|
@@ -30,7 +30,7 @@ public class AlipayController {
|
|||||||
// http://localhost:2222/story_get
|
// http://localhost:2222/story_get
|
||||||
// 原生的接口,可正常调用
|
// 原生的接口,可正常调用
|
||||||
@RequestMapping("story_get")
|
@RequestMapping("story_get")
|
||||||
public Story getStory4() {
|
public Story story_get() {
|
||||||
Story story = new Story();
|
Story story = new Story();
|
||||||
story.setId(1);
|
story.setId(1);
|
||||||
story.setName("海底小纵队(原生)");
|
story.setName("海底小纵队(原生)");
|
||||||
@@ -117,7 +117,7 @@ public class AlipayController {
|
|||||||
// http://localhost:2222/getStory2?version=2.1
|
// http://localhost:2222/getStory2?version=2.1
|
||||||
// 遗留接口具备开放平台能力,在原来的基础上加版本号
|
// 遗留接口具备开放平台能力,在原来的基础上加版本号
|
||||||
@ApiAbility(version = "2.1")
|
@ApiAbility(version = "2.1")
|
||||||
@RequestMapping("getStory2")
|
@GetMapping("getStory2")
|
||||||
public Story getStory2_1() {
|
public Story getStory2_1() {
|
||||||
Story story = new Story();
|
Story story = new Story();
|
||||||
story.setId(1);
|
story.setId(1);
|
||||||
|
@@ -37,5 +37,25 @@ public class PostJsonController {
|
|||||||
return story;
|
return story;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 演示客户端使用json方式请求(application/json)
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiMapping(value = "demo.post.json", version = "1.2")
|
||||||
|
public Story postJson2(StoryParam param) {
|
||||||
|
// 获取开放平台请求参数
|
||||||
|
OpenContext openContext = ServiceContext.getCurrentContext().getOpenContext();
|
||||||
|
List<Object> params = Arrays.asList(
|
||||||
|
openContext.getAppId(),
|
||||||
|
openContext.getMethod(),
|
||||||
|
openContext.getVersion()
|
||||||
|
);
|
||||||
|
Story story = new Story();
|
||||||
|
story.setId(1);
|
||||||
|
story.setName("1.2 参数:" + param.getName() + ", openParams:" + StringUtils.join(params));
|
||||||
|
return story;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.gitee.sop</groupId>
|
<groupId>com.gitee.sop</groupId>
|
||||||
<artifactId>sop-gateway-common</artifactId>
|
<artifactId>sop-gateway-common</artifactId>
|
||||||
<version>1.13.4-SNAPSHOT</version>
|
<version>1.13.5-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- ↓↓↓ 使用spring cloud zuul ↓↓↓ -->
|
<!-- ↓↓↓ 使用spring cloud zuul ↓↓↓ -->
|
||||||
|
@@ -118,7 +118,7 @@ public class OpenHttp {
|
|||||||
* @return
|
* @return
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public String request(String url, Map<String, String> form, Map<String, String> header, String method) throws IOException {
|
public String request(String url, Map<String, String> form, Map<String, String> header, HTTPMethod method) throws IOException {
|
||||||
Request.Builder requestBuilder = buildRequestBuilder(url, form, method);
|
Request.Builder requestBuilder = buildRequestBuilder(url, form, method);
|
||||||
// 添加header
|
// 添加header
|
||||||
addHeader(requestBuilder, header);
|
addHeader(requestBuilder, header);
|
||||||
@@ -134,21 +134,21 @@ public class OpenHttp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Request.Builder buildRequestBuilder(String url, Map<String, String> form, String method) {
|
public static Request.Builder buildRequestBuilder(String url, Map<String, String> form, HTTPMethod method) {
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case "get":
|
case GET:
|
||||||
return new Request.Builder()
|
return new Request.Builder()
|
||||||
.url(buildHttpUrl(url, form))
|
.url(buildHttpUrl(url, form))
|
||||||
.get();
|
.get();
|
||||||
case "head":
|
case HEAD:
|
||||||
return new Request.Builder()
|
return new Request.Builder()
|
||||||
.url(buildHttpUrl(url, form))
|
.url(buildHttpUrl(url, form))
|
||||||
.head();
|
.head();
|
||||||
case "put":
|
case PUT:
|
||||||
return new Request.Builder()
|
return new Request.Builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.put(buildFormBody(form));
|
.put(buildFormBody(form));
|
||||||
case "delete":
|
case DELETE:
|
||||||
return new Request.Builder()
|
return new Request.Builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.delete(buildFormBody(form));
|
.delete(buildFormBody(form));
|
||||||
@@ -241,5 +241,22 @@ public class OpenHttp {
|
|||||||
this.httpClient = httpClient;
|
this.httpClient = httpClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum HTTPMethod {
|
||||||
|
GET,
|
||||||
|
POST,
|
||||||
|
PUT,
|
||||||
|
HEAD,
|
||||||
|
DELETE;
|
||||||
|
|
||||||
|
private HTTPMethod() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String value() {
|
||||||
|
return this.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HTTPMethod fromValue(String v) {
|
||||||
|
return valueOf(v.toUpperCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -111,7 +111,7 @@ public class HttpTool {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public String request(String url, Map<String, String> form, Map<String, String> header, HTTPMethod method) throws IOException {
|
public String request(String url, Map<String, String> form, Map<String, String> header, HTTPMethod method) throws IOException {
|
||||||
Request.Builder requestBuilder = buildRequestBuilder(url, form, method.value());
|
Request.Builder requestBuilder = buildRequestBuilder(url, form, method);
|
||||||
// 添加header
|
// 添加header
|
||||||
addHeader(requestBuilder, header);
|
addHeader(requestBuilder, header);
|
||||||
|
|
||||||
@@ -153,21 +153,21 @@ public class HttpTool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Request.Builder buildRequestBuilder(String url, Map<String, String> form, String method) {
|
public static Request.Builder buildRequestBuilder(String url, Map<String, String> form, HTTPMethod method) {
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case "get":
|
case GET:
|
||||||
return new Request.Builder()
|
return new Request.Builder()
|
||||||
.url(buildHttpUrl(url, form))
|
.url(buildHttpUrl(url, form))
|
||||||
.get();
|
.get();
|
||||||
case "head":
|
case HEAD:
|
||||||
return new Request.Builder()
|
return new Request.Builder()
|
||||||
.url(buildHttpUrl(url, form))
|
.url(buildHttpUrl(url, form))
|
||||||
.head();
|
.head();
|
||||||
case "put":
|
case PUT:
|
||||||
return new Request.Builder()
|
return new Request.Builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.put(buildFormBody(form));
|
.put(buildFormBody(form));
|
||||||
case "delete":
|
case DELETE:
|
||||||
return new Request.Builder()
|
return new Request.Builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.delete(buildFormBody(form));
|
.delete(buildFormBody(form));
|
||||||
|
@@ -231,4 +231,35 @@ public class AlipayClientPostTest extends TestBase {
|
|||||||
System.out.println(responseData);
|
System.out.println(responseData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetStory2() throws AlipayApiException {
|
||||||
|
// 公共请求参数
|
||||||
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
|
params.put("app_id", appId);
|
||||||
|
params.put("method", "getStory2");
|
||||||
|
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<>();
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -49,7 +49,41 @@ public class PostJsonTest extends TestBase {
|
|||||||
params.put("sign", sign);
|
params.put("sign", sign);
|
||||||
|
|
||||||
System.out.println("----------- 返回结果 -----------");
|
System.out.println("----------- 返回结果 -----------");
|
||||||
String responseData = get(url, params);// 发送请求
|
String responseData = postJson(url, params);// 发送请求
|
||||||
|
System.out.println(responseData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPostJson2() throws Exception {
|
||||||
|
|
||||||
|
// 公共请求参数
|
||||||
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
|
params.put("app_id", appId);
|
||||||
|
params.put("method", "demo.post.json");
|
||||||
|
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()));
|
||||||
|
params.put("version", "1.2");
|
||||||
|
|
||||||
|
// 业务参数
|
||||||
|
Map<String, String> bizContent = new HashMap<>();
|
||||||
|
bizContent.put("name", "葫芦娃");
|
||||||
|
|
||||||
|
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 = postJson(url, params);// 发送请求
|
||||||
System.out.println(responseData);
|
System.out.println(responseData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.gitee.sop</groupId>
|
<groupId>com.gitee.sop</groupId>
|
||||||
<artifactId>sop-registry-api</artifactId>
|
<artifactId>sop-registry-api</artifactId>
|
||||||
<version>1.13.4-SNAPSHOT</version>
|
<version>1.13.5-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@@ -111,7 +111,7 @@ public class HttpTool {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public String request(String url, Map<String, String> form, Map<String, String> header, HTTPMethod method) throws IOException {
|
public String request(String url, Map<String, String> form, Map<String, String> header, HTTPMethod method) throws IOException {
|
||||||
Request.Builder requestBuilder = buildRequestBuilder(url, form, method.value());
|
Request.Builder requestBuilder = buildRequestBuilder(url, form, method);
|
||||||
// 添加header
|
// 添加header
|
||||||
addHeader(requestBuilder, header);
|
addHeader(requestBuilder, header);
|
||||||
|
|
||||||
@@ -153,21 +153,21 @@ public class HttpTool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Request.Builder buildRequestBuilder(String url, Map<String, String> form, String method) {
|
public static Request.Builder buildRequestBuilder(String url, Map<String, String> form, HTTPMethod method) {
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case "get":
|
case GET:
|
||||||
return new Request.Builder()
|
return new Request.Builder()
|
||||||
.url(buildHttpUrl(url, form))
|
.url(buildHttpUrl(url, form))
|
||||||
.get();
|
.get();
|
||||||
case "head":
|
case HEAD:
|
||||||
return new Request.Builder()
|
return new Request.Builder()
|
||||||
.url(buildHttpUrl(url, form))
|
.url(buildHttpUrl(url, form))
|
||||||
.head();
|
.head();
|
||||||
case "put":
|
case PUT:
|
||||||
return new Request.Builder()
|
return new Request.Builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.put(buildFormBody(form));
|
.put(buildFormBody(form));
|
||||||
case "delete":
|
case DELETE:
|
||||||
return new Request.Builder()
|
return new Request.Builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.delete(buildFormBody(form));
|
.delete(buildFormBody(form));
|
||||||
@@ -262,6 +262,9 @@ public class HttpTool {
|
|||||||
HEAD,
|
HEAD,
|
||||||
DELETE;
|
DELETE;
|
||||||
|
|
||||||
|
private HTTPMethod() {
|
||||||
|
}
|
||||||
|
|
||||||
public String value() {
|
public String value() {
|
||||||
return this.name();
|
return this.name();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user