Authored by 胡古飞

fix searchLike page bug

@@ -71,13 +71,13 @@ public class SearchLikeInShopServiceImpl implements ISearchLikeInShopService { @@ -71,13 +71,13 @@ public class SearchLikeInShopServiceImpl implements ISearchLikeInShopService {
71 if (productInfoInEs == null) { 71 if (productInfoInEs == null) {
72 return new SearchApiResult().setCode(400).setMessage("SKN不存在"); 72 return new SearchApiResult().setCode(400).setMessage("SKN不存在");
73 } 73 }
74 - // 3、检测分页参数  
75 - int pageSize = StringUtils.isBlank(paramMap.get("viewNum")) ? 60 : Integer.parseInt(paramMap.get("viewNum")); 74 + // 3、检测分页参数[默认展示10条,最多展示60条]
  75 + int pageSize = StringUtils.isBlank(paramMap.get("viewNum")) ? 10 : Integer.parseInt(paramMap.get("viewNum"));
76 int page = StringUtils.isBlank(paramMap.get("page")) ? 1 : Integer.parseInt(paramMap.get("page")); 76 int page = StringUtils.isBlank(paramMap.get("page")) ? 1 : Integer.parseInt(paramMap.get("page"));
77 if (page < 1 || pageSize < 0) { 77 if (page < 1 || pageSize < 0) {
78 return new SearchApiResult().setCode(400).setMessage("分页参数不合法"); 78 return new SearchApiResult().setCode(400).setMessage("分页参数不合法");
79 } 79 }
80 - if (pageSize > 60 || pageSize < 10) { 80 + if (pageSize > 60 || pageSize <= 0) {
81 pageSize = 60; 81 pageSize = 60;
82 } 82 }
83 83
@@ -72,13 +72,13 @@ public class SearchLikeServiceImpl implements ISearchLikeService { @@ -72,13 +72,13 @@ public class SearchLikeServiceImpl implements ISearchLikeService {
72 if (productInfoInEs == null) { 72 if (productInfoInEs == null) {
73 return new SearchApiResult().setCode(400).setMessage("SKN不存在"); 73 return new SearchApiResult().setCode(400).setMessage("SKN不存在");
74 } 74 }
75 - // 3、检测分页参数  
76 - int pageSize = StringUtils.isBlank(paramMap.get("viewNum")) ? 60 : Integer.parseInt(paramMap.get("viewNum")); 75 + // 3、检测分页参数【默认30条,最多60条】
  76 + int pageSize = StringUtils.isBlank(paramMap.get("viewNum")) ? 30 : Integer.parseInt(paramMap.get("viewNum"));
77 int page = StringUtils.isBlank(paramMap.get("page")) ? 1 : Integer.parseInt(paramMap.get("page")); 77 int page = StringUtils.isBlank(paramMap.get("page")) ? 1 : Integer.parseInt(paramMap.get("page"));
78 if (page < 1 || pageSize < 0) { 78 if (page < 1 || pageSize < 0) {
79 return new SearchApiResult().setCode(400).setMessage("分页参数不合法"); 79 return new SearchApiResult().setCode(400).setMessage("分页参数不合法");
80 } 80 }
81 - if (pageSize > 60 || pageSize < 10) { 81 + if (pageSize > 60 || pageSize <= 0) {
82 pageSize = 60; 82 pageSize = 60;
83 } 83 }
84 84
@@ -164,6 +164,9 @@ public class SearchLikeServiceImpl implements ISearchLikeService { @@ -164,6 +164,9 @@ public class SearchLikeServiceImpl implements ISearchLikeService {
164 * @return 164 * @return
165 */ 165 */
166 private JSONArray getProductListNotInBrand(JSONObject productInfoInEs, Map<String, String> paramMap, List<String> notInProductSkns, int limit) { 166 private JSONArray getProductListNotInBrand(JSONObject productInfoInEs, Map<String, String> paramMap, List<String> notInProductSkns, int limit) {
  167 + if(limit<=0){
  168 + return new JSONArray();
  169 + }
167 SearchParam searchParam = new SearchParam(); 170 SearchParam searchParam = new SearchParam();
168 // 1、构建Query 171 // 1、构建Query
169 QueryBuilder queryBuilder = this.genQueryBuilder(productInfoInEs, paramMap, false); 172 QueryBuilder queryBuilder = this.genQueryBuilder(productInfoInEs, paramMap, false);