Browse Source

count 查询,返回结果展示count,不展示total

lvxianyun 3 năm trước cách đây
mục cha
commit
c3aad04c9b

+ 9 - 4
src/main/java/com/persagy/proxy/adm/request/AdmResponse.java

@@ -27,6 +27,7 @@ public class AdmResponse {
     private String message;
     /** 符合条件的总记录数 */
     private Long total;
+    private Long count;
     /** 页码 */
     private Integer pageNumber;
     /** 每页条数 */
@@ -35,15 +36,15 @@ public class AdmResponse {
     private List<?> content;
 
     public static AdmResponse success() {
-        return new AdmResponse(SUCCESS, " ", 0L, 1, 500, null);
+        return new AdmResponse(SUCCESS, "", 0L,null, 1, 500, null);
     }
 
     public static AdmResponse failure(String message) {
-        return new AdmResponse(FAILURE, message, null, null, null, null);
+        return new AdmResponse(FAILURE, message, null, null, null, null, null);
     }
 
     public static AdmResponse success(List<?> content) {
-        return new AdmResponse(SUCCESS, " ", CollUtil.isEmpty(content) ? 0L :content.size()*1L, 1, 500, content);
+        return new AdmResponse(SUCCESS, "", CollUtil.isEmpty(content) ? 0L :content.size()*1L,null, 1, 500, content);
     }
 
     /**
@@ -63,6 +64,10 @@ public class AdmResponse {
         Long total = dmpResult.getCount() == null ? null : dmpResult.getCount().longValue();
         Integer pageNo = admRequest == null ? null : admRequest.getPageNumber();
         Integer pageSize = admRequest == null ? null : admRequest.getPageSize();
-        return new AdmResponse(SUCCESS, null, total, pageNo, pageSize, admVOs);
+        if(admRequest.isOnlyCount()){
+            return new AdmResponse(SUCCESS, null, null,total, pageNo, pageSize, admVOs);
+        }else {
+            return new AdmResponse(SUCCESS, null, total,null, pageNo, pageSize, admVOs);
+        }
     }
 }

+ 6 - 1
src/main/java/com/persagy/proxy/adm/service/impl/AbstractAdmBaseServiceImpl.java

@@ -72,7 +72,12 @@ public class AbstractAdmBaseServiceImpl<T> implements IAdmBaseService<T> {
         // 设置返回值
         AdmResponse response = AdmResponse.success(admVOs);
         Long total = dmpResult.getCount() == null ? null : dmpResult.getCount().longValue();
-        response.setTotal(total);
+        if(request.isOnlyCount()){
+            response.setTotal(null);
+            response.setCount(total);
+        }else {
+            response.setTotal(total);
+        }
         response.setPageNumber(request.getPageNumber());
         response.setPageSize(request.getPageSize());
         return response;