|
|
package com.yoho.search.spider.controller;
|
|
|
|
|
|
import com.yoho.search.spider.conversation.SuggestConvertorService;
|
|
|
import com.yoho.search.spider.job.SpiderJob;
|
|
|
import com.yoho.search.spider.full.BaikeURLSpiderService;
|
|
|
import com.yoho.search.spider.increment.BlackKeywordsMgr;
|
|
|
import com.yoho.search.spider.increment.IncrementCrawlerService;
|
|
|
import com.yoho.search.spider.job.SpiderJob;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
...
|
...
|
@@ -31,6 +32,9 @@ public class BaikeSpiderController { |
|
|
@Autowired
|
|
|
private BlackKeywordsMgr blackKeywordsMgr;
|
|
|
|
|
|
@Autowired
|
|
|
private IncrementCrawlerService incrementCrawlerService;
|
|
|
|
|
|
@RequestMapping(value = "/spider/baike")
|
|
|
@ResponseBody
|
|
|
public Map<String, Object> baikeSpider() {
|
...
|
...
|
@@ -41,13 +45,13 @@ public class BaikeSpiderController { |
|
|
return result;
|
|
|
} catch (Exception e) {
|
|
|
Map<String, Object> result = new HashMap();
|
|
|
result.put("code", 503);
|
|
|
result.put("code", 500);
|
|
|
result.put("message", e.getMessage());
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/spider/crawerEmptyKeywords")
|
|
|
@RequestMapping(value = "/spider/crawlerEmptyKeywords")
|
|
|
@ResponseBody
|
|
|
public Map<String, Object> crawerEmptyKeywords() {
|
|
|
Map<String, Object> result = new HashMap();
|
...
|
...
|
@@ -58,7 +62,7 @@ public class BaikeSpiderController { |
|
|
result.put("message", "success");
|
|
|
return result;
|
|
|
} catch (Exception e) {
|
|
|
result.put("code", 503);
|
|
|
result.put("code", 500);
|
|
|
result.put("message", e.getMessage());
|
|
|
return result;
|
|
|
}
|
...
|
...
|
@@ -75,7 +79,7 @@ public class BaikeSpiderController { |
|
|
result.put("message", "success");
|
|
|
return result;
|
|
|
} catch (Exception e) {
|
|
|
result.put("code", 503);
|
|
|
result.put("code", 500);
|
|
|
result.put("message", e.getMessage());
|
|
|
return result;
|
|
|
}
|
...
|
...
|
@@ -93,7 +97,7 @@ public class BaikeSpiderController { |
|
|
result.put("message", "success");
|
|
|
return result;
|
|
|
} catch (Exception e) {
|
|
|
result.put("code", 503);
|
|
|
result.put("code", 500);
|
|
|
result.put("message", e.getMessage());
|
|
|
return result;
|
|
|
}
|
...
|
...
|
@@ -110,7 +114,78 @@ public class BaikeSpiderController { |
|
|
result.put("message", "success");
|
|
|
return result;
|
|
|
} catch (Exception e) {
|
|
|
result.put("code", 503);
|
|
|
result.put("code", 500);
|
|
|
result.put("message", e.getMessage());
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/spider/single/crawle")
|
|
|
@ResponseBody
|
|
|
public Map<String, Object> singleCrawle(@RequestParam String keyword) {
|
|
|
Map<String, Object> result = new HashMap();
|
|
|
|
|
|
try {
|
|
|
result.put("result", incrementCrawlerService.crawleKeyword(keyword));
|
|
|
result.put("code", 200);
|
|
|
result.put("message", "success");
|
|
|
return result;
|
|
|
} catch (Exception e) {
|
|
|
result.put("code", 500);
|
|
|
result.put("message", e.getMessage());
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/spider/single/convertor")
|
|
|
@ResponseBody
|
|
|
public Map<String, Object> singleConvertor(@RequestParam String keyword) {
|
|
|
Map<String, Object> result = new HashMap();
|
|
|
|
|
|
try {
|
|
|
result.put("result", suggestConvertorService.convertSingleKeyword(keyword));
|
|
|
result.put("code", 200);
|
|
|
result.put("message", "success");
|
|
|
return result;
|
|
|
} catch (Exception e) {
|
|
|
result.put("code", 500);
|
|
|
result.put("message", e.getMessage());
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/spider/single/updateES")
|
|
|
@ResponseBody
|
|
|
public Map<String, Object> singleUpdateES(@RequestParam String keyword) {
|
|
|
Map<String, Object> result = new HashMap();
|
|
|
|
|
|
try {
|
|
|
result.put("result", suggestConvertorService.addOrUpdateIndex(keyword));
|
|
|
result.put("code", 200);
|
|
|
result.put("message", "success");
|
|
|
return result;
|
|
|
} catch (Exception e) {
|
|
|
result.put("code", 500);
|
|
|
result.put("message", e.getMessage());
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/spider/single/increment")
|
|
|
@ResponseBody
|
|
|
public Map<String, Object> singleIncrement(@RequestParam String keyword) {
|
|
|
Map<String, Object> result = new HashMap();
|
|
|
|
|
|
try {
|
|
|
boolean incmentResult = incrementCrawlerService.crawleKeyword(keyword)
|
|
|
&& suggestConvertorService.convertSingleKeyword(keyword)
|
|
|
&& suggestConvertorService.addOrUpdateIndex(keyword);
|
|
|
result.put("result", incmentResult);
|
|
|
result.put("code", 200);
|
|
|
result.put("message", "success");
|
|
|
return result;
|
|
|
} catch (Exception e) {
|
|
|
result.put("code", 500);
|
|
|
result.put("message", e.getMessage());
|
|
|
return result;
|
|
|
}
|
...
|
...
|
|