LAPTOP-3T9ND0SJ\ieven il y a 3 ans
Parent
commit
2e2dc47e96

+ 8 - 2
src/main/java/ieven/server/webapp/domain/file/FileService.java

@@ -39,6 +39,7 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.stream.Collectors;
@@ -138,8 +139,7 @@ public class FileService {
 
     public Mapped listUploaded(FileListInput fileListInput) {
         String modelId = fileListInput.getModelId();
-        //查询总量
-        long total = mongoTemplate.count(new Query(), LogicalFile.class);
+        Future<Long> longFuture = countTotalByModelId(modelId);
         int page = fileListInput.getPage();
         int pageSize = fileListInput.getPageSize();
         int skip = (page - 1) * pageSize;
@@ -147,6 +147,12 @@ public class FileService {
         List<LogicalFile> resultList = mongoTemplate.find(
                 query.skip(skip).limit(pageSize),
                 LogicalFile.class);
+        Long total = null;
+        try {
+            total = longFuture.get();
+        } catch (InterruptedException | ExecutionException e) {
+            return Mapped.ERROR("查询出错");
+        }
         Mapped res = Mapped.OK();
         res.put("code", 200);
         res.put("result", resultList);