增加手工添加suggest_conversion的接口
Showing
5 changed files
with
45 additions
and
0 deletions
@@ -16,4 +16,6 @@ public interface SuggestConversionMapper { | @@ -16,4 +16,6 @@ public interface SuggestConversionMapper { | ||
16 | List<SuggestConversion> selectAll(); | 16 | List<SuggestConversion> selectAll(); |
17 | 17 | ||
18 | void insertBatch(List<SuggestConversion> list); | 18 | void insertBatch(List<SuggestConversion> list); |
19 | + | ||
20 | + void updateByPrimaryKey(SuggestConversion suggestConversion); | ||
19 | } | 21 | } |
@@ -43,4 +43,11 @@ | @@ -43,4 +43,11 @@ | ||
43 | #{item.updateTime, jdbcType=INTEGER}) | 43 | #{item.updateTime, jdbcType=INTEGER}) |
44 | </foreach> | 44 | </foreach> |
45 | </insert> | 45 | </insert> |
46 | + | ||
47 | + <update id="updateByPrimaryKey" parameterType="com.yoho.search.dal.model.SuggestConversion" timeout="20000"> | ||
48 | + update suggest_conversion | ||
49 | + set dest = #{dest,jdbcType=VARCHAR}, | ||
50 | + update_time = #{updateTime,jdbcType=INTEGER} | ||
51 | + where id = #{id,jdbcType=INTEGER} | ||
52 | + </update> | ||
46 | </mapper> | 53 | </mapper> |
@@ -40,4 +40,8 @@ public class SuggestConversionService { | @@ -40,4 +40,8 @@ public class SuggestConversionService { | ||
40 | public void insertBatch(List<SuggestConversion> list) { | 40 | public void insertBatch(List<SuggestConversion> list) { |
41 | suggestConversionMapper.insertBatch(list); | 41 | suggestConversionMapper.insertBatch(list); |
42 | } | 42 | } |
43 | + | ||
44 | + public void updateByPrimaryKey(SuggestConversion suggestConversion){ | ||
45 | + suggestConversionMapper.updateByPrimaryKey(suggestConversion); | ||
46 | + } | ||
43 | } | 47 | } |
@@ -85,6 +85,23 @@ public class BaikeSpiderController { | @@ -85,6 +85,23 @@ public class BaikeSpiderController { | ||
85 | } | 85 | } |
86 | } | 86 | } |
87 | 87 | ||
88 | + @RequestMapping(value = "/spider/conversion/update") | ||
89 | + @ResponseBody | ||
90 | + public Map<String, Object> updateConversion(@RequestParam String source, @RequestParam String dest) { | ||
91 | + Map<String, Object> result = new HashMap(); | ||
92 | + | ||
93 | + try { | ||
94 | + suggestConvertorService.insertOrUpdateConversion(source, dest); | ||
95 | + result.put("code", 200); | ||
96 | + result.put("message", "success"); | ||
97 | + return result; | ||
98 | + } catch (Exception e) { | ||
99 | + result.put("code", 500); | ||
100 | + result.put("message", e.getMessage()); | ||
101 | + return result; | ||
102 | + } | ||
103 | + } | ||
104 | + | ||
88 | @RequestMapping(value = "/spider/explain") | 105 | @RequestMapping(value = "/spider/explain") |
89 | @ResponseBody | 106 | @ResponseBody |
90 | public Map<String, Object> explain(@RequestParam String keyword) { | 107 | public Map<String, Object> explain(@RequestParam String keyword) { |
@@ -52,6 +52,21 @@ public class SuggestConvertorService { | @@ -52,6 +52,21 @@ public class SuggestConvertorService { | ||
52 | @Autowired | 52 | @Autowired |
53 | private IYohoIndexService indexService; | 53 | private IYohoIndexService indexService; |
54 | 54 | ||
55 | + public void insertOrUpdateConversion(String source, String dest){ | ||
56 | + SuggestConversion suggestConversion = suggestConversionService.selectBySource(source); | ||
57 | + if(suggestConversion == null){ | ||
58 | + suggestConversion = new SuggestConversion(); | ||
59 | + suggestConversion.setSource(source); | ||
60 | + suggestConversion.setDest(dest); | ||
61 | + suggestConversionService.insertBatch(Arrays.asList(suggestConversion)); | ||
62 | + } | ||
63 | + else{ | ||
64 | + suggestConversion.setDest(dest); | ||
65 | + suggestConversion.setUpdateTime(DateUtil.getCurrentTimeSecond()); | ||
66 | + suggestConversionService.updateByPrimaryKey(suggestConversion); | ||
67 | + } | ||
68 | + } | ||
69 | + | ||
55 | public YohoKeywordsBO buildYohoKeywordBO() { | 70 | public YohoKeywordsBO buildYohoKeywordBO() { |
56 | Set<String> keywordSet = new HashSet<>(3000); | 71 | Set<String> keywordSet = new HashSet<>(3000); |
57 | Set<String> filterSortNameSet = new HashSet<>(300); | 72 | Set<String> filterSortNameSet = new HashSet<>(300); |
-
Please register or login to post a comment