bugfix: 修复查询预约时没有设备导致查询预约sql拼接错误的问题

This commit is contained in:
BenjaminNH 2025-07-22 10:25:37 +08:00
parent ec9a40be88
commit 999c399dd8
2 changed files with 8 additions and 0 deletions

View File

@ -129,6 +129,9 @@ public class ReservationServiceImpl implements ReservationService {
List<Device> devices = deviceMapper.selectList(new LambdaQueryWrapper<Device>() List<Device> devices = deviceMapper.selectList(new LambdaQueryWrapper<Device>()
.eq(Device::getTeamId, user.getTeamId()) .eq(Device::getTeamId, user.getTeamId())
.select()); .select());
if (devices.isEmpty()) {
return (Page<ReservationVO>) PageUtil.EMPTY_PAGE;
}
List<Role> userRole = roleMapper.selectRoleByUserId(userId); List<Role> userRole = roleMapper.selectRoleByUserId(userId);
ReservationStatus status; ReservationStatus status;
if (userRole.stream().anyMatch(r -> r.getCode().equals("LEADER"))) { if (userRole.stream().anyMatch(r -> r.getCode().equals("LEADER"))) {

View File

@ -2,8 +2,13 @@ package github.benjamin.equipreservebackend.utils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.Collections;
public class PageUtil { public class PageUtil {
public static final Page<?> EMPTY_PAGE = new Page<>(1, 10, 0)
.setRecords(Collections.emptyList());
public static <T> Page<T> copyPage(Page<?> page) { public static <T> Page<T> copyPage(Page<?> page) {
return new Page<T>(page.getCurrent(), page.getSize(), page.getTotal(), page.searchCount()); return new Page<T>(page.getCurrent(), page.getSize(), page.getTotal(), page.searchCount());
} }