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()); }