Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
A
Afrishop refactored project
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Whispa
Afrishop refactored project
Commits
e00c1ddd
提交
e00c1ddd
authored
12月 29, 2020
作者:
吴德鹏
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
paypal token
上级
43c33a49
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
75 行增加
和
73 行删除
+75
-73
PaypalContoller.java
.../com/example/afrishop_v3/controllers/PaypalContoller.java
+2
-13
AfrishopV3ApplicationTests.java
...a/com/example/afrishop_v3/AfrishopV3ApplicationTests.java
+73
-60
没有找到文件。
src/main/java/com/example/afrishop_v3/controllers/PaypalContoller.java
浏览文件 @
e00c1ddd
...
...
@@ -172,19 +172,8 @@ public class PaypalContoller extends Controller {
public
APIContext
getToken
()
throws
IOException
{
//获取paypal的最新token
Optional
<
Token
>
tokenOptional
=
tokenRepository
.
findFirstToken
();
Optional
<
String
>
token
=
Optional
.
empty
();
//第一次执行时,token表都为空
if
(
tokenOptional
.
isPresent
())
{
token
=
Optional
.
ofNullable
(
tokenOptional
.
get
().
getToken
());
}
if
(!
token
.
isPresent
())
{
String
oldToken
=
oldApiContext
.
getAccessToken
();
String
token1
=
PayPalUtil
.
getToken
(
oldToken
,
mode
);
token
=
Optional
.
ofNullable
(
token1
);
}
APIContext
apiContext
=
new
APIContext
(
token
.
get
());
String
token
=
PayPalUtil
.
getToken
(
tokenOptional
.
get
().
getToken
(),
mode
);
APIContext
apiContext
=
new
APIContext
(
token
);
Map
<
String
,
String
>
sdkConfig
=
new
HashMap
<>();
sdkConfig
.
put
(
"mode"
,
mode
);
apiContext
.
setConfigurationMap
(
sdkConfig
);
...
...
src/test/java/com/example/afrishop_v3/AfrishopV3ApplicationTests.java
浏览文件 @
e00c1ddd
//package com.example.afrishop_v3;
//
//import com.example.afrishop_v3.models.JsonTag;
//import com.example.afrishop_v3.models.TbCfOrder;
//import com.example.afrishop_v3.repository.TbCfOrderRepository;
//import com.google.gson.JsonObject;
//import net.sf.json.JSONObject;
//import org.junit.jupiter.api.Test;
//import org.junit.runner.Result;
//import org.junit.runner.RunWith;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.test.context.SpringBootTest;
//import org.springframework.http.ResponseEntity;
//import org.springframework.test.context.junit4.SpringRunner;
//import org.springframework.web.client.RestTemplate;
//
//import java.text.SimpleDateFormat;
//import java.time.LocalDateTime;
//import java.util.Date;
//import java.util.HashMap;
//import java.util.Map;
//import java.util.Optional;
//
//@RunWith(SpringRunner.class)
//@SpringBootTest
//public class AfrishopV3ApplicationTests {
//
// RestTemplate restTemplate = new RestTemplate();
//
// @Test
// void contextLoads() {
// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
// String now = format.format(new Date());
// System.out.println(now);
// }
//
// private String url = "http://localhost:8099/afrishop/discover/bonus/saveNetworkMarketing";
// @Autowired
// private TbCfOrderRepository orderRepository;
//
//// post35789572fbf643cdab55901d1dc511a6
//// userInfo00297bf300ed45e092a5182dececad21
//// productSharervv32GmG4q
//// amount0.9
//// orderId008272b1fb994aef9b199449f46d5aa5
//
// @Test
// public void test1() {
//
// Optional<TbCfOrder> byId = orderRepository.findById("12a9d7d1042348278c97980a00fc67c4");
// JSONObject json=new JSONObject();
// json.put("userInfo", "32dcda5a709c4265a6f01686ae9b1c1c");
// json.put("amount", byId.get().getItemsPrice());
// json.put("orderId","12a9d7d1042348278c97980a00fc67c4");
// System.out.println(json);
// ResponseEntity<Result> resultResponseEntity = restTemplate.postForEntity(url, json, Result.class);
// System.err.println(resultResponseEntity);
// }
//
//}
package
com
.
example
.
afrishop_v3
;
import
com.example.afrishop_v3.models.JsonTag
;
import
com.example.afrishop_v3.models.TbCfOrder
;
import
com.example.afrishop_v3.models.Token
;
import
com.example.afrishop_v3.repository.TbCfOrderRepository
;
import
com.example.afrishop_v3.repository.TokenRepository
;
import
com.google.gson.JsonObject
;
import
net.sf.json.JSONObject
;
import
org.junit.jupiter.api.Test
;
import
org.junit.runner.Result
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.web.client.RestTemplate
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDateTime
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Optional
;
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
public
class
AfrishopV3ApplicationTests
{
RestTemplate
restTemplate
=
new
RestTemplate
();
@Test
void
contextLoads
()
{
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd hh:mm:ss"
);
String
now
=
format
.
format
(
new
Date
());
System
.
out
.
println
(
now
);
}
private
String
url
=
"http://localhost:8099/afrishop/discover/bonus/saveNetworkMarketing"
;
@Autowired
private
TbCfOrderRepository
orderRepository
;
// post35789572fbf643cdab55901d1dc511a6
// userInfo00297bf300ed45e092a5182dececad21
// productSharervv32GmG4q
// amount0.9
// orderId008272b1fb994aef9b199449f46d5aa5
@Test
public
void
test1
()
{
Optional
<
TbCfOrder
>
byId
=
orderRepository
.
findById
(
"12a9d7d1042348278c97980a00fc67c4"
);
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"userInfo"
,
"32dcda5a709c4265a6f01686ae9b1c1c"
);
json
.
put
(
"amount"
,
byId
.
get
().
getItemsPrice
());
json
.
put
(
"orderId"
,
"12a9d7d1042348278c97980a00fc67c4"
);
System
.
out
.
println
(
json
);
ResponseEntity
<
Result
>
resultResponseEntity
=
restTemplate
.
postForEntity
(
url
,
json
,
Result
.
class
);
System
.
err
.
println
(
resultResponseEntity
);
}
@Autowired
private
TokenRepository
tokenRepository
;
@Test
public
void
test2
(){
Optional
<
Token
>
firstToken
=
tokenRepository
.
findFirstToken
();
if
(
firstToken
.
isPresent
()){
System
.
out
.
println
(
firstToken
.
get
().
getToken
());
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论