...
|
...
|
@@ -8,7 +8,9 @@ import java.util.stream.Collectors; |
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.yohoufo.common.utils.UfoStringUtils;
|
|
|
import com.yohoufo.dal.product.ProductMapper;
|
|
|
import com.yohoufo.dal.product.ProductSortMapper;
|
|
|
import com.yohoufo.dal.product.model.Product;
|
|
|
import com.yohoufo.dal.product.model.ProductSort;
|
|
|
import com.yohoufo.product.helper.SearchParam;
|
|
|
import com.yohoufo.product.model.FilterItem;
|
...
|
...
|
@@ -16,6 +18,7 @@ import com.yohoufo.product.request.ProductSearchReq; |
|
|
import com.yohoufo.product.request.SortIdLevel;
|
|
|
import com.yohoufo.product.response.SearchBrandListResp;
|
|
|
import com.yohoufo.product.response.SearchProductListFilterResp;
|
|
|
import com.yohoufo.product.response.SearchProductRecommendResp;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
...
|
...
|
@@ -43,6 +46,9 @@ public class ProductSearchServiceImpl implements ProductSearchService { |
|
|
@Autowired
|
|
|
private ProductSortMapper productSortMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private ProductMapper productMapper;
|
|
|
|
|
|
|
|
|
public static final String PRODUCT_LIST_URL = "/yohosearch/ufo/productList.json";
|
|
|
|
...
|
...
|
@@ -198,6 +204,22 @@ public class ProductSearchServiceImpl implements ProductSearchService { |
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public SearchProductRecommendResp searchProductRecommendById(Integer productId) {
|
|
|
SearchProductRecommendResp resp = new SearchProductRecommendResp();
|
|
|
Product product = productMapper.selectByPrimaryKey(productId);
|
|
|
if (product != null) {
|
|
|
ProductSearchReq req = new ProductSearchReq().setNot_id(productId + "").setMidSort(product.getMidSortId() + "").setBrand(product.getBrandId() + "").setQuery(product.getProductName());
|
|
|
SearchParam searchParam = new SearchParam().buildSearchParam(req);
|
|
|
|
|
|
JSONObject data = search(searchParam.getParam(), PRODUCT_RECOMMEND_LIST_URL);
|
|
|
if(data != null && !CollectionUtils.isEmpty(data.getJSONArray("product_list"))) {
|
|
|
resp = JSON.toJavaObject(data, SearchProductRecommendResp.class);
|
|
|
}
|
|
|
}
|
|
|
return resp;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public SortIdLevel getSortLevelById(String sortId) {
|
|
|
SortIdLevel sortIdLevel = new SortIdLevel();
|
|
|
if (StringUtils.isNotBlank(sortId)) {
|
...
|
...
|
|