Authored by hugufei

添加trycatch

... ... @@ -9,6 +9,8 @@ import com.yoho.search.common.SearchDynamicConfigService;
import com.yoho.search.common.SearchRequestParams;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -25,27 +27,32 @@ public class GoodsCoverHelper {
@Autowired
private SearchDynamicConfigService searchDynamicConfigService;
private static final Logger logger = LoggerFactory.getLogger(GoodsCoverHelper.class);
public void pickImgOnColor(List<Map<String, Object>> productReturnInfoList, Map paramMap){
List<String> values = ConvertUtils.stringToStringList(MapUtils.getString(paramMap, SearchRequestParams.PARAM_SEARCH_COLOR), ",");
if(values==null || values.isEmpty()){
return;
}
for (Map<String, Object> productInfo : productReturnInfoList) {
List<JSONObject> goodsList = JSON.parseObject(JSON.toJSONString(productInfo.get("goods_list")), new TypeReference<List<JSONObject>>() {});
for (JSONObject good : goodsList) {
String colorId = good.getString("color_id");
String imagesUrl = good.getString("images_url");
if (StringUtils.isNotBlank(colorId) && StringUtils.isNotBlank(imagesUrl) && values.contains(colorId)) {
productInfo.put("default_images", imagesUrl);
productInfo.put("cover_1", "");
productInfo.put("cover_2", "");
break;
try {
List<JSONObject> goodsList = JSON.parseObject(JSON.toJSONString(productInfo.get("goods_list")), new TypeReference<List<JSONObject>>() {});
for (JSONObject good : goodsList) {
String colorId = good.getString("color_id");
String imagesUrl = good.getString("images_url");
if (StringUtils.isNotBlank(colorId) && StringUtils.isNotBlank(imagesUrl) && values.contains(colorId)) {
productInfo.put("default_images", imagesUrl);
productInfo.put("cover_1", "");
productInfo.put("cover_2", "");
break;
}
}
}
//测试环境zk配置改为false以不返回goods,刚上线默认还是要返回,等6.7上线后彻底删除
if (!searchDynamicConfigService.productListReturnGoods()) {
productInfo.put("goods_list", new JSONArray());
//测试环境zk配置改为false以不返回goods,刚上线默认还是要返回,等6.7上线后彻底删除
if (!searchDynamicConfigService.productListReturnGoods()) {
productInfo.put("goods_list", new JSONArray());
}
}catch (Exception e){
logger.error(e.getMessage(),e);
}
}
}
... ...