提交 553643cf authored 作者: renjianyu's avatar renjianyu

--no commit message

上级 75b1b3b2
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论