Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
Z
zion
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
zhengfg
zion
Commits
830bc294
提交
830bc294
authored
12月 02, 2019
作者:
zgy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改bug
上级
43af036c
显示空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
132 行增加
和
111 行删除
+132
-111
pom.xml
pom.xml
+7
-0
FlutterWaveController.java
...yun/zion/chinafrica/controller/FlutterWaveController.java
+6
-1
ShopifyController.java
...diaoyun/zion/chinafrica/controller/ShopifyController.java
+4
-19
FlutterKey.java
...n/java/com/diaoyun/zion/chinafrica/entity/FlutterKey.java
+1
-1
ShopifyService.java
...a/com/diaoyun/zion/chinafrica/service/ShopifyService.java
+2
-2
ShopifyServiceImpl.java
...oyun/zion/chinafrica/service/impl/ShopifyServiceImpl.java
+5
-52
HttpClientUtil.java
...ain/java/com/diaoyun/zion/master/util/HttpClientUtil.java
+58
-23
application.yml
src/main/resources/application.yml
+8
-7
domain.properties
src/main/resources/properties/domain.properties
+1
-1
PayTest.java
src/test/java/com/diaoyun/zion/PayTest.java
+40
-5
没有找到文件。
pom.xml
浏览文件 @
830bc294
...
...
@@ -380,6 +380,13 @@
<systemPath>${project.basedir}/lib/Rave-1.0.1.jar
</systemPath>
</dependency>-->
<!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
<dependency>
<groupId>
com.squareup.okhttp3
</groupId>
<artifactId>
okhttp
</artifactId>
<version>
4.1.0
</version>
</dependency>
</dependencies>
<build>
...
...
src/main/java/com/diaoyun/zion/chinafrica/controller/FlutterWaveController.java
浏览文件 @
830bc294
...
...
@@ -58,9 +58,14 @@ public class FlutterWaveController {
return
flutterWaveService
.
refund
(
flutterWaveCard
);
}
/**
* 支付参数
*
* @param userId
* @return
*/
@GetMapping
(
"/queryParams"
)
public
Result
queryParams
(
@ApiParam
(
"用户ID"
)
@RequestParam
(
"userId"
)
String
userId
)
{
return
flutterWaveService
.
queryParams
(
userId
);
}
}
src/main/java/com/diaoyun/zion/chinafrica/controller/ShopifyController.java
浏览文件 @
830bc294
...
...
@@ -41,6 +41,7 @@ public class ShopifyController {
return
shopifyService
.
queryShopifyProducts
();
}
/**
* 查询分类商品
*
...
...
@@ -51,27 +52,11 @@ public class ShopifyController {
@ApiOperation
(
value
=
"查询分类商品"
)
@GetMapping
(
"/queryproductsbytype"
)
public
Result
queryProductsByType
(
@ApiParam
(
"商品分类"
)
@RequestParam
(
"product_type"
)
String
product_type
,
@ApiParam
(
"商品ID"
)
@RequestParam
(
value
=
"product_id"
,
required
=
false
)
String
product_id
,
@ApiParam
(
value
=
"页数 默认1"
)
@RequestParam
(
value
=
"pageNum"
,
defaultValue
=
"1"
)
Integer
pageNum
,
@ApiParam
(
value
=
"每页大小 默认10"
)
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"10"
)
Integer
pageSize
)
{
@ApiParam
(
"商品ID"
)
@RequestParam
(
value
=
"product_id"
,
required
=
false
)
String
product_id
)
{
return
shopifyService
.
queryProductsByType
(
product_type
,
product_id
,
pageNum
,
pageSize
);
return
shopifyService
.
queryProductsByType
(
product_type
,
product_id
);
}
// /**
// * 查询分类商品
// *
// * @param product_type 商品分类
// * @param product_id 商品ID
// * @return
// */
// @ApiOperation(value = "查询分类商品")
// @GetMapping("/queryproductsbytype")
// public Result queryProductsByType(@ApiParam("商品分类") @RequestParam("product_type") String product_type,
// @ApiParam("商品ID") @RequestParam(value = "product_id", required = false) String product_id
// ) {
//
// return shopifyService.queryProductsByType(product_type, product_id);
// }
/**
* 查看商品详情
...
...
src/main/java/com/diaoyun/zion/chinafrica/entity/FlutterKey.java
浏览文件 @
830bc294
...
...
@@ -5,7 +5,7 @@ import java.util.List;
/**
* @Auther: wudepeng
* @Date: 2019/11/28
* @Description:
ǰ֧
* @Description:
前端所需的支付数据
*/
public
class
FlutterKey
{
private
String
public_key
;
...
...
src/main/java/com/diaoyun/zion/chinafrica/service/ShopifyService.java
浏览文件 @
830bc294
...
...
@@ -13,8 +13,8 @@ import org.springframework.web.bind.annotation.RequestParam;
public
interface
ShopifyService
{
Result
queryShopifyProducts
();
Result
queryProductsByType
(
String
product_type
,
String
product_id
,
Integer
pageNum
,
Integer
pageSize
);
//Result queryProductsByType(String product_type, String product_id);
Result
queryProductsByType
(
String
product_type
,
String
product_id
);
Result
queryProductsDetails
(
String
product_id
);
Result
queryAllProducts
(
String
product_id
);
...
...
src/main/java/com/diaoyun/zion/chinafrica/service/impl/ShopifyServiceImpl.java
浏览文件 @
830bc294
...
...
@@ -73,6 +73,7 @@ public class ShopifyServiceImpl implements ShopifyService {
return
result
;
}
/**
* 查询分类商品
*
...
...
@@ -80,31 +81,15 @@ public class ShopifyServiceImpl implements ShopifyService {
* @return
*/
@Override
public
Result
queryProductsByType
(
String
product_type
,
String
product_id
,
Integer
pageNum
,
Integer
pageSize
)
{
public
Result
queryProductsByType
(
String
product_type
,
String
product_id
)
{
Result
result
=
new
Result
();
List
list
=
new
ArrayList
();
// Object typeProducts = redisCache.get(KeyConstant.SHOPIFY_TYPE_ITEMS + product_type + product_id + pageNum);
// if (typeProducts != null) {
// result.setData(typeProducts);
// return result;
// }
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"product_type"
,
product_type
);
//params.put("limit", "250");
params
.
put
(
"since_id"
,
product_id
);
params
.
put
(
"limit"
,
ShopifyConstant
.
SHOPIFY_PAGE_SIZE
);
try
{
String
data
=
HttpClientUtil
.
createConnection
(
ShopifyConstant
.
productTypeUrl
(),
params
,
"UTF-8"
);
JSONArray
products
=
JSONObject
.
fromObject
(
data
).
getJSONArray
(
"products"
);
System
.
out
.
println
(
products
.
size
());
for
(
int
i
=
0
;
i
<
products
.
size
();
i
++)
{
list
.
add
(
products
.
getJSONObject
(
i
));
}
Map
<
String
,
List
<
String
>>
listMap
=
new
HashMap
<>();
List
<
String
>
strings
=
ListUtil
.
pageBySubList
(
list
,
pageNum
,
pageSize
);
listMap
.
put
(
"products"
,
strings
);
System
.
out
.
println
(
"===>>>"
+
strings
.
size
());
result
.
setData
(
JSON
.
toJSON
(
listMap
));
//redisCache.set(KeyConstant.SHOPIFY_TYPE_ITEMS + product_type + product_id + pageNum, JSON.toJSON(listMap), 86400);
JSONObject
jsonObject
=
JSONObject
.
fromObject
(
data
);
result
.
setData
(
jsonObject
);
}
catch
(
IOException
e
)
{
result
.
setCode
(
ResultCodeEnum
.
QUERY_ERROR
.
getCode
()).
setMessage
(
e
.
getMessage
());
logger
.
error
(
e
.
getMessage
(),
e
);
...
...
@@ -113,38 +98,6 @@ public class ShopifyServiceImpl implements ShopifyService {
return
result
;
}
// /**
// * 查询分类商品
// *
// * @param product_type
// * @return
// */
// @Override
// public Result queryProductsByType(String product_type, String product_id) {
// Result result = new Result();
//// String typeProducts = (String) redisCache.get(KeyConstant.SHOPIFY_TYPE_ITEMS + product_type + product_id);
//// if (typeProducts != null) {
//// JSONObject object = JSONObject.fromObject(typeProducts);
//// result.setData(object);
//// return result;
//// }
// Map<String, Object> params = new HashMap<>();
// params.put("product_type", product_type);
// params.put("limit", ShopifyConstant.SHOPIFY_PAGE_SIZE);
// params.put("since_id", product_id);
// try {
// String data = HttpClientUtil.createConnection(ShopifyConstant.productTypeUrl(), params, "UTF-8");
// JSONObject jsonObject = JSONObject.fromObject(data);
// result.setData(jsonObject);
// redisCache.set(KeyConstant.SHOPIFY_TYPE_ITEMS + product_type + product_id, data, 86400);
// } catch (IOException e) {
// result.setCode(ResultCodeEnum.QUERY_ERROR.getCode()).setMessage(e.getMessage());
// logger.error(e.getMessage(), e);
// return result;
// }
// return result;
// }
/**
* 查看商品详情
*
...
...
src/main/java/com/diaoyun/zion/master/util/HttpClientUtil.java
浏览文件 @
830bc294
...
...
@@ -20,7 +20,9 @@ import org.apache.http.message.BasicNameValuePair;
import
org.apache.http.util.EntityUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.net.*
;
...
...
@@ -34,6 +36,7 @@ public class HttpClientUtil {
/**
* 获取url链接中的content 内容
*
* @param sourceUrl 目标url
* @param sourceType
* @return
...
...
@@ -41,19 +44,19 @@ public class HttpClientUtil {
* @throws IOException
*/
public
static
String
getContentByUrl
(
String
sourceUrl
,
String
sourceType
)
throws
URISyntaxException
,
IOException
{
sourceUrl
=
urlEncode
(
sourceUrl
,
Consts
.
UTF_8
.
name
());
sourceUrl
=
urlEncode
(
sourceUrl
,
Consts
.
UTF_8
.
name
());
URL
url
=
new
URL
(
sourceUrl
);
//构建URI
URI
uri
=
new
URI
(
url
.
getProtocol
(),
url
.
getHost
(),
url
.
getPath
(),
url
.
getQuery
(),
null
);
URI
uri
=
new
URI
(
url
.
getProtocol
(),
url
.
getHost
(),
url
.
getPath
(),
url
.
getQuery
(),
null
);
//创建一个HttpContext对象,用来保存Cookie
//HttpClientContext httpClientContext = HttpClientContext.create();
//构造自定义的HttpClient对象
CloseableHttpClient
httpClient
;
if
(
PlatformEnum
.
TB
.
getValue
().
equals
(
sourceType
))
{
if
(
PlatformEnum
.
TB
.
getValue
().
equals
(
sourceType
))
{
httpClient
=
createBrowserClient
();
}
else
if
(
PlatformEnum
.
TM
.
getValue
().
equals
(
sourceType
))
{
}
else
if
(
PlatformEnum
.
TM
.
getValue
().
equals
(
sourceType
))
{
//天猫用手机端访问拿的数据 香港服务器不可行
httpClient
=
createIphoneClient
();
httpClient
=
createIphoneClient
();
//httpClient= createBrowserClient();
}
else
{
httpClient
=
createBrowserClient
();
...
...
@@ -65,7 +68,7 @@ public class HttpClientUtil {
//执行请求,传入HttpContext,将会得到请求结果的信息
//httpClient.execute(httpUriRequest,httpClientContext)
HttpResponse
httpResponse
=
httpClient
.
execute
(
httpUriRequest
);
HttpResponse
httpResponse
=
httpClient
.
execute
(
httpUriRequest
);
//拿到返回的HttpResponse的"实体"
HttpEntity
result
=
httpResponse
.
getEntity
();
//System.getProperties().list(System.out);//输出当前环境属性 55555555
...
...
@@ -76,9 +79,9 @@ public class HttpClientUtil {
result = new DeflateDecompressingEntity(result);
}
}*/
String
defaultCharset
=
Consts
.
UTF_8
.
name
();
if
(
PlatformEnum
.
TM
.
getValue
().
equals
(
sourceType
))
{
defaultCharset
=
Consts
.
UTF_8
.
name
();
String
defaultCharset
=
Consts
.
UTF_8
.
name
();
if
(
PlatformEnum
.
TM
.
getValue
().
equals
(
sourceType
))
{
defaultCharset
=
Consts
.
UTF_8
.
name
();
}
String
content
=
EntityUtils
.
toString
(
result
,
defaultCharset
);
//logger.info(content);
...
...
@@ -89,13 +92,14 @@ public class HttpClientUtil {
/**
* 获取url链接中的content 网页内容
*
* @param url 目标url
* @return
* @throws URISyntaxException
* @throws IOException
*/
public
static
String
getContentByUrl
(
String
url
,
BasicHeader
basicHeader
)
throws
URISyntaxException
,
IOException
{
URI
sibUri
=
new
URIBuilder
(
url
).
build
();
URI
sibUri
=
new
URIBuilder
(
url
).
build
();
//构造请求对象
HttpUriRequest
sibUriRequest
=
RequestBuilder
.
get
().
setUri
(
sibUri
).
build
();
//构造自定义的HttpClient对象
...
...
@@ -103,7 +107,7 @@ public class HttpClientUtil {
//创建一个HttpContext对象,用来保存Cookie
//HttpClientContext sibClientContext = HttpClientContext.create();
//执行请求,传入HttpContext,将会得到请求结果的信息
HttpResponse
sibResponse
=
sibClient
.
execute
(
sibUriRequest
);
HttpResponse
sibResponse
=
sibClient
.
execute
(
sibUriRequest
);
//拿到返回的HttpResponse的"实体"
HttpEntity
sibResult
=
sibResponse
.
getEntity
();
String
sibContent
=
EntityUtils
.
toString
(
sibResult
);
...
...
@@ -115,6 +119,7 @@ public class HttpClientUtil {
/**
* 创建带浏览器头部的连接
*
* @return
*/
public
static
CloseableHttpClient
createBrowserClient
()
{
...
...
@@ -134,6 +139,7 @@ public class HttpClientUtil {
/**
* 创建带浏览器头部的连接
*
* @return
*/
public
static
CloseableHttpClient
createBrowserClient
(
BasicHeader
basicHeader
)
{
...
...
@@ -154,6 +160,7 @@ public class HttpClientUtil {
/**
* 创建带苹果手机头部的连接
*
* @return
*/
public
static
CloseableHttpClient
createIphoneClient
()
{
...
...
@@ -172,19 +179,20 @@ public class HttpClientUtil {
/**
* 发送请求
*
* @param url
* @param paramMap
* @param charset
* @return
*/
public
static
String
createConnection
(
String
url
,
Map
<
String
,
Object
>
paramMap
,
String
charset
)
throws
IOException
{
public
static
String
createConnection
(
String
url
,
Map
<
String
,
Object
>
paramMap
,
String
charset
)
throws
IOException
{
List
<
NameValuePair
>
formparams
=
setHttpParams
(
paramMap
);
String
param
=
URLEncodedUtils
.
format
(
formparams
,
charset
);
// 构建一个GET请求
HttpGet
httpGet
=
new
HttpGet
();
httpGet
.
setURI
(
URI
.
create
(
url
+
"?"
+
param
));
CloseableHttpClient
httpClient
=
createBrowserClient
();
HttpResponse
sibResponse
=
httpClient
.
execute
(
httpGet
);
CloseableHttpClient
httpClient
=
createBrowserClient
();
HttpResponse
sibResponse
=
httpClient
.
execute
(
httpGet
);
// 拿到返回的HttpResponse的"实体"
HttpEntity
sibResult
=
sibResponse
.
getEntity
();
return
EntityUtils
.
toString
(
sibResult
);
...
...
@@ -192,6 +200,7 @@ public class HttpClientUtil {
/**
* 设置 Http 参数
*
* @param paramsMap
* @return
*/
...
...
@@ -207,30 +216,32 @@ public class HttpClientUtil {
/**
* 获取连接中的参数
*
* @param targetUrl
* @return
*/
public
static
Map
<
String
,
String
>
getParamMap
(
String
targetUrl
)
throws
URISyntaxException
,
MalformedURLException
{
URL
url
=
new
URL
(
targetUrl
);
//构建URI
URI
uri
=
new
URI
(
url
.
getProtocol
(),
url
.
getHost
(),
url
.
getPath
(),
url
.
getQuery
(),
null
);
URI
uri
=
new
URI
(
url
.
getProtocol
(),
url
.
getHost
(),
url
.
getPath
(),
url
.
getQuery
(),
null
);
List
<
NameValuePair
>
params
=
URLEncodedUtils
.
parse
(
uri
,
String
.
valueOf
(
Charset
.
forName
(
Consts
.
UTF_8
.
name
())));
Map
<
String
,
String
>
paramMap
=
new
HashMap
<>();
Map
<
String
,
String
>
paramMap
=
new
HashMap
<>();
for
(
NameValuePair
param
:
params
)
{
paramMap
.
put
(
param
.
getName
(),
param
.
getValue
());
paramMap
.
put
(
param
.
getName
(),
param
.
getValue
());
}
return
paramMap
;
}
/**
* 发送带body参数的post请求
*
* @param url
* @param paramMap
* @return
* @throws URISyntaxException
* @throws IOException
*/
public
static
String
sendPostWithBodyParameter
(
String
url
,
Map
<
String
,
Object
>
paramMap
)
throws
IOException
{
public
static
String
sendPostWithBodyParameter
(
String
url
,
Map
<
String
,
Object
>
paramMap
)
throws
IOException
{
//构建一个Post请求
HttpPost
httpPost
=
new
HttpPost
();
httpPost
.
setURI
(
URI
.
create
(
url
));
...
...
@@ -241,7 +252,7 @@ public class HttpClientUtil {
//构造自定义的HttpClient对象
CloseableHttpClient
sibClient
=
HttpClients
.
custom
().
build
();
//执行请求,传入HttpContext,将会得到请求结果的信息
HttpResponse
sibResponse
=
sibClient
.
execute
(
httpPost
);
HttpResponse
sibResponse
=
sibClient
.
execute
(
httpPost
);
//拿到返回的HttpResponse的"实体"
HttpEntity
sibResult
=
sibResponse
.
getEntity
();
String
sibContent
=
EntityUtils
.
toString
(
sibResult
);
...
...
@@ -253,17 +264,18 @@ public class HttpClientUtil {
/**
* 对链接进行url编码
*
* @param url
* @param chartSet
* @return
*/
public
static
String
urlEncode
(
String
url
,
String
chartSet
)
{
public
static
String
urlEncode
(
String
url
,
String
chartSet
)
{
try
{
//双字节,包括中文和中文符号[^\x00-\xff] 中文[\u4e00-\u9fa5]
Matcher
matcher
=
Pattern
.
compile
(
"[^\\x00-\\xff]"
).
matcher
(
url
);
while
(
matcher
.
find
())
{
String
tmp
=
matcher
.
group
();
url
=
url
.
replaceAll
(
tmp
,
java
.
net
.
URLEncoder
.
encode
(
tmp
,
chartSet
));
String
tmp
=
matcher
.
group
();
url
=
url
.
replaceAll
(
tmp
,
java
.
net
.
URLEncoder
.
encode
(
tmp
,
chartSet
));
}
}
catch
(
UnsupportedEncodingException
e
)
{
logger
.
error
(
"双字节编码异常:"
,
e
);
...
...
@@ -271,4 +283,27 @@ public class HttpClientUtil {
return
url
;
}
/**
* 发送请求
*
* @param url
* @param paramMap
* @param charset
* @return
*/
public
static
String
getConnection
(
String
url
,
Map
<
String
,
Object
>
paramMap
,
String
charset
)
throws
IOException
{
List
<
NameValuePair
>
formparams
=
setHttpParams
(
paramMap
);
String
param
=
URLEncodedUtils
.
format
(
formparams
,
charset
);
// 构建一个GET请求
HttpGet
httpGet
=
new
HttpGet
();
httpGet
.
setURI
(
URI
.
create
(
url
+
"?"
+
param
));
CloseableHttpClient
httpClient
=
createBrowserClient
();
HttpResponse
sibResponse
=
httpClient
.
execute
(
httpGet
);
// 拿到返回的HttpResponse的"实体"
HttpEntity
sibResult
=
sibResponse
.
getEntity
();
Header
header
=
sibResult
.
getContentEncoding
();
return
EntityUtils
.
toString
(
sibResult
)
+
"#"
+
header
;
}
}
src/main/resources/application.yml
浏览文件 @
830bc294
...
...
@@ -20,6 +20,7 @@ spring:
redis
:
#Redis数据库分片索引(默认为0)
database
:
0
# host: 192.168.1.211
host
:
127.0.0.1
port
:
6379
password
:
...
...
@@ -37,13 +38,13 @@ spring:
mysql
:
type
:
com.alibaba.druid.pool.DruidDataSource
driver-class-name
:
com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://localhost:3306/chinafrica?useUnicode=true&characterEncoding=UTF-8&rewriteBatchedStatements=true&autoReconnect=true&failOverReadOnly=false&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
# username: root
# password: root
# 测试环境
# 测试环境
url
:
jdbc:mysql://47.106.242.175:3306/chinafrica?useUnicode=true&characterEncoding=UTF-8&rewriteBatchedStatements=true&autoReconnect=true&failOverReadOnly=false&zeroDateTimeBehavior=convertToNull&useSSL=false
username
:
root
password
:
diaoyun666
# url: jdbc:mysql://159.138.48.71:3306/chinafrica?useUnicode=true&characterEncoding=UTF-8&rewriteBatchedStatements=true&autoReconnect=true&failOverReadOnly=false&zeroDateTimeBehavior=convertToNull&useSSL=false
# username: root
# password: Diaoyunnuli.8
# 连接池配置
initial-size
:
5
...
...
src/main/resources/properties/domain.properties
浏览文件 @
830bc294
...
...
@@ -20,7 +20,7 @@ email.subject=Verification Code from Afrishop
###################################\u90AE\u7BB1 END###############################################
################redis\u6709\u6548\u65F6\u95F4###################
#\u767B\u5F55token second \u9ED8\u8BA430\u5206 \u4E00\u4E2A\u661F\u671F 604800
redis.token.expiredTime
=
6048
0000
redis.token.expiredTime
=
777600
0000
#\u8BA2\u5355 30\u5206 second
redis.order.expiredTime
=
1800
################\u817E\u8BAF\u7FFB\u8BD1\u914D\u7F6E###################
...
...
src/test/java/com/diaoyun/zion/PayTest.java
浏览文件 @
830bc294
...
...
@@ -10,13 +10,24 @@ import com.diaoyun.zion.master.util.HttpClientUtil;
import
com.diaoyun.zion.master.util.ListUtil
;
import
com.github.pagehelper.PageInfo
;
import
com.google.gson.JsonArray
;
import
com.mashape.unirest.http.Headers
;
import
com.mashape.unirest.http.HttpResponse
;
import
com.mashape.unirest.http.Unirest
;
import
com.mashape.unirest.http.exceptions.UnirestException
;
import
io.swagger.models.auth.In
;
import
net.sf.json.JSONArray
;
import
net.sf.json.JSONObject
;
import
okhttp3.OkHttpClient
;
import
okhttp3.Request
;
import
okhttp3.Response
;
import
okhttp3.ResponseBody
;
import
org.apache.http.Consts
;
import
org.apache.http.HttpRequest
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
springfox.documentation.spring.web.json.Json
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.net.MalformedURLException
;
...
...
@@ -59,13 +70,13 @@ public class PayTest {
Result
result
=
new
Result
();
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"product_type"
,
"Christmas"
);
params
.
put
(
"limit"
,
"1"
);
params
.
put
(
"limit"
,
"1"
);
//params.put("since_id", "4248995594337");
List
list
=
new
ArrayList
<>();
String
data
=
HttpClientUtil
.
createConnection
(
ShopifyConstant
.
productTypeUrl
(),
params
,
"UTF-8"
);
JSONArray
products
=
JSONObject
.
fromObject
(
data
).
getJSONArray
(
"products"
);
for
(
int
i
=
0
;
i
<
products
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
products
.
size
();
i
++)
{
Products
product
=
JSON
.
parseObject
(
data
,
Products
.
class
);
System
.
out
.
println
(
products
);
}
...
...
@@ -81,7 +92,6 @@ public class PayTest {
}
public
static
List
<
String
>
pageBySubList
(
List
list
,
int
pagesize
,
int
currentPage
)
{
int
totalcount
=
list
.
size
();
int
pagecount
=
0
;
...
...
@@ -106,8 +116,8 @@ public class PayTest {
@Test
public
void
url
()
throws
MalformedURLException
,
URISyntaxException
,
UnsupportedEncodingException
{
String
url
=
"http://www.oschina.net/search?scope=bbs&q=C%E8%AF%AD%E8%A8%80"
;
String
targetUrl
=
URLDecoder
.
decode
(
url
,
"utf-8"
);
String
url
=
"http://www.oschina.net/search?scope=bbs&q=C%E8%AF%AD%E8%A8%80"
;
String
targetUrl
=
URLDecoder
.
decode
(
url
,
"utf-8"
);
Map
<
String
,
String
>
paramMap
=
HttpClientUtil
.
getParamMap
(
targetUrl
);
System
.
out
.
println
(
paramMap
);
String
q
=
URLDecoder
.
decode
(
paramMap
.
get
(
"q"
),
"utf-8"
);
...
...
@@ -115,4 +125,29 @@ public class PayTest {
}
@Test
public
void
testHeaders
()
throws
UnirestException
{
// String url = "https://7f0e048ac4016b9357bb1eb2217e4201:1c97a1222c5b40e0597c816c6dfecac0@mollykitty.myshopify.com/admin/api/2019-10/products.json";
// Map<String, Object> map = new HashMap<>();
// map.put("product_type", "Men");
// map.put("limit", "10");
// String data = HttpClientUtil.getConnection(url, map,"utf-8");
// System.out.println(data);
HttpResponse
<
String
>
response
=
Unirest
.
get
(
"https://7f0e048ac4016b9357bb1eb2217e4201:1c97a1222c5b40e0597c816c6dfecac0@mollykitty.myshopify.com/admin/api/2019-10/products.json?limit=10&page_info=eyJwcm9kdWN0X3R5cGUiOiJNZW4iLCJsYXN0X2lkIjo0Mjg2ODYxMTgxMDI1LCJsYXN0X3ZhbHVlIjoiQmxhY2sgc25lYWtlcnMiLCJkaXJlY3Rpb24iOiJuZXh0In0"
)
.
headers
(
new
HashMap
<>())
.
asString
();
System
.
out
.
println
(
response
.
getBody
());
System
.
out
.
println
(
"========================"
);
List
<
String
>
link
=
response
.
getHeaders
().
get
(
"Link"
);
String
str
=
link
.
get
(
0
);
String
[]
split
=
str
.
split
(
","
);
String
s
=
split
[
0
];
System
.
out
.
println
(
s
.
substring
(
s
.
lastIndexOf
(
"page_info="
),
s
.
lastIndexOf
(
">;"
)));
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论