Authored by wangnan

pi返回店铺名和domain

... ... @@ -970,6 +970,14 @@
"forbiddenPageIds": {
"type": "string",
"analyzer": "comma_spliter"
},
"shopName": {
"type": "string",
"analyzer": "ik_complex"
},
"shopDomain": {
"type": "string",
"analyzer": "not_analyzed"
}
}
}
... ...
package com.yoho.search.consumer.service.bo;
import com.alibaba.fastjson.JSONArray;
import java.io.Serializable;
import java.math.BigDecimal;
import com.alibaba.fastjson.JSONArray;
/**
* 商品实体索引
*
... ... @@ -107,6 +107,11 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
//from erp_product.product_attribute yh_shops.product_attribute_property_values
private String attributeNames;
//from shops
private String shopName;
private String shopDomain;
// get
public BigDecimal getSpecialPrice() {
return specialPrice;
... ... @@ -493,4 +498,19 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
this.attributeNames = attributeNames;
}
public String getShopName() {
return shopName;
}
public void setShopName(String shopName) {
this.shopName = shopName;
}
public String getShopDomain() {
return shopDomain;
}
public void setShopDomain(String shopDomain) {
this.shopDomain = shopDomain;
}
}
\ No newline at end of file
... ...
package com.yoho.search.consumer.service.logic.productIndex.viewBuilder;
import com.yoho.search.consumer.service.bo.ProductIndexBO;
import com.yoho.search.dal.ShopMapper;
import com.yoho.search.dal.model.Shops;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Created by wangnan on 2017/3/23.
*/
@Component
public class ShopBuilder implements ViewBuilder {
private final Logger logger = LoggerFactory.getLogger(ShopBuilder.class);
@Autowired
private ShopMapper shopMapper;
@Override
public void build(List<ProductIndexBO> productIndexBOs, List<Integer> ids, List<Integer> skns) {
List<Shops> shopsList = shopMapper.getPageLists(0, Integer.MAX_VALUE);
if (CollectionUtils.isEmpty(shopsList)) {
logger.warn("[class=GeneralDataBuilder][func=buildDataFromProductI] shopsList is empty");
return;
}
Map<Integer, Shops> shopMap = new HashMap<>();
shopsList.stream().collect(Collectors.toList()).forEach(shops -> shopMap.put(shops.getShopsId(), shops));
for (ProductIndexBO productIndexBO : productIndexBOs) {
Shops shops = shopMap.get(productIndexBO.getShopId());
if (shops != null) {
productIndexBO.setShopName(shops.getShopName());
productIndexBO.setShopDomain(shops.getShopDomain());
}
}
}
}
... ...