Sfoglia il codice sorgente

作者:张哲
时间:2023/04/07
类型:优化
描述:里程碑(3) 增加关键字上报接口

zizg 1 anno fa
parent
commit
044f7e2c92

+ 8 - 0
src/main/java/com/redxun/knowledge/controller/CommonController.java

@@ -87,4 +87,12 @@ public class CommonController extends BaseController<CommonEntity> {
         return jsonResult.setData("");
     }
 
+    @ApiOperation("搜索关键字上报")
+    @PostMapping("searchKeywordTrack")
+    public JsonResult searchKeywordTrack(@RequestBody String keyword){
+        JsonResult jsonResult = JsonResult.getSuccessResult("");
+        systemService.searchKeywordTrack(keyword);
+        return jsonResult.setData("");
+    }
+
 }

+ 16 - 2
src/main/java/com/redxun/knowledge/service/CommonServiceImpl.java

@@ -19,6 +19,7 @@ import com.redxun.knowledge.entity.dao.CommonEntity;
 import com.redxun.knowledge.entity.vo.DicVo;
 import com.redxun.knowledge.entity.vo.PositionSequenceVo;
 import com.redxun.knowledge.mapper.CommonMapper;
+import com.redxun.search.service.impl.SearchServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -47,6 +48,9 @@ public class CommonServiceImpl extends SuperServiceImpl<CommonMapper, CommonEnti
     @Autowired
     private PvLogMapper pvLogMapper;
 
+    @Autowired
+    private SearchServiceImpl searchService;
+
     @Resource
     @Lazy
     SystemClient systemClient;
@@ -111,8 +115,9 @@ public class CommonServiceImpl extends SuperServiceImpl<CommonMapper, CommonEnti
     public void pageTrack(SystemLogDto systemLogDto) {
         IUser users = ContextUtil.getCurrentUser();
         PvLog pvLog = new PvLog();
-        //地图详情补充字段处理
-        if (("知识地图").equals(systemLogDto.getModule()) && ("详情").equals(systemLogDto.getSubModule())){
+        //专辑详情&地图详情补充字段处理
+        if (("知识专辑").equals(systemLogDto.getModule()) && ("详情").equals(systemLogDto.getSubModule()) ||
+                ("知识地图").equals(systemLogDto.getModule()) && ("详情").equals(systemLogDto.getSubModule())){
             String ussd = systemLogDto.getUssd();
             KnowledgeTypeParse knowledgeTypeParse = JSON.parseObject(ussd, KnowledgeTypeParse.class);
             String id = knowledgeTypeParse.getId();
@@ -130,4 +135,13 @@ public class CommonServiceImpl extends SuperServiceImpl<CommonMapper, CommonEnti
         pvLog.setUpdateTime(new Date());
         pvLogMapper.insert(pvLog);
     }
+
+    /**
+     * 搜索关键字上报
+     * @param keyword
+     */
+    public void searchKeywordTrack(String keyword) {
+        IUser users = ContextUtil.getCurrentUser();
+        searchService.keywordParticiple(keyword,users);
+    }
 }

+ 1 - 7
src/main/java/com/redxun/search/service/impl/SearchServiceImpl.java

@@ -52,9 +52,6 @@ public class SearchServiceImpl implements SearchService {
     @Autowired
     private SearchParticipleLogMapper searchParticipleLogMapper;
 
-    @Autowired
-    private ThreadPoolExecutor threadPoolExecutor;
-
     @SneakyThrows
     @Override
     public Map<String,Object> search(String keyword, Integer pageIndex, Integer pageSize,
@@ -81,9 +78,6 @@ public class SearchServiceImpl implements SearchService {
         headerMap.put("businessKey", httpServletRequest.getHeader("businessKey"));
         String userId = userService.queryLoginUser();
         headerMap.put("userId",userId);
-        //获取关键字存入分词表中(用于统计高频搜索词)
-        IUser users = ContextUtil.getCurrentUser();
-        CompletableFuture.runAsync(() -> keywordParticiple(keyword,users),threadPoolExecutor);
         //发送搜索请求
         JSONObject respone = HttpRequestHelper.sendRequest(headerMap,paramMap,searchUrl+"/api-kmsearch/search/search");
         if(null != respone && 200 == respone.getIntValue("code")) {
@@ -268,7 +262,7 @@ public class SearchServiceImpl implements SearchService {
         return result;
     }
 
-    private void keywordParticiple(String keyword, IUser users){
+    public void keywordParticiple(String keyword, IUser users){
         try {
             Map<String, Object> headerMap = new HashMap<>();
             Map<String, Object> paramMap = new HashMap<>();