Browse Source

代码优化

wanghn 5 months ago
parent
commit
d3b9a3dda9
1 changed files with 10 additions and 3 deletions
  1. 10 3
      src/main/java/com/diagbot/facade/BehospitalInfoFacade.java

+ 10 - 3
src/main/java/com/diagbot/facade/BehospitalInfoFacade.java

@@ -2100,6 +2100,14 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
         List<BehospitalInfoDeptDTO> records = res.getRecords();
         List<BehospitalInfoDeptDTO> resRecords = new ArrayList<>();
 
+        //非空判断
+        if(res.getTotal() == 0){
+            IPage<BehospitalInfoDeptDTO> emptyPage = new Page<>(1, 15); // 页码为1,每页10条记录
+            emptyPage.setRecords(new ArrayList<>()); // 设置记录为空列表
+            emptyPage.setTotal(0); // 设置总记录数为0
+            return emptyPage;
+        }
+
         // 收集所有唯一的病历号
         List<String> behospitalCodes = records.stream()
                 .map(BehospitalInfoDeptDTO::getBehospitalCode)
@@ -2124,11 +2132,10 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
             }
         }
 
-        IPage<BehospitalInfoDeptDTO> resultPage = new Page<>(res.getCurrent(), res.getSize(), res.getTotal());
+        IPage<BehospitalInfoDeptDTO> resultPage = new Page<>(res.getCurrent(), resRecords.size(), resRecords.size());
         // 设置记录
         resultPage.setRecords(resRecords);
-        resultPage.setTotal(resRecords.size());
-        resultPage.setSize(resRecords.size());
+
         return resultPage;
     }