فهرست منبع

fix: 已登录无法通过公司名搜索问题处理

dongbw 7 سال پیش
والد
کامیت
fb1a52a1b4

+ 13 - 0
src/main/java/com/uas/ps/inquiry/page/PageInfo.java

@@ -20,6 +20,19 @@ import java.util.*;
 public class PageInfo implements Pageable {
 
 	public PageInfo() {
+        // 不传入页面大小,默认页面大小为5
+        if (this.pageSize == 0) {
+            this.pageSize = 5;
+        }
+        // 页面大小最大不可超过1000,防止服务器崩溃
+        if (this.pageSize > 1000) {
+            throw new IllegalOperatorException("页面大小不可超过1000");
+        }
+        if (this.pageNumber == 0) {
+            // 不传入页码,默认为第一页
+            this.pageNumber = 1;
+        }
+        this.offset = this.pageSize * (this.pageNumber - 1);
 	}
 
 	/**

+ 10 - 5
src/main/java/com/uas/ps/inquiry/service/impl/PublicInquiryServiceImpl.java

@@ -1335,10 +1335,7 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
      * @param filter  过滤条件
      */
     private void setFilter(PageInfo info, SearchFilter filter) {
-        Sort sort = new Sort(Sort.Direction.DESC, "id", "date");
-        if (info.getOffset() == 0) {
-            info.setOffset(info.getPageSize() * (info.getPageNumber() - 1));
-        }
+        Sort sort = new Sort(Sort.Direction.DESC, "id");
         info.setSort(sort);
         if (filter.getFromDate() != null) {
             info.expression(PredicateUtils.gte("date", new Date(filter.getFromDate()), false));
@@ -1356,7 +1353,15 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
             SimpleExpression cmpCode = new SimpleExpression("cmpCode", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
             SimpleExpression brand = new SimpleExpression("inbrand", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
             SimpleExpression title = new SimpleExpression("prodTitle", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
-            SimpleExpression[] simpleExpressions = new SimpleExpression[]{cmpCode, brand, title};
+            SimpleExpression spec = new SimpleExpression("spec", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
+//            SimpleExpression code = new SimpleExpression("inquiry.code", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
+            SimpleExpression enName = new SimpleExpression("inquiry.enName", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
+            SimpleExpression[] simpleExpressions = null;
+            if (!StringUtils.isEmpty(filter.getIsLogin()) && filter.getIsLogin() == 1) {
+                simpleExpressions = new SimpleExpression[]{cmpCode, brand, title, enName, spec};
+            } else {
+                simpleExpressions = new SimpleExpression[]{cmpCode, brand, title, spec};
+            }
             LogicalExpression logical = new LogicalExpression(simpleExpressions, CriterionExpression.Operator.OR);
             info.expression(logical);
         }