mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 12:56:28 +08:00
5.0
This commit is contained in:
@@ -7,5 +7,6 @@ import lombok.Data;
|
||||
*/
|
||||
@Data
|
||||
public class DemoFileUploadModel {
|
||||
private String remark;
|
||||
private String storyName;
|
||||
private String addTime;
|
||||
}
|
||||
|
@@ -1,13 +1,13 @@
|
||||
package com.gitee.sop.sdk.request;
|
||||
|
||||
import com.gitee.sop.sdk.response.DemoFileUploadResponse;
|
||||
import com.gitee.sop.sdk.response.GetStoryResponse;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
public class DemoFileUploadRequest extends BaseRequest<DemoFileUploadResponse> {
|
||||
public class DemoFileUploadRequest extends BaseRequest<GetStoryResponse> {
|
||||
@Override
|
||||
protected String method() {
|
||||
return "file.upload";
|
||||
return "story.upload.more";
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,23 @@
|
||||
package com.gitee.sop.sdk.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* pay.trade.wap.pay(手机网站支付接口)
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class PayTradeWapPayModel {
|
||||
|
||||
private String outTradeNo;
|
||||
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
private String subject;
|
||||
|
||||
private String productCode;
|
||||
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
package com.gitee.sop.sdk.request;
|
||||
|
||||
import com.gitee.sop.sdk.response.PayTradeWapPayResponse;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* pay.trade.wap.pay(手机网站支付接口)
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class PayTradeWapPayRequest extends BaseRequest<PayTradeWapPayResponse> {
|
||||
|
||||
private String outTradeNo;
|
||||
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
private String subject;
|
||||
|
||||
private String productCode;
|
||||
|
||||
@Override
|
||||
protected String method() {
|
||||
return "pay.trade.wap.pay";
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package com.gitee.sop.sdk.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class PayTradeWapPayResponse {
|
||||
|
||||
private String pageRedirectionData;
|
||||
|
||||
}
|
@@ -8,14 +8,21 @@ import com.gitee.sop.sdk.model.DemoFileUploadModel;
|
||||
import com.gitee.sop.sdk.model.GetStoryModel;
|
||||
import com.gitee.sop.sdk.request.DemoFileUploadRequest;
|
||||
import com.gitee.sop.sdk.request.GetStoryRequest;
|
||||
import com.gitee.sop.sdk.request.PayTradeWapPayModel;
|
||||
import com.gitee.sop.sdk.request.PayTradeWapPayRequest;
|
||||
import com.gitee.sop.sdk.response.DemoFileUploadResponse;
|
||||
import com.gitee.sop.sdk.response.GetStoryResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.gitee.sop.sdk.response.PayTradeWapPayResponse;
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class SdkTest extends TestCase {
|
||||
String url = "http://localhost:8081/api";
|
||||
@@ -33,6 +40,25 @@ public class SdkTest extends TestCase {
|
||||
// 声明一个就行
|
||||
OpenClient client = new OpenClient(url, appId, privateKeyIsv, publicKeyPlatform);
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
PayTradeWapPayRequest request = new PayTradeWapPayRequest();
|
||||
PayTradeWapPayModel model = new PayTradeWapPayModel();
|
||||
model.setOutTradeNo("70501111111S001111119");
|
||||
model.setTotalAmount(new BigDecimal("1000"));
|
||||
model.setSubject("衣服");
|
||||
model.setProductCode("QUICK_WAP_WAY");
|
||||
request.setBizModel(model);
|
||||
|
||||
Result<PayTradeWapPayResponse> result = client.execute(request);
|
||||
if (result.isSuccess()) {
|
||||
PayTradeWapPayResponse response = result.getData();
|
||||
System.out.println(response);
|
||||
} else {
|
||||
System.out.println(result);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGet() {
|
||||
// 创建请求对象
|
||||
@@ -62,23 +88,22 @@ public class SdkTest extends TestCase {
|
||||
DemoFileUploadRequest request = new DemoFileUploadRequest();
|
||||
|
||||
DemoFileUploadModel model = new DemoFileUploadModel();
|
||||
model.setRemark("上传文件参数");
|
||||
model.setStoryName("上传文件参数");
|
||||
model.setAddTime( new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
||||
request.setBizModel(model);
|
||||
|
||||
String root = System.getProperty("user.dir");
|
||||
System.out.println(root);
|
||||
// 这里演示将resources下的两个文件上传到服务器
|
||||
request.addFile(new UploadFile("file1", new File(root + "/src/main/resources/file1.txt")));
|
||||
request.addFile(new UploadFile("file2", new File(root + "/src/main/resources/file2.txt")));
|
||||
request.addFile(new UploadFile("idCardFront", new File(root + "/src/main/resources/file1.txt")));
|
||||
request.addFile(new UploadFile("idCardBack", new File(root + "/src/main/resources/file2.txt")));
|
||||
|
||||
Result<DemoFileUploadResponse> result = client.execute(request);
|
||||
Result<GetStoryResponse> result = client.execute(request);
|
||||
|
||||
System.out.println("--------------------");
|
||||
if (result.isSuccess()) {
|
||||
DemoFileUploadResponse response = result.getData();
|
||||
List<DemoFileUploadResponse.FileMeta> responseFiles = response.getFiles();
|
||||
System.out.println("您上传的文件信息:");
|
||||
responseFiles.forEach(System.out::println);
|
||||
GetStoryResponse response = result.getData();
|
||||
System.out.println("您上传的文件信息:" + response);
|
||||
} else {
|
||||
System.out.println(JSON.toJSONString(result));
|
||||
}
|
||||
|
Reference in New Issue
Block a user