Authored by hugufei

找相似保留偶数

... ... @@ -122,11 +122,7 @@ public class SearchLikeHelper {
}
productList.add(productListJSONArray.getJSONObject(i));
}
//4、保留偶数
if (productList.size() % 2 > 0) {
productList = CollectionUtils.safeSubList(productList, 0, productList.size() - 1);
}
//5、构造返回结果
//4、构造返回结果
data.put("page", 1);
data.put("page_size", viewNum);
data.put("total", productList.size());
... ...
... ... @@ -60,24 +60,24 @@ public class SearchLikeInShopService {
}
// 2、检测分页参数【默认30条】
int viewNum = 30;
// 3、获取当前查询的SKN的基本信息
JSONObject productInfoInEs = searchLikeHelper.getProductInfoInEs(productSkn);
if (productInfoInEs == null) {
return new SearchApiResult().setCode(400).setMessage("SKN不存在");
}
// 4、设置SearchParams
List<SearchParam> searchParams = new ArrayList<SearchParam>();
searchParams.add(this.builderSearchParam(productInfoInEs, Arrays.asList(productSkn), viewNum));
// 5、获取搜索结果[截取条数]
List<Map<String, Object>> tempProductList = searchLikeHelper.queryProductList(searchParams);
if (tempProductList.size() > viewNum) {
tempProductList = CollectionUtils.safeSubList(tempProductList,0, viewNum);
}
// 6、构造真实返回结果
//6、保留偶数
if (tempProductList.size() % 2 > 0) {
tempProductList = CollectionUtils.safeSubList(tempProductList, 0, tempProductList.size() - 1);
}
// 7、构造返回结果
List<Map<String, Object>> productListResults = new ArrayList<Map<String, Object>>();
if (!tempProductList.isEmpty()) {
productListResults = productListHelper.buildReturnInfoByEsSourceList(tempProductList);
... ...