Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
C
chinafrica
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
zhengfg
chinafrica
Commits
676c7994
提交
676c7994
authored
3月 19, 2020
作者:
梁业锦
💬
提交者:
何春颖
3月 19, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
- 方法改为返回集合
上级
8378c7f1
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
105 行增加
和
84 行删除
+105
-84
ShopifyController.java
...n/java/com/platform/controller/api/ShopifyController.java
+4
-4
TbCategoryTemplateDao.java
...src/main/java/com/platform/dao/TbCategoryTemplateDao.java
+3
-1
TbCfDescripitonDao.java
...in/src/main/java/com/platform/dao/TbCfDescripitonDao.java
+1
-1
TbCfGoodstwotypeDao.java
...n/src/main/java/com/platform/dao/TbCfGoodstwotypeDao.java
+1
-1
TbCfGoodstypeDao.java
...dmin/src/main/java/com/platform/dao/TbCfGoodstypeDao.java
+3
-1
TbCategoryTemplateDao.xml
...main/resources/com/platform/dao/TbCategoryTemplateDao.xml
+1
-2
ImpartCode.java
platform-admin/src/main/test/java/test/ImpartCode.java
+82
-64
TestApi.java
platform-admin/src/main/test/java/test/TestApi.java
+10
-10
没有找到文件。
platform-admin/src/main/java/com/platform/controller/api/ShopifyController.java
浏览文件 @
676c7994
...
@@ -69,7 +69,7 @@ public class ShopifyController {
...
@@ -69,7 +69,7 @@ public class ShopifyController {
*
*
* @return 保存商品数据
* @return 保存商品数据
*/
*/
@PostMapping
(
"/save"
)
/*
@PostMapping("/save")
public R save() {
public R save() {
// 记录页数的
// 记录页数的
int pageSize = 0;
int pageSize = 0;
...
@@ -213,8 +213,8 @@ public class ShopifyController {
...
@@ -213,8 +213,8 @@ public class ShopifyController {
tbCfGoodstypeDao.save(tbCfGoodstypeEntity);
tbCfGoodstypeDao.save(tbCfGoodstypeEntity);
} else {
} else {
// 如果已存在一级分类名,则使用已存在的 id
// 如果已存在一级分类名,则使用已存在的 id
TbCfGoodstypeEntity
tbCfGoodstypeEntity
=
tbCfGoodstypeDao
.
queryByTitle
(
product_type
);
*//*TbCfGoodstypeEntity tbCfGoodstypeEntity = tbCfGoodstypeDao.queryByTitle(product_type);*//*
goods_type_id
=
tbCfGoodstypeEntity
.
getGoodstypeId
();
*//*oods_type_id = tbCfGoodstypeEntity.getGoodstypeId();*//*
}
}
String goodsTwoId = IdUtil.simpleUUID(); // 商品二级分类id
String goodsTwoId = IdUtil.simpleUUID(); // 商品二级分类id
...
@@ -303,7 +303,7 @@ public class ShopifyController {
...
@@ -303,7 +303,7 @@ public class ShopifyController {
// 记录页数
// 记录页数
pageSize++;
pageSize++;
}
}
}
}
*/
/**
/**
* 补录失败的商品
* 补录失败的商品
...
...
platform-admin/src/main/java/com/platform/dao/TbCategoryTemplateDao.java
浏览文件 @
676c7994
...
@@ -2,6 +2,8 @@ package com.platform.dao;
...
@@ -2,6 +2,8 @@ package com.platform.dao;
import
com.platform.entity.TbCategoryTemplateEntity
;
import
com.platform.entity.TbCategoryTemplateEntity
;
import
java.util.List
;
/**
/**
* Dao
* Dao
*
*
...
@@ -10,6 +12,6 @@ import com.platform.entity.TbCategoryTemplateEntity;
...
@@ -10,6 +12,6 @@ import com.platform.entity.TbCategoryTemplateEntity;
*/
*/
public
interface
TbCategoryTemplateDao
extends
BaseDao
<
TbCategoryTemplateEntity
>
{
public
interface
TbCategoryTemplateDao
extends
BaseDao
<
TbCategoryTemplateEntity
>
{
TbCategoryTemplateEntity
queryByDesc
(
String
category_desc
);
List
<
TbCategoryTemplateEntity
>
queryByDesc
(
String
category_desc
);
}
}
platform-admin/src/main/java/com/platform/dao/TbCfDescripitonDao.java
浏览文件 @
676c7994
...
@@ -14,5 +14,5 @@ public interface TbCfDescripitonDao extends BaseDao<TbCfDescripitonEntity> {
...
@@ -14,5 +14,5 @@ public interface TbCfDescripitonDao extends BaseDao<TbCfDescripitonEntity> {
List
<
TbCfDescripitonEntity
>
queryByItemTypeTwo
(
String
id
);
List
<
TbCfDescripitonEntity
>
queryByItemTypeTwo
(
String
id
);
TbCfDescripitonEntity
queryByDescriptionName
(
String
descripition_name
);
List
<
TbCfDescripitonEntity
>
queryByDescriptionName
(
String
descripition_name
);
}
}
platform-admin/src/main/java/com/platform/dao/TbCfGoodstwotypeDao.java
浏览文件 @
676c7994
...
@@ -17,5 +17,5 @@ public interface TbCfGoodstwotypeDao extends BaseDao<TbCfGoodstwotypeEntity> {
...
@@ -17,5 +17,5 @@ public interface TbCfGoodstwotypeDao extends BaseDao<TbCfGoodstwotypeEntity> {
List
<
TbCfGoodstwotypeEntity
>
queryByTypeId
(
String
typeId
);
List
<
TbCfGoodstwotypeEntity
>
queryByTypeId
(
String
typeId
);
TbCfGoodstwotypeEntity
queryTitle
(
String
title
);
List
<
TbCfGoodstwotypeEntity
>
queryTitle
(
String
title
);
}
}
platform-admin/src/main/java/com/platform/dao/TbCfGoodstypeDao.java
浏览文件 @
676c7994
...
@@ -2,6 +2,8 @@ package com.platform.dao;
...
@@ -2,6 +2,8 @@ package com.platform.dao;
import
com.platform.entity.TbCfGoodstypeEntity
;
import
com.platform.entity.TbCfGoodstypeEntity
;
import
java.util.List
;
/**
/**
* Dao
* Dao
*
*
...
@@ -16,6 +18,6 @@ public interface TbCfGoodstypeDao extends BaseDao<TbCfGoodstypeEntity> {
...
@@ -16,6 +18,6 @@ public interface TbCfGoodstypeDao extends BaseDao<TbCfGoodstypeEntity> {
* @param title 分类名称
* @param title 分类名称
* @return TbCfGoodstypeEntity
* @return TbCfGoodstypeEntity
*/
*/
TbCfGoodstypeEntity
queryByTitle
(
String
title
);
List
<
TbCfGoodstypeEntity
>
queryByTitle
(
String
title
);
}
}
platform-admin/src/main/resources/com/platform/dao/TbCategoryTemplateDao.xml
浏览文件 @
676c7994
...
@@ -33,10 +33,9 @@
...
@@ -33,10 +33,9 @@
`create_time`,
`create_time`,
`update_time`
`update_time`
from tb_category_template
from tb_category_template
where category_
desc = #{category_desc
}
where category_
name = #{category_name
}
</select>
</select>
<select
id=
"queryList"
resultType=
"com.platform.entity.TbCategoryTemplateEntity"
>
<select
id=
"queryList"
resultType=
"com.platform.entity.TbCategoryTemplateEntity"
>
select
select
`id`,
`id`,
...
...
platform-admin/src/main/test/java/test/ImpartCode.java
浏览文件 @
676c7994
...
@@ -116,7 +116,6 @@ public class ImpartCode {
...
@@ -116,7 +116,6 @@ public class ImpartCode {
}
}
}
}
}
}
}
}
/**
/**
...
@@ -161,37 +160,6 @@ public class ImpartCode {
...
@@ -161,37 +160,6 @@ public class ImpartCode {
// 商品详情
// 商品详情
int
optionNum
=
0
;
int
optionNum
=
0
;
StringBuilder
optionBuilder
=
new
StringBuilder
();
StringBuilder
optionBuilder
=
new
StringBuilder
();
StringBuilder
imageBuilder
=
new
StringBuilder
();
JSONArray
imagesArr
=
productsObj
.
getJSONArray
(
"images"
);
for
(
int
j
=
0
;
j
<
imagesArr
.
size
();
j
++)
{
JSONObject
imageObj
=
imagesArr
.
getJSONObject
(
j
);
// 上传图片
String
skuSrc
=
imageObj
.
getString
(
"src"
);
InputStream
skuInputStream
=
getImageStream
(
skuSrc
);
byte
[]
skuBytes
=
toByteArray
(
skuInputStream
);
String
url
=
OssUtil
.
upload
(
skuBytes
,
id
+
"_sku_"
+
j
+
".jpg"
,
"image"
);
// 拼接富文本的 HTML
imageBuilder
.
append
(
"<p><img src=\""
)
.
append
(
url
).
append
(
"\" title=\""
)
.
append
(
IdUtil
.
randomUUID
()).
append
(
"_350x350"
)
.
append
(
IdUtil
.
simpleUUID
()).
append
(
".jpg\"/></p>"
);
System
.
err
.
println
(
"富文本图片内容:"
+
imageBuilder
.
toString
());
}
TbCfItemDescEntity
itemDescEntity
=
tbCfItemDescDao
.
queryObject
(
itemId
);
if
(
itemDescEntity
==
null
)
{
itemDescEntity
=
new
TbCfItemDescEntity
();
itemDescEntity
.
setItemId
(
itemId
);
itemDescEntity
.
setItemDesc
(
imageBuilder
.
toString
());
itemDescEntity
.
setCreateTime
(
date
);
tbCfItemDescDao
.
save
(
itemDescEntity
);
}
// 上传图片获取主图
String
src
=
productsObj
.
getJSONObject
(
"image"
).
getString
(
"src"
);
InputStream
inputStream
=
getImageStream
(
src
);
byte
[]
bytes
=
toByteArray
(
inputStream
);
String
url
=
OssUtil
.
upload
(
bytes
,
id
+
"_station.jpg"
,
"image"
);
System
.
err
.
println
(
"主图的链接为: "
+
url
);
// 商品的属性
// 商品的属性
JSONArray
optionsArr
=
productsObj
.
getJSONArray
(
"options"
);
JSONArray
optionsArr
=
productsObj
.
getJSONArray
(
"options"
);
...
@@ -216,7 +184,7 @@ public class ImpartCode {
...
@@ -216,7 +184,7 @@ public class ImpartCode {
categoryEntity
.
setOption
(
"option"
+
optionNum
);
categoryEntity
.
setOption
(
"option"
+
optionNum
);
// 保存属性名
// 保存属性名
String
categoryId
=
IdUtil
.
simpleUUID
();
String
categoryId
=
IdUtil
.
simpleUUID
();
if
(
tbCategoryTemplateDao
.
queryByDesc
(
optionName
)
==
null
)
{
if
(
tbCategoryTemplateDao
.
queryByDesc
(
optionName
)
.
size
()
==
0
)
{
TbCategoryTemplateEntity
tbCategoryTemplateEntity
=
new
TbCategoryTemplateEntity
();
TbCategoryTemplateEntity
tbCategoryTemplateEntity
=
new
TbCategoryTemplateEntity
();
tbCategoryTemplateEntity
.
setId
(
categoryId
);
tbCategoryTemplateEntity
.
setId
(
categoryId
);
tbCategoryTemplateEntity
.
setCategoryDesc
(
optionName
);
tbCategoryTemplateEntity
.
setCategoryDesc
(
optionName
);
...
@@ -224,8 +192,10 @@ public class ImpartCode {
...
@@ -224,8 +192,10 @@ public class ImpartCode {
tbCategoryTemplateEntity
.
setCategoryName
(
optionName
);
tbCategoryTemplateEntity
.
setCategoryName
(
optionName
);
tbCategoryTemplateEntity
.
setUpdateTime
(
date
);
tbCategoryTemplateEntity
.
setUpdateTime
(
date
);
tbCategoryTemplateEntity
.
setUpdateTime
(
date
);
tbCategoryTemplateEntity
.
setUpdateTime
(
date
);
if
(
tbCategoryTemplateDao
.
queryByDesc
(
optionName
).
size
()
==
0
)
{
tbCategoryTemplateDao
.
save
(
tbCategoryTemplateEntity
);
tbCategoryTemplateDao
.
save
(
tbCategoryTemplateEntity
);
}
}
}
StringBuilder
categoryBuilder
=
new
StringBuilder
();
StringBuilder
categoryBuilder
=
new
StringBuilder
();
JSONArray
valuesArr
=
optionObj
.
getJSONArray
(
"values"
);
JSONArray
valuesArr
=
optionObj
.
getJSONArray
(
"values"
);
...
@@ -297,18 +267,24 @@ public class ImpartCode {
...
@@ -297,18 +267,24 @@ public class ImpartCode {
// 保存一级分类名
// 保存一级分类名
String
goods_type_id
=
IdUtil
.
simpleUUID
();
String
goods_type_id
=
IdUtil
.
simpleUUID
();
if
(
tbCfGoodstypeDao
.
queryByTitle
(
product_type
)
==
null
)
{
// 如果分类名已存在则不保存
if
(
tbCfGoodstypeDao
.
queryByTitle
(
product_type
)
.
size
()
==
0
)
{
// 如果分类名已存在则不保存
TbCfGoodstypeEntity
tbCfGoodstypeEntity
=
new
TbCfGoodstypeEntity
();
TbCfGoodstypeEntity
tbCfGoodstypeEntity
=
new
TbCfGoodstypeEntity
();
tbCfGoodstypeEntity
.
setGoodstypeId
(
goods_type_id
);
tbCfGoodstypeEntity
.
setGoodstypeId
(
goods_type_id
);
tbCfGoodstypeEntity
.
setGoodstypeTitle
(
product_type
);
tbCfGoodstypeEntity
.
setGoodstypeTitle
(
product_type
);
tbCfGoodstypeEntity
.
setGoodstypeSort
(
tbCfGoodstypeDao
.
queryTotal
()
+
1
);
tbCfGoodstypeEntity
.
setGoodstypeSort
(
tbCfGoodstypeDao
.
queryTotal
()
+
1
);
product_type
=
product_type
.
replaceAll
(
" "
,
"-"
);
product_type
=
product_type
.
replaceAll
(
" "
,
"-"
);
tbCfGoodstypeEntity
.
setGoodstypeUrl
(
"https://www.afrieshop.com/collections/"
+
product_type
);
tbCfGoodstypeEntity
.
setGoodstypeUrl
(
"https://www.afrieshop.com/collections/"
+
product_type
);
if
(
tbCfGoodstypeDao
.
queryByTitle
(
product_type
).
size
()
==
0
)
{
// 如果分类名已存在则不保存
tbCfGoodstypeDao
.
save
(
tbCfGoodstypeEntity
);
tbCfGoodstypeDao
.
save
(
tbCfGoodstypeEntity
);
}
else
{
}
else
{
// 如果已存在一级分类名,则使用已存在的 id
// 如果已存在一级分类名,则使用已存在的 id
TbCfGoodstypeEntity
tbCfGoodstypeEntity
=
tbCfGoodstypeDao
.
queryByTitle
(
product_type
);
List
<
TbCfGoodstypeEntity
>
tbCfGoodstypeEntity1
=
tbCfGoodstypeDao
.
queryByTitle
(
product_type
);
goods_type_id
=
tbCfGoodstypeEntity
.
getGoodstypeId
();
goods_type_id
=
tbCfGoodstypeEntity1
.
get
(
0
).
getGoodstypeId
();
}
}
else
{
// 如果已存在一级分类名,则使用已存在的 id
List
<
TbCfGoodstypeEntity
>
tbCfGoodstypeEntity
=
tbCfGoodstypeDao
.
queryByTitle
(
product_type
);
goods_type_id
=
tbCfGoodstypeEntity
.
get
(
0
).
getGoodstypeId
();
}
}
// 解析二三级分类名
// 解析二三级分类名
...
@@ -325,29 +301,39 @@ public class ImpartCode {
...
@@ -325,29 +301,39 @@ public class ImpartCode {
// 保存二级分类名
// 保存二级分类名
String
goodsTwoId
=
IdUtil
.
simpleUUID
();
String
goodsTwoId
=
IdUtil
.
simpleUUID
();
if
(
tbCfGoodstwotypeDao
.
queryTitle
(
tags
)
==
null
)
{
if
(
tbCfGoodstwotypeDao
.
queryTitle
(
tags
)
.
size
()
==
0
)
{
TbCfGoodstwotypeEntity
tbCfGoodstwotypeEntity
=
new
TbCfGoodstwotypeEntity
();
TbCfGoodstwotypeEntity
tbCfGoodstwotypeEntity
=
new
TbCfGoodstwotypeEntity
();
tbCfGoodstwotypeEntity
.
setGoodstwotypeId
(
goodsTwoId
);
tbCfGoodstwotypeEntity
.
setGoodstwotypeId
(
goodsTwoId
);
tbCfGoodstwotypeEntity
.
setGoodstwotypeTitle
(
tags
);
tbCfGoodstwotypeEntity
.
setGoodstwotypeTitle
(
tags
);
tbCfGoodstwotypeEntity
.
setGoodstypeId
(
goods_type_id
);
tbCfGoodstwotypeEntity
.
setGoodstypeId
(
goods_type_id
);
if
(
tbCfGoodstwotypeDao
.
queryTitle
(
tags
).
size
()
==
0
)
{
tbCfGoodstwotypeDao
.
save
(
tbCfGoodstwotypeEntity
);
tbCfGoodstwotypeDao
.
save
(
tbCfGoodstwotypeEntity
);
}
else
{
}
else
{
TbCfGoodstwotypeEntity
tbCfGoodstwotypeEntity
=
tbCfGoodstwotypeDao
.
queryTitle
(
tags
);
List
<
TbCfGoodstwotypeEntity
>
tbCfGoodstwotypeEntity1
=
tbCfGoodstwotypeDao
.
queryTitle
(
tags
);
goodsTwoId
=
tbCfGoodstwotypeEntity
.
getGoodstwotypeId
();
goodsTwoId
=
tbCfGoodstwotypeEntity1
.
get
(
0
).
getGoodstwotypeId
();
}
}
else
{
List
<
TbCfGoodstwotypeEntity
>
tbCfGoodstwotypeEntity
=
tbCfGoodstwotypeDao
.
queryTitle
(
tags
);
goodsTwoId
=
tbCfGoodstwotypeEntity
.
get
(
0
).
getGoodstwotypeId
();
}
}
// 保存三级分类名(品名)
// 保存三级分类名(品名)
String
goodsThreeId
=
IdUtil
.
simpleUUID
();
String
goodsThreeId
=
IdUtil
.
simpleUUID
();
if
(
tbCfDescripitonDao
.
queryByDescriptionName
(
three
)
==
null
)
{
if
(
tbCfDescripitonDao
.
queryByDescriptionName
(
three
)
.
size
()
==
0
)
{
TbCfDescripitonEntity
tbCfDescripitonEntity
=
new
TbCfDescripitonEntity
();
TbCfDescripitonEntity
tbCfDescripitonEntity
=
new
TbCfDescripitonEntity
();
tbCfDescripitonEntity
.
setDescripitionId
(
goodsThreeId
);
tbCfDescripitonEntity
.
setDescripitionId
(
goodsThreeId
);
tbCfDescripitonEntity
.
setDescripitionName
(
three
);
tbCfDescripitonEntity
.
setDescripitionName
(
three
);
tbCfDescripitonEntity
.
setGoodstypeId
(
goods_type_id
);
tbCfDescripitonEntity
.
setGoodstypeId
(
goods_type_id
);
tbCfDescripitonEntity
.
setGoodstwotypeId
(
goodsTwoId
);
tbCfDescripitonEntity
.
setGoodstwotypeId
(
goodsTwoId
);
if
(
tbCfDescripitonDao
.
queryByDescriptionName
(
three
).
size
()
==
0
)
{
tbCfDescripitonDao
.
save
(
tbCfDescripitonEntity
);
tbCfDescripitonDao
.
save
(
tbCfDescripitonEntity
);
}
else
{
}
else
{
TbCfDescripitonEntity
tbCfDescripitonEntity
=
tbCfDescripitonDao
.
queryByDescriptionName
(
three
);
List
<
TbCfDescripitonEntity
>
tbCfDescripitonEntity1
=
tbCfDescripitonDao
.
queryByDescriptionName
(
three
);
goodsThreeId
=
tbCfDescripitonEntity
.
getDescripitionId
();
goodsThreeId
=
tbCfDescripitonEntity1
.
get
(
0
).
getDescripitionId
();
}
}
else
{
List
<
TbCfDescripitonEntity
>
tbCfDescripitonEntity
=
tbCfDescripitonDao
.
queryByDescriptionName
(
three
);
goodsThreeId
=
tbCfDescripitonEntity
.
get
(
0
).
getDescripitionId
();
}
}
// 保存商品的主体信息
// 保存商品的主体信息
...
@@ -364,10 +350,42 @@ public class ImpartCode {
...
@@ -364,10 +350,42 @@ public class ImpartCode {
tbCfStationItem
.
setItemDescritionId
(
goodsThreeId
);
tbCfStationItem
.
setItemDescritionId
(
goodsThreeId
);
tbCfStationItem
.
setItemTags
(
product_type
+
","
+
tags
+
","
+
three
);
tbCfStationItem
.
setItemTags
(
product_type
+
","
+
tags
+
","
+
three
);
tbCfStationItem
.
setItemTop
(
"N"
);
tbCfStationItem
.
setItemTop
(
"N"
);
// 上传图片获取主图
String
src
=
productsObj
.
getJSONObject
(
"image"
).
getString
(
"src"
);
InputStream
inputStream
=
getImageStream
(
src
);
byte
[]
bytes
=
toByteArray
(
inputStream
);
String
url
=
OssUtil
.
upload
(
bytes
,
id
+
"_station.jpg"
,
"image"
);
System
.
err
.
println
(
"主图的链接为: "
+
url
);
tbCfStationItem
.
setItemImg
(
url
);
tbCfStationItem
.
setItemImg
(
url
);
tbCfStationItem
.
setEnableFlag
(
2
);
tbCfStationItem
.
setEnableFlag
(
2
);
tbCfStationItemDao
.
save
(
tbCfStationItem
);
tbCfStationItemDao
.
save
(
tbCfStationItem
);
StringBuilder
imageBuilder
=
new
StringBuilder
();
JSONArray
imagesArr
=
productsObj
.
getJSONArray
(
"images"
);
for
(
int
j
=
0
;
j
<
imagesArr
.
size
();
j
++)
{
JSONObject
imageObj
=
imagesArr
.
getJSONObject
(
j
);
// 上传图片
String
skuSrc
=
imageObj
.
getString
(
"src"
);
InputStream
skuInputStream
=
getImageStream
(
skuSrc
);
byte
[]
skuBytes
=
toByteArray
(
skuInputStream
);
String
skuUrl
=
OssUtil
.
upload
(
skuBytes
,
id
+
"_sku_"
+
j
+
".jpg"
,
"image"
);
// 拼接富文本的 HTML
imageBuilder
.
append
(
"<p><img src=\""
)
.
append
(
skuUrl
).
append
(
"\" title=\""
)
.
append
(
IdUtil
.
randomUUID
()).
append
(
"_350x350"
)
.
append
(
IdUtil
.
simpleUUID
()).
append
(
".jpg\"/></p>"
);
System
.
err
.
println
(
"富文本图片内容:"
+
imageBuilder
.
toString
());
}
TbCfItemDescEntity
itemDescEntity
=
tbCfItemDescDao
.
queryObject
(
itemId
);
if
(
itemDescEntity
==
null
)
{
itemDescEntity
=
new
TbCfItemDescEntity
();
itemDescEntity
.
setItemId
(
itemId
);
itemDescEntity
.
setItemDesc
(
imageBuilder
.
toString
());
itemDescEntity
.
setCreateTime
(
date
);
tbCfItemDescDao
.
save
(
itemDescEntity
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
// 记录失败的产品记录
// 记录失败的产品记录
...
...
platform-admin/src/main/test/java/test/TestApi.java
浏览文件 @
676c7994
...
@@ -158,20 +158,20 @@ public class TestApi {
...
@@ -158,20 +158,20 @@ public class TestApi {
.
execute
().
body
();
.
execute
().
body
();
JSONObject
jsonObject
=
JSONObject
.
fromObject
(
result
);
JSONObject
jsonObject
=
JSONObject
.
fromObject
(
result
);
// 第一次导入
// 第一次导入
once
(
result
);
//
once(result);
// 解析请求头,获取到下一页的 url
// 解析请求头,获取到下一页的 url
String
headerLink
=
HttpRequest
.
get
(
link
)
String
headerLink
=
HttpRequest
.
get
(
link
)
.
header
(
"Authorization"
,
"Basic N2YwZTA0OGFjNDAxNmI5MzU3YmIxZWIyMjE3ZTQyMDE6MWM5N2ExMjIyYzViNDBlMDU5N2M4MTZjNmRmZWNhYzA="
)
.
header
(
"Authorization"
,
"Basic N2YwZTA0OGFjNDAxNmI5MzU3YmIxZWIyMjE3ZTQyMDE6MWM5N2ExMjIyYzViNDBlMDU5N2M4MTZjNmRmZWNhYzA="
)
.
execute
().
header
(
"link"
);
.
execute
().
header
(
"link"
);
headerLink
=
headerLink
.
split
(
";"
)[
0
].
replaceAll
(
"<"
,
""
).
replaceAll
(
">"
,
""
);
headerLink
=
headerLink
.
split
(
";"
)[
0
].
replaceAll
(
"<"
,
""
).
replaceAll
(
">"
,
""
);
// 无限导入
// 无限导入
unlimited
(
headerLink
);
//
unlimited(headerLink);
}
}
/**
/**
* 第一遍循环导入
* 第一遍循环导入
*/
*/
private
void
once
(
String
data
)
{
/*
private void once(String data) {
// 记录页数的
// 记录页数的
int productCount = 0;
int productCount = 0;
// json 化返回数据
// json 化返回数据
...
@@ -305,8 +305,8 @@ public class TestApi {
...
@@ -305,8 +305,8 @@ public class TestApi {
tbCfGoodstypeDao.save(tbCfGoodstypeEntity);
tbCfGoodstypeDao.save(tbCfGoodstypeEntity);
} else {
} else {
// 如果已存在一级分类名,则使用已存在的 id
// 如果已存在一级分类名,则使用已存在的 id
TbCfGoodstypeEntity
tbCfGoodstypeEntity
=
tbCfGoodstypeDao
.
queryByTitle
(
product_type
);
*//*TbCfGoodstypeEntity tbCfGoodstypeEntity = tbCfGoodstypeDao.queryByTitle(product_type);*//*
goods_type_id
=
tbCfGoodstypeEntity
.
getGoodstypeId
();
*//*goods_type_id = tbCfGoodstypeEntity.getGoodstypeId();*//*
}
}
// 二级分类名
// 二级分类名
...
@@ -423,12 +423,12 @@ public class TestApi {
...
@@ -423,12 +423,12 @@ public class TestApi {
tbProductMissDao.save(tbProductMissEntity);
tbProductMissDao.save(tbProductMissEntity);
}
}
}
}
}
}
*/
/**
/**
* 无限循环导入
* 无限循环导入
*/
*/
private
void
unlimited
(
String
link
)
{
/*
private void unlimited(String link) {
// 记录页数的
// 记录页数的
int pageSize = 0;
int pageSize = 0;
int productCount = 1;
int productCount = 1;
...
@@ -570,8 +570,8 @@ public class TestApi {
...
@@ -570,8 +570,8 @@ public class TestApi {
tbCfGoodstypeDao.save(tbCfGoodstypeEntity);
tbCfGoodstypeDao.save(tbCfGoodstypeEntity);
} else {
} else {
// 如果已存在一级分类名,则使用已存在的 id
// 如果已存在一级分类名,则使用已存在的 id
TbCfGoodstypeEntity
tbCfGoodstypeEntity
=
tbCfGoodstypeDao
.
queryByTitle
(
product_type
);
*//*
TbCfGoodstypeEntity tbCfGoodstypeEntity = tbCfGoodstypeDao.queryByTitle(product_type);
goods_type_id
=
tbCfGoodstypeEntity
.
getGoodstypeId
();
goods_type_id = tbCfGoodstypeEntity.getGoodstypeId();
*//*
}
}
// 二级分类名
// 二级分类名
...
@@ -678,7 +678,7 @@ public class TestApi {
...
@@ -678,7 +678,7 @@ public class TestApi {
pageSize++;
pageSize++;
}
}
}
}
*/
/**
/**
* 通过URL获取网络图片
* 通过URL获取网络图片
* 获取网络图片流
* 获取网络图片流
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论