Authored by mali

搜索通用接口

... ... @@ -411,4 +411,39 @@ public class ProductSearchController {
return new ApiResponse.ApiResponseBuilder().code(200).message("Product List.").data(resp).build();
}
@ApiOperation(name = "ufo.product.search.list", desc="首页商品推荐")
@RequestMapping(params = "method=ufo.product.search.common.list")
@IgnoreSession
@Cachable(expire = 180)
public ApiResponse searchCommonProductList(
@RequestParam(value = "order", required = false)String order,
@RequestParam(value = "product_id", required = false)String id,
@RequestParam(value = "not_product_id", required = false)String notId,
@RequestParam(value = "productPool", required = false) String productPool,
@RequestParam(value = "sort", required = false)String sort,
@RequestParam(value = "brand", required = false)String brand,
@RequestParam(value = "series", required = false)String series,
@RequestParam(value = "gender", required = false) String gender,
@RequestParam(value = "size", required = false) String size,
@RequestParam(value = "query", required = false)String query,
@RequestParam(value = "limit", required = false)Integer limit,
@RequestParam(value = "page", required = false)Integer page
) {
if (StringUtils.isNotBlank(productPool) && StringUtils.isBlank(query) && StringUtils.isBlank(order)) {
order = "pools.order_by:desc"; // 如果走商品池接口,默认走排序倒序接口
}
SortIdLevel sortIdLevel = productSearchService.getSortLevelById(sort);
ProductSearchReq req = new ProductSearchReq().setOrder(order).setId(id).setNot_id(notId).setPool(productPool).setBrand(brand)
.setSeries(series).setGender(gender).setSize(size).setViewNum(limit).setPage(page);
searchHelpService.setQuery(query, req);
if(StringUtils.isNotBlank(sort)) {
req.setMidSort(sortIdLevel.getMidSortId()).setMaxSort(sortIdLevel.getMaxSortId());
}
LOG.info("in method=ufo.product.search.common.list req={}", req.toString());
JSONObject resp = productSearchService.searchCommonProductList(req);
return new ApiResponse.ApiResponseBuilder().code(200).message("Product List.").data(resp).build();
}
}
\ No newline at end of file
... ...
... ... @@ -58,4 +58,6 @@ public interface ProductSearchService {
* @return
*/
SearchProductListFilterResp searchSecondhandSkupListFilter(ProductSearchReq req);
JSONObject searchCommonProductList(ProductSearchReq req);
}
... ...
... ... @@ -721,4 +721,21 @@ public class ProductSearchServiceImpl implements ProductSearchService {
}
return data;
}
@Override
public JSONObject searchCommonProductList(ProductSearchReq req) {
SearchParam searchParam = new SearchParam().buildPageSearchParam(req);
String url = null;
if (StringUtils.isNotBlank(req.getPool())) {
url = ProductSearchConstants.PRODUCT_POOL_URL;
} else {
url = ProductSearchConstants.PRODUCT_LIST_URL;
}
JSONObject data = searchAssistService.search(searchParam.getParam(), url);
if (null != data) {
searchAssistService.processProductList(data.getJSONArray("product_list"));
searchAssistService.setRecId(data);
}
return data;
}
}
... ...