|
|
package com.yoho.search.restapi.tools;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yoho.search.base.utils.CollectionUtils;
|
|
|
import com.yoho.search.base.utils.Transfer;
|
|
|
import com.yoho.search.base.utils.DateUtil;
|
|
|
import com.yoho.search.base.utils.SearchPageIdDefine;
|
|
|
import com.yoho.search.base.utils.*;
|
|
|
import com.yoho.search.common.utils.HttpServletRequestUtils;
|
|
|
import com.yoho.search.common.utils.SearchKeyWordUtils;
|
|
|
import com.yoho.search.core.es.model.SearchParam;
|
|
|
import com.yoho.search.core.es.model.SearchResult;
|
|
|
import com.yoho.search.models.SearchApiResult;
|
|
|
import com.yoho.search.recall.beans.builder.UserRecallRequestBuilder;
|
|
|
import com.yoho.search.recall.beans.cache.SknReturnInfoCacheBean;
|
...
|
...
|
@@ -15,9 +14,12 @@ import com.yoho.search.recall.beans.strategy.StrategyEnum; |
|
|
import com.yoho.search.recall.models.common.RecallSknInfo;
|
|
|
import com.yoho.search.recall.models.req.UserRecallRequest;
|
|
|
import com.yoho.search.recall.models.req.UserRecallResponse;
|
|
|
import com.yoho.search.service.base.SearchCommonService;
|
|
|
import com.yoho.search.service.base.SearchRequestParams;
|
|
|
import org.apache.commons.collections.MapUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
|
|
import org.elasticsearch.index.query.QueryBuilders;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
...
|
...
|
@@ -41,6 +43,8 @@ public class RecallResultController { |
|
|
private UserRecallCacheBean userRecallCacheBean;
|
|
|
@Autowired
|
|
|
private SknReturnInfoCacheBean sknReturnInfoCacheBean;
|
|
|
@Autowired
|
|
|
private SearchCommonService searchCommonService;
|
|
|
|
|
|
private List<String> supportPageIdList = Arrays.asList(SearchPageIdDefine.PAGE_ID_SORT, SearchPageIdDefine.PAGE_ID_NEW, SearchPageIdDefine.PAGE_ID_ZQ, SearchPageIdDefine.PAGE_ID_POOL);
|
|
|
|
...
|
...
|
@@ -76,6 +80,24 @@ public class RecallResultController { |
|
|
return recallProductList(paramMap);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(method = RequestMethod.GET, value = "/querySknInfo")
|
|
|
public SearchApiResult querySknInfo(HttpServletRequest request) {
|
|
|
Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
|
|
|
if (StringUtils.isBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_PRODUCT_SKN))) {
|
|
|
return new SearchApiResult().setCode(400).setMessage("缺少skn");
|
|
|
}
|
|
|
SearchParam searchParam = new SearchParam();
|
|
|
BoolQueryBuilder boolFilter = QueryBuilders.boolQuery();
|
|
|
boolFilter.filter(QueryBuilders.termQuery(ProductIndexEsField.productSkn, paramMap.get(SearchRequestParams.PARAM_SEARCH_PRODUCT_SKN)));
|
|
|
searchParam.setFiter(boolFilter);
|
|
|
searchParam.setSize(1);
|
|
|
searchParam.setQuery(QueryBuilders.matchAllQuery());
|
|
|
SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_PRODUCT_INDEX, searchParam);
|
|
|
if (searchResult != null && searchResult.getResultList() != null && !searchResult.getResultList().isEmpty()) {
|
|
|
return new SearchApiResult().setData(searchResult.getResultList().get(0));
|
|
|
}
|
|
|
return new SearchApiResult().setData(null);
|
|
|
}
|
|
|
|
|
|
private boolean checkSortParam(Map<String, String> paramMap) {
|
|
|
if (StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_MAXSORT))) {
|
...
|
...
|
|