Authored by Gino Zhang

增加手工添加suggest_conversion的接口

... ... @@ -16,4 +16,6 @@ public interface SuggestConversionMapper {
List<SuggestConversion> selectAll();
void insertBatch(List<SuggestConversion> list);
void updateByPrimaryKey(SuggestConversion suggestConversion);
}
\ No newline at end of file
... ...
... ... @@ -43,4 +43,11 @@
#{item.updateTime, jdbcType=INTEGER})
</foreach>
</insert>
<update id="updateByPrimaryKey" parameterType="com.yoho.search.dal.model.SuggestConversion" timeout="20000">
update suggest_conversion
set dest = #{dest,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -40,4 +40,8 @@ public class SuggestConversionService {
public void insertBatch(List<SuggestConversion> list) {
suggestConversionMapper.insertBatch(list);
}
public void updateByPrimaryKey(SuggestConversion suggestConversion){
suggestConversionMapper.updateByPrimaryKey(suggestConversion);
}
}
... ...
... ... @@ -85,6 +85,23 @@ public class BaikeSpiderController {
}
}
@RequestMapping(value = "/spider/conversion/update")
@ResponseBody
public Map<String, Object> updateConversion(@RequestParam String source, @RequestParam String dest) {
Map<String, Object> result = new HashMap();
try {
suggestConvertorService.insertOrUpdateConversion(source, dest);
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/explain")
@ResponseBody
public Map<String, Object> explain(@RequestParam String keyword) {
... ...
... ... @@ -52,6 +52,21 @@ public class SuggestConvertorService {
@Autowired
private IYohoIndexService indexService;
public void insertOrUpdateConversion(String source, String dest){
SuggestConversion suggestConversion = suggestConversionService.selectBySource(source);
if(suggestConversion == null){
suggestConversion = new SuggestConversion();
suggestConversion.setSource(source);
suggestConversion.setDest(dest);
suggestConversionService.insertBatch(Arrays.asList(suggestConversion));
}
else{
suggestConversion.setDest(dest);
suggestConversion.setUpdateTime(DateUtil.getCurrentTimeSecond());
suggestConversionService.updateByPrimaryKey(suggestConversion);
}
}
public YohoKeywordsBO buildYohoKeywordBO() {
Set<String> keywordSet = new HashSet<>(3000);
Set<String> filterSortNameSet = new HashSet<>(300);
... ...