|
|
package com.yoho.search.consumer.index.fullbuild;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import com.yoho.search.consumer.index.common.IIndexBuilder;
|
|
|
import com.yoho.search.dal.ProductMapper;
|
|
|
import com.yoho.search.dal.model.Product;
|
|
|
|
|
|
@Component
|
|
|
public class ProductBaseIndexBuilder extends IIndexBuilder {
|
|
|
|
|
|
@Autowired
|
|
|
private ProductMapper productMapper;
|
|
|
|
|
|
@Override
|
|
|
public int getTotalCount() throws Exception {
|
|
|
return productMapper.selectCount();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<?> getPageLists(int offset, int limit) throws Exception {
|
|
|
List<Product> productList = productMapper.selectPageLists(offset, limit);
|
|
|
if (productList.isEmpty()) {
|
|
|
return new ArrayList<Map<String, Object>>();
|
|
|
}
|
|
|
List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>();
|
|
|
for (Product product : productList) {
|
|
|
dataList.add(this.getProductBaseMap(product));
|
|
|
}
|
|
|
return dataList;
|
|
|
}
|
|
|
|
|
|
private Map<String, Object> getProductBaseMap(Product product) {
|
|
|
Map<String, Object> productMap = new HashMap<String, Object>();
|
|
|
productMap.put("id", product.getId());
|
|
|
productMap.put("productSkn", product.getErpProductId());
|
|
|
productMap.put("productName", product.getProductName());
|
|
|
productMap.put("shopId", product.getShopId());
|
|
|
productMap.put("brandId", product.getBrandId());
|
|
|
productMap.put("maxSortId", product.getMaxSortId());
|
|
|
productMap.put("middleSortId", product.getMiddleSortId());
|
|
|
productMap.put("smallSortId", product.getSmallSortId());
|
|
|
productMap.put("phrase", product.getPhrase());
|
|
|
productMap.put("firstShelveTime", product.getFirstShelveTime());
|
|
|
return productMap;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public String getId(Object object) {
|
|
|
return ((Map<?, ?>) object).get("id").toString();
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|