|
@@ -10,10 +10,12 @@ import com.aliyun.opensearch.sdk.generated.search.SearchParams;
|
|
|
import com.caimei365.commodity.components.PriceUtilService;
|
|
|
import com.caimei365.commodity.components.RedisService;
|
|
|
import com.caimei365.commodity.components.SearchOpenService;
|
|
|
+import com.caimei365.commodity.mapper.CmPraiseStatisticsMapper;
|
|
|
import com.caimei365.commodity.mapper.PageMapper;
|
|
|
import com.caimei365.commodity.mapper.SearchFrequencyMapper;
|
|
|
import com.caimei365.commodity.mapper.SearchMapper;
|
|
|
import com.caimei365.commodity.model.ResponseJson;
|
|
|
+import com.caimei365.commodity.model.po.CmPraiseStatistics;
|
|
|
import com.caimei365.commodity.model.po.SearchHistoryPo;
|
|
|
import com.caimei365.commodity.model.search.ProductListVo;
|
|
|
import com.caimei365.commodity.model.vo.HotSearchVo;
|
|
@@ -26,7 +28,6 @@ import com.caimei365.commodity.utils.Json2PojoUtil;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -59,9 +60,10 @@ public class SearchProductServiceImpl implements SearchProductService {
|
|
|
@Resource
|
|
|
private SearchFrequencyMapper searchFrequencyMapper;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private RedisService redisService;
|
|
|
-
|
|
|
+ @Resource
|
|
|
+ private CmPraiseStatisticsMapper cmPraiseStatisticsMapper;
|
|
|
/**
|
|
|
* 根据关键词搜索商品
|
|
|
*
|
|
@@ -616,25 +618,31 @@ public class SearchProductServiceImpl implements SearchProductService {
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public ResponseJson conKeyword(Integer fromType, String path, String keyword) {
|
|
|
- Date date = new Date();
|
|
|
- SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- sf.format(date);
|
|
|
+ public ResponseJson conKeyword(String keyword) {
|
|
|
+ // Date date = new Date();
|
|
|
+ // SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ // sf.format(date);
|
|
|
//根据关键词和来源查询数据库是否存在(存在来源也相同时增加次数,存在但来源不同时和不存在则新增)
|
|
|
- List<SearchFrequencyVo> searchFrequencyVoList = searchFrequencyMapper.getInfoBykeyword(keyword, fromType);
|
|
|
+ List<SearchFrequencyVo> searchFrequencyVoList = searchFrequencyMapper.getInfoBykeyword(keyword);
|
|
|
if (null != searchFrequencyVoList && searchFrequencyVoList.size() > 0) {
|
|
|
//存在 统计次数
|
|
|
+ cmPraiseStatisticsMapper.addCmPraiseStatistics(new CmPraiseStatistics()
|
|
|
+ .setType("6")
|
|
|
+ .setAuthorId(String.valueOf(searchFrequencyVoList.get(0).getId()))
|
|
|
+ .setPv(1)
|
|
|
+ );
|
|
|
Integer frequency = searchFrequencyVoList.get(0).getFrequency() + 1;
|
|
|
searchFrequencyMapper.upFrequencyById(searchFrequencyVoList.get(0).getId(), frequency);
|
|
|
- } else {
|
|
|
- //不存在 新增
|
|
|
- SearchFrequencyVo sea = new SearchFrequencyVo();
|
|
|
- sea.setKeyword(keyword);
|
|
|
- sea.setFrequency(1);
|
|
|
- sea.setFromSearch(fromType);
|
|
|
- sea.setSearchTime(new java.sql.Date(date.getTime()));
|
|
|
- searchFrequencyMapper.saveInfo(sea);
|
|
|
}
|
|
|
+ // } else {
|
|
|
+ // //不存在 新增
|
|
|
+ // SearchFrequencyVo sea = new SearchFrequencyVo();
|
|
|
+ // sea.setKeyword(keyword);
|
|
|
+ // sea.setFrequency(1);
|
|
|
+ // sea.setFromSearch(fromType);
|
|
|
+ // sea.setSearchTime(new java.sql.Date(date.getTime()));
|
|
|
+ // searchFrequencyMapper.saveInfo(sea);
|
|
|
+ // }
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
|