Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
Z
zion
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
zhengfg
zion
Commits
84d9d245
提交
84d9d245
authored
11月 16, 2019
作者:
zgy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
完成shopify商品详情
上级
ace7a897
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
62 行增加
和
9 行删除
+62
-9
ShopifyController.java
...diaoyun/zion/chinafrica/controller/ShopifyController.java
+14
-2
ShopifyService.java
...a/com/diaoyun/zion/chinafrica/service/ShopifyService.java
+3
-0
ShopifyServiceImpl.java
...oyun/zion/chinafrica/service/impl/ShopifyServiceImpl.java
+23
-0
PayTest.java
src/test/java/com/diaoyun/zion/PayTest.java
+22
-7
没有找到文件。
src/main/java/com/diaoyun/zion/chinafrica/controller/ShopifyController.java
浏览文件 @
84d9d245
...
...
@@ -2,7 +2,6 @@ package com.diaoyun.zion.chinafrica.controller;
import
com.diaoyun.zion.chinafrica.service.ShopifyService
;
import
com.diaoyun.zion.master.base.Result
;
import
com.diaoyun.zion.master.config.DomainProperties
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
...
...
@@ -43,9 +42,22 @@ public class ShopifyController {
@ApiOperation
(
value
=
"查询分类商品"
)
@GetMapping
(
"/queryproductsbytype"
)
public
Result
queryProductsByType
(
@ApiParam
(
"商品分类"
)
@RequestParam
(
"product_type"
)
String
product_type
,
@ApiParam
(
"商品
分类
"
)
@RequestParam
(
value
=
"product_id"
,
required
=
false
)
String
product_id
)
{
@ApiParam
(
"商品
ID
"
)
@RequestParam
(
value
=
"product_id"
,
required
=
false
)
String
product_id
)
{
return
shopifyService
.
queryProductsByType
(
product_type
,
product_id
);
}
/**
* 查看商品详情
*
* @param product_id
* @return
*/
@ApiOperation
(
value
=
"查看商品详情"
)
@GetMapping
(
"/queryproductdetails"
)
public
Result
queryProductsDetails
(
@ApiParam
(
"商品ID"
)
@RequestParam
(
"product_id"
)
String
product_id
)
{
return
shopifyService
.
queryProductsDetails
(
product_id
);
}
}
src/main/java/com/diaoyun/zion/chinafrica/service/ShopifyService.java
浏览文件 @
84d9d245
package
com
.
diaoyun
.
zion
.
chinafrica
.
service
;
import
com.diaoyun.zion.master.base.Result
;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestParam
;
/**
* @Auther: wudepeng
...
...
@@ -11,4 +13,5 @@ import org.springframework.web.bind.annotation.PathVariable;
public
interface
ShopifyService
{
public
Result
queryShopifyProducts
();
public
Result
queryProductsByType
(
String
product_type
,
String
product_id
);
Result
queryProductsDetails
(
String
product_id
);
}
src/main/java/com/diaoyun/zion/chinafrica/service/impl/ShopifyServiceImpl.java
浏览文件 @
84d9d245
...
...
@@ -87,6 +87,29 @@ public class ShopifyServiceImpl implements ShopifyService {
return
result
;
}
/**
* 查看商品详情
* @param product_id
* @return
*/
@Override
public
Result
queryProductsDetails
(
String
product_id
)
{
Result
result
=
new
Result
();
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"ids"
,
product_id
);
try
{
String
data
=
HttpClientUtil
.
createConnection
(
ShopifyConstant
.
productTypeUrl
(),
params
,
"UTF-8"
);
JSONObject
jsonObject
=
JSONObject
.
fromObject
(
data
);
System
.
out
.
println
(
jsonObject
);
result
.
setData
(
jsonObject
);
}
catch
(
IOException
e
)
{
result
.
setCode
(
ResultCodeEnum
.
QUERY_ERROR
.
getCode
()).
setMessage
(
e
.
getMessage
());
logger
.
error
(
e
.
getMessage
(),
e
);
return
result
;
}
return
result
;
}
/**
* 查询所有商品分类
*
...
...
src/test/java/com/diaoyun/zion/PayTest.java
浏览文件 @
84d9d245
...
...
@@ -48,19 +48,34 @@ public class PayTest {
Result
result
=
new
Result
();
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"product_type"
,
"Face"
);
List
list
=
new
ArrayList
<>();
try
{
String
data
=
HttpClientUtil
.
createConnection
(
ShopifyConstant
.
productTypeUrl
(),
params
,
"UTF-8"
);
System
.
out
.
println
(
"===========>>>>>>>>>"
+
data
);
System
.
out
.
println
(
data
);
JSONArray
products
=
JSONObject
.
fromObject
(
data
).
getJSONArray
(
"products"
);
for
(
int
i
=
0
;
i
<
products
.
size
();
i
++)
{
JSONObject
object
=
products
.
getJSONObject
(
i
);
list
.
add
(
object
);
JSONObject
jsonObject
=
products
.
getJSONObject
(
i
);
JSONArray
images
=
jsonObject
.
getJSONArray
(
"images"
);
for
(
int
j
=
0
;
j
<
images
.
size
();
j
++)
{
JSONObject
object
=
images
.
getJSONObject
(
j
);
System
.
out
.
println
(
object
.
getString
(
"id"
));
}
// String string = jsonObject.getJSONObject("image").getString("product_id");
// System.out.println(string);
// System.err.println(jsonObject);
// System.out.println(jsonObject.getString("id"));
// System.out.println(jsonObject.getString("title"));
// System.out.println(jsonObject.getString("product_type"));
// System.out.println(jsonObject.getJSONArray("variants"));
// JSONArray variants = jsonObject.getJSONArray("variants");
// for (int j=0;j<variants.size();j++){
// JSONObject object = variants.getJSONObject(j);
// String price = object.getString("price");
// System.out.println("price"+price);
// }
}
// System.out.println(list.size());
System
.
err
.
println
(
products
.
get
(
1
));
JSONArray
jsonArray
=
JSONArray
.
fromObject
(
list
);
}
catch
(
IOException
e
)
{
result
.
setCode
(
ResultCodeEnum
.
QUERY_ERROR
.
getCode
()).
setMessage
(
e
.
getMessage
());
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论