Quellcode durchsuchen

search改版的调整

hulh vor 8 Jahren
Ursprung
Commit
2d2f405941

+ 46 - 46
src/main/java/com/uas/platform/b2c/common/search/service/impl/SearcherServiceImpl.java

@@ -1,17 +1,19 @@
 package com.uas.platform.b2c.common.search.service.impl;
 
 import com.alibaba.fastjson.JSONObject;
+import com.uas.platform.b2c.common.search.service.SearcherService;
+import com.uas.platform.b2c.core.utils.FastjsonUtils;
 import com.uas.platform.b2c.prod.product.component.dao.ComponentGoodsDao;
 import com.uas.platform.b2c.prod.product.component.dao.ComponentInfoDao;
 import com.uas.platform.b2c.prod.product.component.modal.ComponentGoods;
 import com.uas.platform.b2c.prod.product.component.modal.ComponentInfo;
-import com.uas.platform.b2c.common.search.service.SearcherService;
-import com.uas.platform.b2c.core.utils.FastjsonUtils;
 import com.uas.platform.core.exception.SystemException;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.PageParams;
 import com.uas.search.exception.SearchException;
+import com.uas.search.model.CollectField;
 import com.uas.search.model.PageParams.FilterField;
+import com.uas.search.model.SPage;
 import com.uas.search.model.Sort;
 import com.uas.search.service.SearchService;
 import org.slf4j.Logger;
@@ -26,11 +28,9 @@ import java.io.IOException;
 import java.util.*;
 import java.util.Map.Entry;
 
-import com.uas.search.model.CollectField;
-
 /**
  * 搜索索引
- * 
+ *
  * @author sunyj
  * @since 2016年7月8日 下午5:14:44
  */
@@ -50,7 +50,7 @@ public class SearcherServiceImpl implements SearcherService {
 
 	/**
 	 * 智能搜索类目
-	 * 
+	 *
 	 * @param keyword
 	 * @param field
 	 * @return
@@ -60,20 +60,20 @@ public class SearcherServiceImpl implements SearcherService {
 	@Override
 	public ModelMap searchKind(String keyword, String field) {
 		ModelMap map = new ModelMap();
-		List<Map<String, Object>> kinds = new ArrayList<>();
+		SPage<Map<String, Object>> kinds = null;
 		try {
-			kinds = searchService.getKinds(keyword);
+			kinds = searchService.getKinds(keyword,1,1024*1024*1024);
 		} catch (SearchException e) {
 			throwSystemException(e);
 		}
-		map.put("total", kinds.size());// 结果总数
-		map.put("kinds", kinds);
+		map.put("total", kinds.getTotalElement());// 结果总数
+		map.put("kinds", kinds.getContent());
 		return map;
 	}
 
 	/**
 	 * 智能搜索品牌
-	 * 
+	 *
 	 * @param keyword
 	 * @param field
 	 * @return
@@ -83,20 +83,20 @@ public class SearcherServiceImpl implements SearcherService {
 	@Override
 	public ModelMap searchBrand(String keyword, String field) {
 		ModelMap map = new ModelMap();
-		List<Map<String, Object>> brands = new ArrayList<>();
+		SPage<Map<String, Object>> brands = null;
 		try {
-			brands = searchService.getBrands(keyword);
+			brands = searchService.getBrands(keyword,1,1024*1024*1024);
 		} catch (SearchException e) {
 			throwSystemException(e);
 		}
-		map.put("brands", brands);// 结果集
-		map.put("total", brands.size());// 结果总数
+		map.put("brands", brands.getContent());// 结果集
+		map.put("total", brands.getTotalElement());// 结果总数
 		return map;
 	}
 
 	/**
 	 * 智能搜索器件
-	 * 
+	 *
 	 * @param keyword
 	 * @return
 	 * @throws InterruptedException
@@ -179,35 +179,35 @@ public class SearcherServiceImpl implements SearcherService {
 
 		return map;
 	}
-    /**
-     * 批次搜索数量统计
-     *
-     * @param keyword
-     * @param page
-     * @return
-     * @throws InterruptedException
-     * @throws IOException
-     */
-    @SuppressWarnings("unchecked")
-    @Override
-    public ModelMap searchComponentGoodsNums(String keyword, PageParams page) {
-        ModelMap map = new ModelMap();
-        Map<String, Object> results = null;
-        //Map<String, Object> results = new HashMap<>();
-        try {
-            results = searchService.getGoodsIds(keyword, convertPageParams(page));
-        } catch (SearchException e) {
-            throwSystemException(e);
-        }
-        map.put("total", results.get("total"));// 搜索结果总数
-        return map;
-    }
+	/**
+	 * 批次搜索数量统计
+	 *
+	 * @param keyword
+	 * @param page
+	 * @return
+	 * @throws InterruptedException
+	 * @throws IOException
+	 */
+	@SuppressWarnings("unchecked")
+	@Override
+	public ModelMap searchComponentGoodsNums(String keyword, PageParams page) {
+		ModelMap map = new ModelMap();
+		Map<String, Object> results = null;
+		//Map<String, Object> results = new HashMap<>();
+		try {
+			results = searchService.getGoodsIds(keyword, convertPageParams(page));
+		} catch (SearchException e) {
+			throwSystemException(e);
+		}
+		map.put("total", results.get("total"));// 搜索结果总数
+		return map;
+	}
 
 
 
 	/**
 	 * 获取器件搜索的类目统计
-	 * 
+	 *
 	 * @param keyword
 	 * @return
 	 */
@@ -224,7 +224,7 @@ public class SearcherServiceImpl implements SearcherService {
 
 	/**
 	 * 获取器件搜索的品牌统计列表
-	 * 
+	 *
 	 * @param keyword
 	 * @return
 	 */
@@ -253,7 +253,7 @@ public class SearcherServiceImpl implements SearcherService {
 		for (Entry<String, Object> entry : paramEntry) {
 			param.put(FilterField.valueOf(entry.getKey().toUpperCase()), entry.getValue());
 		}
- 		try {
+		try {
 			collectResult = searchService.collectBySearchGoods(keyword, CollectField.valueOf(collectList.toUpperCase()),param);
 		} catch (SearchException e) {
 			throwSystemException(e);
@@ -270,8 +270,8 @@ public class SearcherServiceImpl implements SearcherService {
 			throwSystemException(e);
 		}
 		if (result.size() > 8) {
-            result = result.subList(0,8);
-        }
+			result = result.subList(0,8);
+		}
 		return result;
 	}
 
@@ -288,7 +288,7 @@ public class SearcherServiceImpl implements SearcherService {
 
 	/**
 	 * 把平台中PageParams对象转化为搜索API封装的PageParams对象
-	 * 
+	 *
 	 * @param params
 	 * @return
 	 */
@@ -351,7 +351,7 @@ public class SearcherServiceImpl implements SearcherService {
 
 	/**
 	 * 捕获SearchException抛出SystemException
-	 * 
+	 *
 	 * @param e
 	 * @return
 	 */