Просмотр исходного кода

SearchService抛出自定义SearchException

sunyj 9 лет назад
Родитель
Сommit
123005a8f2

+ 27 - 0
search-api/src/main/java/com/uas/search/exception/SearchException.java

@@ -0,0 +1,27 @@
+package com.uas.search.exception;
+
+/**
+ * 搜索异常
+ * 
+ * @author sunyj
+ * @since 2016年9月30日 下午3:32:48
+ */
+public class SearchException extends RuntimeException {
+
+	private static final long serialVersionUID = 1L;
+
+	private String message;
+
+	public SearchException(String message) {
+		this.message = message;
+	}
+
+	public String getMessage() {
+		return message;
+	}
+
+	public void setMessage(String message) {
+		this.message = message;
+	}
+
+}

+ 34 - 17
search-api/src/main/java/com/uas/search/service/SearchService.java

@@ -4,6 +4,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import com.uas.search.exception.SearchException;
 import com.uas.search.model.PageParams;
 
 /**
@@ -20,16 +21,18 @@ public interface SearchService {
 	 * @param keyword
 	 *            关键词
 	 * @return 符合条件的类目id
+	 * @throws SearchException
 	 */
-	public List<Long> getKindIds(String keyword);
+	public List<Long> getKindIds(String keyword) throws SearchException;
 
 	/**
 	 * 根据关键词搜索产品类目
 	 * 
 	 * @param keyword
 	 * @return
+	 * @throws SearchException
 	 */
-	public List<Map<String, Object>> getKinds(String keyword);
+	public List<Map<String, Object>> getKinds(String keyword) throws SearchException;
 
 	/**
 	 * 根据关键词搜索产品品牌id
@@ -37,16 +40,18 @@ public interface SearchService {
 	 * @param keyword
 	 *            关键词
 	 * @return 符合条件的品牌id
+	 * @throws SearchException
 	 */
-	public List<Long> getBrandIds(String keyword);
+	public List<Long> getBrandIds(String keyword) throws SearchException;
 
 	/**
 	 * 根据关键词搜索产品品牌
 	 * 
 	 * @param keyword
 	 * @return
+	 * @throws SearchException
 	 */
-	public List<Map<String, Object>> getBrands(String keyword);
+	public List<Map<String, Object>> getBrands(String keyword) throws SearchException;
 
 	/**
 	 * 根据关键词搜索产品
@@ -55,8 +60,9 @@ public interface SearchService {
 	 * @param params
 	 *            (可选,默认第1页的20条)
 	 * @return
+	 * @throws SearchException
 	 */
-	public Map<String, Object> getComponentIds(String keyword, PageParams params);
+	public Map<String, Object> getComponentIds(String keyword, PageParams params) throws SearchException;
 
 	/**
 	 * 根据产品搜索获取产品类目id的统计
@@ -65,8 +71,9 @@ public interface SearchService {
 	 * @param brandId
 	 *            (可选)
 	 * @return
+	 * @throws SearchException
 	 */
-	public Set<Long> getKindIdsBySearchComponent(String keyword, String brandId);
+	public Set<Long> getKindIdsBySearchComponent(String keyword, String brandId) throws SearchException;
 
 	/**
 	 * 根据产品搜索获取产品类目的统计
@@ -75,8 +82,9 @@ public interface SearchService {
 	 * @param brandId
 	 *            (可选)
 	 * @return
+	 * @throws SearchException
 	 */
-	public List<Map<String, Object>> getKindsBySearchComponent(String keyword, String brandId);
+	public List<Map<String, Object>> getKindsBySearchComponent(String keyword, String brandId) throws SearchException;
 
 	/**
 	 * 根据产品搜索获取产品品牌id的统计
@@ -85,8 +93,9 @@ public interface SearchService {
 	 * @param kindId
 	 *            (可选)
 	 * @return
+	 * @throws SearchException
 	 */
-	public Set<Long> getBrandIdsBySearchComponent(String keyword, String kindId);
+	public Set<Long> getBrandIdsBySearchComponent(String keyword, String kindId) throws SearchException;
 
 	/**
 	 * 根据产品搜索获取产品品牌的统计
@@ -95,48 +104,54 @@ public interface SearchService {
 	 * @param kindId
 	 *            (可选)
 	 * @return
+	 * @throws SearchException
 	 */
-	public List<Map<String, Object>> getBrandsBySearchComponent(String keyword, String kindId);
+	public List<Map<String, Object>> getBrandsBySearchComponent(String keyword, String kindId) throws SearchException;
 
 	/**
 	 * 根据输入获取联想词(包括器件、类目、品牌,按顺序获取,数量不足,才会获取下一个)
 	 * 
 	 * @param keyword
 	 * @return
+	 * @throws SearchException
 	 */
-	public List<String> getSimilarKeywords(String keyword);
+	public List<String> getSimilarKeywords(String keyword) throws SearchException;
 
 	/**
 	 * 根据输入的原厂型号获取联想词
 	 * 
 	 * @param componentCode
 	 * @return 包括id、uuid、code
+	 * @throws SearchException
 	 */
-	public List<Map<String, Object>> getSimilarComponents(String componentCode);
+	public List<Map<String, Object>> getSimilarComponents(String componentCode) throws SearchException;
 
 	/**
 	 * 根据输入的品牌获取联想词
 	 * 
 	 * @param brandName
 	 * @return 包括id、uuid、nameCn、nameEn
+	 * @throws SearchException
 	 */
-	public List<Map<String, Object>> getSimilarBrands(String brandName);
+	public List<Map<String, Object>> getSimilarBrands(String brandName) throws SearchException;
 
 	/**
 	 * 根据输入的类目名获取联想词
 	 * 
 	 * @param kindName
 	 * @return 包括id、nameCn、level、isLeaf
+	 * @throws SearchException
 	 */
-	public List<Map<String, Object>> getSimilarKinds(String kindName);
+	public List<Map<String, Object>> getSimilarKinds(String kindName) throws SearchException;
 
 	/**
 	 * 根据输入的类目名获取末级类目联想词
 	 * 
 	 * @param kindName
 	 * @return 包括id、nameCn、level、isLeaf
+	 * @throws SearchException
 	 */
-	public List<Map<String, Object>> getSimilarLeafKinds(String kindName);
+	public List<Map<String, Object>> getSimilarLeafKinds(String kindName) throws SearchException;
 
 	/**
 	 * 根据输入的类目名和指定的类目级别获取联想词
@@ -144,8 +159,9 @@ public interface SearchService {
 	 * @param kindName
 	 * @param level
 	 * @return 包括id、nameCn、level、isLeaf
+	 * @throws SearchException
 	 */
-	public List<Map<String, Object>> getSimilarKindsByLevel(String kindName, Short level);
+	public List<Map<String, Object>> getSimilarKindsByLevel(String kindName, Short level) throws SearchException;
 
 	/**
 	 * 根据类目id、属性id、属性值获取联想词
@@ -159,8 +175,9 @@ public interface SearchService {
 	 * @param topNum
 	 *            (可选) 获取的最大数目
 	 * @return 相似的属性值,包括propertyValue
+	 * @throws SearchException
 	 */
-	public List<Map<String, String>> getSimilarPropertyValues(Long kindId, Long propertyId, String keyword,
-			Long topNum);
+	public List<Map<String, String>> getSimilarPropertyValues(Long kindId, Long propertyId, String keyword, Long topNum)
+			throws SearchException;
 
 }