diff --git a/pjcloud-integrated/pjcloud-integrated-biz/src/main/java/com/bsd/pjcloud/integrated/controller/MeetingRoomController.java b/pjcloud-integrated/pjcloud-integrated-biz/src/main/java/com/bsd/pjcloud/integrated/controller/MeetingRoomController.java index 73cdef2f7..bcb11ae78 100644 --- a/pjcloud-integrated/pjcloud-integrated-biz/src/main/java/com/bsd/pjcloud/integrated/controller/MeetingRoomController.java +++ b/pjcloud-integrated/pjcloud-integrated-biz/src/main/java/com/bsd/pjcloud/integrated/controller/MeetingRoomController.java @@ -281,9 +281,8 @@ public class MeetingRoomController { for (MeetingBookingEntity booking : existingBookings) { LocalTime bookingStart = booking.getStartTime(); LocalTime bookingEnd = booking.getEndTime(); - - // 修改判断逻辑:只要有任何重叠就表示冲突 - if (!(endTime.isBefore(bookingStart) || startTime.isAfter(bookingEnd))) { + // 只要不是完全无交集就算冲突 + if (!(endTime.compareTo(bookingStart) <= 0 || startTime.compareTo(bookingEnd) >= 0)) { return R.failed("该时间段已被预约"); } } @@ -304,4 +303,58 @@ public class MeetingRoomController { return R.ok(success); } + /** + * 我的预约 - 分页,支持checkStatus筛选 + * @param page 分页对象 + * @param checkStatus 审核状态(可选),传空查全部 + */ + @GetMapping("/app/my-bookings") + public R> myBookings(@ParameterObject Page page, @RequestParam(value = "checkStatus", required = false) String checkStatus) { + Long userId = SecurityUtils.getUser().getId(); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery() + .eq(MeetingBookingEntity::getApplicantId, userId); + if (checkStatus != null && !checkStatus.isEmpty()) { + wrapper.eq(MeetingBookingEntity::getCheckStatus, checkStatus); + } + wrapper.orderByDesc(MeetingBookingEntity::getBookingDate) + .orderByDesc(MeetingBookingEntity::getStartTime); + Page result = meetingBookingService.page(page, wrapper); + return R.ok(result); + } + + /** + * 取消预约 + */ + @PostMapping("/app/cancel-booking/{bookingId}") + public R cancelBooking(@PathVariable("bookingId") Long bookingId) { + Long userId = SecurityUtils.getUser().getId(); + MeetingBookingEntity booking = meetingBookingService.getById(bookingId); + if (booking == null) { + return R.failed("预约不存在"); + } + if (!Objects.equals(booking.getApplicantId(), userId)) { + return R.failed("无权取消他人预约"); + } + // 设置checkStatus为4(已取消) + booking.setCheckStatus("4"); + boolean updated = meetingBookingService.updateById(booking); + return R.ok(updated); + } + + /** + * 预约详情 + */ + @GetMapping("/app/booking-detail/{bookingId}") + public R bookingDetail(@PathVariable("bookingId") Long bookingId) { + Long userId = SecurityUtils.getUser().getId(); + MeetingBookingEntity booking = meetingBookingService.getById(bookingId); + if (booking == null) { + return R.failed("预约不存在"); + } + if (!Objects.equals(booking.getApplicantId(), userId)) { + return R.failed("无权查看他人预约详情"); + } + return R.ok(booking); + } + } \ No newline at end of file