Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
C
chinafrica
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
zhengfg
chinafrica
Commits
679c8712
提交
679c8712
authored
3月 19, 2020
作者:
梁业锦
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
- 商品导入相关逻辑
上级
affc4772
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
71 行增加
和
552 行删除
+71
-552
ImpartCode.java
platform-admin/src/main/test/java/test/ImpartCode.java
+55
-21
TestApi.java
platform-admin/src/main/test/java/test/TestApi.java
+16
-531
没有找到文件。
platform-admin/src/main/test/java/test/ImpartCode.java
浏览文件 @
679c8712
...
@@ -117,7 +117,17 @@ public class ImpartCode {
...
@@ -117,7 +117,17 @@ public class ImpartCode {
}
}
}
}
}
}
/**
* 商品导入处理
*
* @param link 请求链接
*/
private
void
updateCategory
(
String
link
)
{
}
/**
/**
* 商品导入处理
* 商品导入处理
*
*
...
@@ -288,32 +298,46 @@ public class ImpartCode {
...
@@ -288,32 +298,46 @@ public class ImpartCode {
}
}
// 解析二三级分类名
// 解析二三级分类名
String
t
ags
=
""
;
String
t
wo
=
""
;
String
three
=
""
;
String
three
=
""
;
String
[]
s
=
productsObj
.
getString
(
"tags"
).
split
(
","
);
String
[]
s
=
productsObj
.
getString
(
"tags"
).
split
(
","
);
for
(
String
str
:
s
)
{
// 切割的字符串数组有 2 个
if
(
str
.
indexOf
(
"#"
)
==
0
)
{
if
(
s
.
length
>
1
)
{
tags
=
str
.
replaceAll
(
"#"
,
""
);
// 可能出现 #分类名,#分类名:第一个为二级
if
(
s
[
0
].
contains
(
"#"
)
&&
s
[
1
].
contains
(
"#"
))
{
two
=
s
[
0
].
replaceAll
(
"#"
,
""
);
three
=
s
[
1
].
replaceAll
(
"#"
,
""
);
}
else
{
}
else
{
three
=
str
;
// 包含着 #分类名 的是三级
if
(
s
[
0
].
contains
(
"#"
))
{
three
=
s
[
0
].
replaceAll
(
"#"
,
""
);
two
=
s
[
1
];
}
else
{
two
=
s
[
0
].
replaceAll
(
"#"
,
""
);
three
=
s
[
1
];
}
}
}
}
else
{
// 如果只有一个,那么为二级
two
=
s
[
0
].
replaceAll
(
"#"
,
""
);
}
}
// 保存二级分类名
// 保存二级分类名
String
goodsTwoId
=
IdUtil
.
simpleUUID
();
String
goodsTwoId
=
IdUtil
.
simpleUUID
();
if
(
tbCfGoodstwotypeDao
.
queryTitle
(
t
ags
).
size
()
==
0
)
{
if
(
tbCfGoodstwotypeDao
.
queryTitle
(
t
wo
).
size
()
==
0
)
{
TbCfGoodstwotypeEntity
tbCfGoodstwotypeEntity
=
new
TbCfGoodstwotypeEntity
();
TbCfGoodstwotypeEntity
tbCfGoodstwotypeEntity
=
new
TbCfGoodstwotypeEntity
();
tbCfGoodstwotypeEntity
.
setGoodstwotypeId
(
goodsTwoId
);
tbCfGoodstwotypeEntity
.
setGoodstwotypeId
(
goodsTwoId
);
tbCfGoodstwotypeEntity
.
setGoodstwotypeTitle
(
t
ags
);
tbCfGoodstwotypeEntity
.
setGoodstwotypeTitle
(
t
wo
);
tbCfGoodstwotypeEntity
.
setGoodstypeId
(
goods_type_id
);
tbCfGoodstwotypeEntity
.
setGoodstypeId
(
goods_type_id
);
if
(
tbCfGoodstwotypeDao
.
queryTitle
(
t
ags
).
size
()
==
0
)
{
if
(
tbCfGoodstwotypeDao
.
queryTitle
(
t
wo
).
size
()
==
0
)
{
tbCfGoodstwotypeDao
.
save
(
tbCfGoodstwotypeEntity
);
tbCfGoodstwotypeDao
.
save
(
tbCfGoodstwotypeEntity
);
}
else
{
}
else
{
List
<
TbCfGoodstwotypeEntity
>
tbCfGoodstwotypeEntity1
=
tbCfGoodstwotypeDao
.
queryTitle
(
t
ags
);
List
<
TbCfGoodstwotypeEntity
>
tbCfGoodstwotypeEntity1
=
tbCfGoodstwotypeDao
.
queryTitle
(
t
wo
);
goodsTwoId
=
tbCfGoodstwotypeEntity1
.
get
(
0
).
getGoodstwotypeId
();
goodsTwoId
=
tbCfGoodstwotypeEntity1
.
get
(
0
).
getGoodstwotypeId
();
}
}
}
else
{
}
else
{
List
<
TbCfGoodstwotypeEntity
>
tbCfGoodstwotypeEntity
=
tbCfGoodstwotypeDao
.
queryTitle
(
t
ags
);
List
<
TbCfGoodstwotypeEntity
>
tbCfGoodstwotypeEntity
=
tbCfGoodstwotypeDao
.
queryTitle
(
t
wo
);
goodsTwoId
=
tbCfGoodstwotypeEntity
.
get
(
0
).
getGoodstwotypeId
();
goodsTwoId
=
tbCfGoodstwotypeEntity
.
get
(
0
).
getGoodstwotypeId
();
}
}
...
@@ -348,14 +372,14 @@ public class ImpartCode {
...
@@ -348,14 +372,14 @@ public class ImpartCode {
tbCfStationItem
.
setItemCategory
(
goods_type_id
);
tbCfStationItem
.
setItemCategory
(
goods_type_id
);
tbCfStationItem
.
setItemCategorytwo
(
goodsTwoId
);
tbCfStationItem
.
setItemCategorytwo
(
goodsTwoId
);
tbCfStationItem
.
setItemDescritionId
(
goodsThreeId
);
tbCfStationItem
.
setItemDescritionId
(
goodsThreeId
);
tbCfStationItem
.
setItemTags
(
product_type
+
","
+
t
ags
+
","
+
three
);
tbCfStationItem
.
setItemTags
(
product_type
+
","
+
t
wo
+
","
+
three
);
tbCfStationItem
.
setItemTop
(
"N"
);
tbCfStationItem
.
setItemTop
(
"N"
);
// 上传图片获取主图
// 上传图片获取主图
String
src
=
productsObj
.
getJSONObject
(
"image"
).
getString
(
"src"
);
String
src
=
productsObj
.
getJSONObject
(
"image"
).
getString
(
"src"
);
InputStream
inputStream
=
getImageStream
(
src
);
InputStream
inputStream
=
getImageStream
(
src
);
byte
[]
bytes
=
toByteArray
(
inputStream
);
byte
[]
bytes
=
toByteArray
(
inputStream
);
String
url
=
OssUtil
.
upload
(
bytes
,
id
+
"_station.jpg"
,
"
image
"
);
String
url
=
OssUtil
.
upload
(
bytes
,
id
+
"_station.jpg"
,
"
zion
"
);
System
.
err
.
println
(
"主图的链接为: "
+
url
);
System
.
err
.
println
(
"主图的链接为: "
+
url
);
tbCfStationItem
.
setItemImg
(
url
);
tbCfStationItem
.
setItemImg
(
url
);
...
@@ -368,14 +392,24 @@ public class ImpartCode {
...
@@ -368,14 +392,24 @@ public class ImpartCode {
JSONObject
imageObj
=
imagesArr
.
getJSONObject
(
j
);
JSONObject
imageObj
=
imagesArr
.
getJSONObject
(
j
);
// 上传图片
// 上传图片
String
skuSrc
=
imageObj
.
getString
(
"src"
);
String
skuSrc
=
imageObj
.
getString
(
"src"
);
InputStream
skuInputStream
=
getImageStream
(
skuSrc
);
try
{
byte
[]
skuBytes
=
toByteArray
(
skuInputStream
);
InputStream
skuInputStream
=
getImageStream
(
skuSrc
);
String
skuUrl
=
OssUtil
.
upload
(
skuBytes
,
id
+
"_sku_"
+
j
+
".jpg"
,
"image"
);
byte
[]
skuBytes
=
toByteArray
(
skuInputStream
);
// 拼接富文本的 HTML
String
skuUrl
=
OssUtil
.
upload
(
skuBytes
,
id
+
"_sku_"
+
j
+
".jpg"
,
"zion"
);
imageBuilder
.
append
(
"<p><img src=\""
)
// 拼接富文本的 HTML
.
append
(
skuUrl
).
append
(
"\" title=\""
)
imageBuilder
.
append
(
"<p><img src=\""
)
.
append
(
IdUtil
.
randomUUID
()).
append
(
"_350x350"
)
.
append
(
skuUrl
).
append
(
"\" title=\""
)
.
append
(
IdUtil
.
simpleUUID
()).
append
(
".jpg\"/></p>"
);
.
append
(
IdUtil
.
randomUUID
()).
append
(
"_350x350"
)
.
append
(
IdUtil
.
simpleUUID
()).
append
(
".jpg\"/></p>"
);
}
catch
(
Exception
e
)
{
// 没有详情图片,则用主图凑活一下
imageBuilder
=
new
StringBuilder
();
imageBuilder
.
append
(
"<p><img src=\""
)
.
append
(
url
).
append
(
"\" title=\""
)
.
append
(
IdUtil
.
randomUUID
()).
append
(
"_350x350"
)
.
append
(
IdUtil
.
simpleUUID
()).
append
(
".jpg\"/></p>"
);
break
;
}
System
.
err
.
println
(
"富文本图片内容:"
+
imageBuilder
.
toString
());
System
.
err
.
println
(
"富文本图片内容:"
+
imageBuilder
.
toString
());
}
}
TbCfItemDescEntity
itemDescEntity
=
tbCfItemDescDao
.
queryObject
(
itemId
);
TbCfItemDescEntity
itemDescEntity
=
tbCfItemDescDao
.
queryObject
(
itemId
);
...
...
platform-admin/src/main/test/java/test/TestApi.java
浏览文件 @
679c8712
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论