|
|
@@ -0,0 +1,77 @@
|
|
|
+package com.uas.platform.b2c.prod.product.component.service.impl;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.uas.platform.b2c.prod.product.component.dao.ComponentCrawlDao;
|
|
|
+import com.uas.platform.b2c.prod.product.component.dao.ComponentCrawlTaskDao;
|
|
|
+import com.uas.platform.b2c.prod.product.component.modal.ComponentCrawlTask;
|
|
|
+import com.uas.platform.b2c.prod.product.component.service.ComponentCrawlService;
|
|
|
+import com.uas.platform.core.exception.IllegalOperatorException;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by wangyc on 2017/11/17.
|
|
|
+ *
|
|
|
+ * @version 2017/11/17 16:10 wangyc
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class ComponentCrawlServiceImpl implements ComponentCrawlService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ComponentCrawlTaskDao componentCrawlTaskDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ComponentCrawlDao componentCrawlDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private JdbcTemplate jdbcTemplate;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<String> downloadImg(String taskId) {
|
|
|
+ ComponentCrawlTask task = componentCrawlTaskDao.findByTaskId(taskId);
|
|
|
+ if (task == null) {
|
|
|
+ throw new IllegalOperatorException("任务不存在");
|
|
|
+ }
|
|
|
+ List<String> imgs = componentCrawlDao.findImgByTask(task.getId());
|
|
|
+ return imgs;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<String> downloadAttach(String taskId) {
|
|
|
+ ComponentCrawlTask task = componentCrawlTaskDao.findByTaskId(taskId);
|
|
|
+ if (task == null) {
|
|
|
+ throw new IllegalOperatorException("任务不存在");
|
|
|
+ }
|
|
|
+ List<String> attachs = componentCrawlDao.findAttachByTask(task.getId());
|
|
|
+ return attachs;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String uploadImg(JSONObject jsonObject) {
|
|
|
+ String taskId = jsonObject.getString("taskId");
|
|
|
+ String oldUrl = jsonObject.getString("oldUrl");
|
|
|
+ String newUrl = jsonObject.getString("newUrl");
|
|
|
+ ComponentCrawlTask task = componentCrawlTaskDao.findByTaskId(taskId);
|
|
|
+ if (task == null) {
|
|
|
+ throw new IllegalOperatorException("任务不存在");
|
|
|
+ }
|
|
|
+ jdbcTemplate.update("update product$component_crawl set cc_b2c_img = \'" + newUrl + "\' where cc_task = " + task.getId() + " and cc_img = \'" + oldUrl + "' and cc_b2c_img is null" );
|
|
|
+ return "success";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String uploadAttach(JSONObject jsonObject) {
|
|
|
+ String taskId = jsonObject.getString("taskId");
|
|
|
+ String oldUrl = jsonObject.getString("oldUrl");
|
|
|
+ String newUrl = jsonObject.getString("newUrl");
|
|
|
+ ComponentCrawlTask task = componentCrawlTaskDao.findByTaskId(taskId);
|
|
|
+ if (task == null) {
|
|
|
+ throw new IllegalOperatorException("任务不存在");
|
|
|
+ }
|
|
|
+ jdbcTemplate.update("update product$component_crawl set cc_b2c_attach = \'" + newUrl + "\' where cc_task = " + task.getId() + " and cc_attach = \'" + oldUrl + "' and cc_b2c_attach is null" );
|
|
|
+ return "success";
|
|
|
+ }
|
|
|
+}
|