Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
scsm
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
注册表
注册表
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
svn
scsm
Commits
553643cf
提交
553643cf
authored
6月 28, 2020
作者:
renjianyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
上级
75b1b3b2
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
36 行增加
和
6 行删除
+36
-6
JdController.java
...java/com/zrqx/resource/bg/controller/jd/JdController.java
+36
-6
没有找到文件。
com.zrqx.resource/src/main/java/com/zrqx/resource/bg/controller/jd/JdController.java
浏览文件 @
553643cf
package
com
.
zrqx
.
resource
.
bg
.
controller
.
jd
;
import
java.util.Date
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -8,10 +9,13 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RestController
;
import
com.zrqx.core.constant.resource.ResourceRequestPath
;
import
com.zrqx.core.model.resource.diytype.DiyType
;
import
com.zrqx.core.model.resource.ebook.Ebook
;
import
com.zrqx.core.model.resource.ebook.EbookDiyType
;
import
com.zrqx.core.model.resource.ebook.EbookImage
;
import
com.zrqx.core.model.resource.jd.JdList
;
import
com.zrqx.core.util.response.CallBack
;
import
com.zrqx.resource.bg.service.diytype.DiyTypeService
;
import
com.zrqx.resource.bg.service.ebook.EBookImageService
;
import
com.zrqx.resource.bg.service.ebook.EbookDiyTypeService
;
import
com.zrqx.resource.bg.service.ebook.EbookService
;
...
...
@@ -20,6 +24,7 @@ import com.zrqx.resource.commons.Redis;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
tk.mybatis.mapper.entity.Example
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
...
...
@@ -52,6 +57,8 @@ public class JdController {
@Autowired
private
EbookDiyTypeService
dtservice
;
@Autowired
private
DiyTypeService
diyTypeService
;
@Autowired
private
Redis
redis
;
@Autowired
private
JdService
jdservice
;
...
...
@@ -62,8 +69,15 @@ public class JdController {
@PostMapping
(
ResourceRequestPath
.
SAVE
)
public
CallBack
<?>
saveBook
()
{
List
<
JdList
>
list
=
jdservice
.
selectAll
();
Ebook
ebook
=
new
Ebook
();
for
(
JdList
jdList
:
list
)
{
try
{
Thread
.
sleep
(
3000
);
}
catch
(
InterruptedException
e1
)
{
// TODO Auto-generated catch block
e1
.
printStackTrace
();
}
Ebook
ebook
=
new
Ebook
();
String
url
=
jdList
.
getDizhi
();
String
[]
cmds
=
{
"curl"
,
"https://dx.3.cn/desc/"
+
jdList
.
getId
()
+
"?encode=utf-8&cdn=2&callback=showdesc"
};
...
...
@@ -183,19 +197,35 @@ public class JdController {
if
(
img
!=
null
&&
imgs
.
hasAttr
(
"src"
))
{
for
(
int
i
=
0
;
i
<
imgs
.
size
();
i
++)
{
if
(
i
<
1
)
{
ebook
.
setBookCover
(
imgs
.
get
(
i
).
attr
(
"src
"
));
ebook
.
setBookCover
(
"https:"
+
imgs
.
get
(
i
).
attr
(
"src"
).
replace
(
"/n5"
,
"/n1
"
));
}
}
}
//上下架查询
ebook
.
setBookStatus
(
1
);
ebook
.
setUploadTime
(
new
Date
());
ebook
.
setUpdateTime
(
new
Date
());
ebookservice
.
insert
(
ebook
);
//分类添加
Example
example
=
diyTypeService
.
createExample
();
example
.
createCriteria
().
andEqualTo
(
"showName"
,
jdList
.
getType
());
List
<
DiyType
>
distype
=
diyTypeService
.
selectByExample
(
example
);
EbookDiyType
type
=
new
EbookDiyType
();
type
.
setEbookId
(
ebook
.
getId
());
type
.
setDiyTypeId
(
distype
.
get
(
0
).
getId
());
type
.
setCode
(
distype
.
get
(
0
).
getCode
());
dtservice
.
insert
(
type
);
if
(
img
!=
null
&&
imgs
.
hasAttr
(
"src"
))
{
EbookImage
ebookImage
=
new
EbookImage
();
for
(
int
i
=
0
;
i
<
imgs
.
size
();
i
++)
{
if
(
i
<
4
)
{
EbookImage
ebookImage
=
new
EbookImage
();
ebookImage
.
setEbookId
(
ebook
.
getId
());
ebookImage
.
setCover
(
imgs
.
get
(
i
).
attr
(
"src
"
));
System
.
out
.
println
(
"11111111111111https:"
+
imgs
.
get
(
i
).
attr
(
"src"
)
);
ebookImage
.
setCover
(
"https:"
+
imgs
.
get
(
i
).
attr
(
"src"
).
replace
(
"/n5"
,
"/n1
"
));
ebookImageService
.
insert
(
ebookImage
);
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论