From 999c399dd84f06b69070c9e8762b67f44f030bb4 Mon Sep 17 00:00:00 2001 From: BenjaminNH <1249376374@qq.com> Date: Tue, 22 Jul 2025 10:25:37 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:=20=E4=BF=AE=E5=A4=8D=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E9=A2=84=E7=BA=A6=E6=97=B6=E6=B2=A1=E6=9C=89=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E6=9F=A5=E8=AF=A2=E9=A2=84=E7=BA=A6sql?= =?UTF-8?q?=E6=8B=BC=E6=8E=A5=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ReservationServiceImpl.java | 3 +++ .../github/benjamin/equipreservebackend/utils/PageUtil.java | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/main/java/github/benjamin/equipreservebackend/service/impl/ReservationServiceImpl.java b/src/main/java/github/benjamin/equipreservebackend/service/impl/ReservationServiceImpl.java index f14bdbf..9ecbd4d 100644 --- a/src/main/java/github/benjamin/equipreservebackend/service/impl/ReservationServiceImpl.java +++ b/src/main/java/github/benjamin/equipreservebackend/service/impl/ReservationServiceImpl.java @@ -129,6 +129,9 @@ public class ReservationServiceImpl implements ReservationService { List devices = deviceMapper.selectList(new LambdaQueryWrapper() .eq(Device::getTeamId, user.getTeamId()) .select()); + if (devices.isEmpty()) { + return (Page) PageUtil.EMPTY_PAGE; + } List userRole = roleMapper.selectRoleByUserId(userId); ReservationStatus status; if (userRole.stream().anyMatch(r -> r.getCode().equals("LEADER"))) { diff --git a/src/main/java/github/benjamin/equipreservebackend/utils/PageUtil.java b/src/main/java/github/benjamin/equipreservebackend/utils/PageUtil.java index e24be83..3dab72e 100644 --- a/src/main/java/github/benjamin/equipreservebackend/utils/PageUtil.java +++ b/src/main/java/github/benjamin/equipreservebackend/utils/PageUtil.java @@ -2,8 +2,13 @@ package github.benjamin.equipreservebackend.utils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import java.util.Collections; + public class PageUtil { + public static final Page EMPTY_PAGE = new Page<>(1, 10, 0) + .setRecords(Collections.emptyList()); + public static Page copyPage(Page page) { return new Page(page.getCurrent(), page.getSize(), page.getTotal(), page.searchCount()); }