会议app接口
This commit is contained in:
1 parent
db6c35328f
commit
aaa69111d0
1 file changed
+56
-3
+56
-3
@@ -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<Page<MeetingBookingEntity>> myBookings(@ParameterObject Page page, @RequestParam(value = "checkStatus", required = false) String checkStatus) {
|
||||
Long userId = SecurityUtils.getUser().getId();
|
||||
LambdaQueryWrapper<MeetingBookingEntity> wrapper = Wrappers.<MeetingBookingEntity>lambdaQuery()
|
||||
.eq(MeetingBookingEntity::getApplicantId, userId);
|
||||
if (checkStatus != null && !checkStatus.isEmpty()) {
|
||||
wrapper.eq(MeetingBookingEntity::getCheckStatus, checkStatus);
|
||||
}
|
||||
wrapper.orderByDesc(MeetingBookingEntity::getBookingDate)
|
||||
.orderByDesc(MeetingBookingEntity::getStartTime);
|
||||
Page<MeetingBookingEntity> result = meetingBookingService.page(page, wrapper);
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消预约
|
||||
*/
|
||||
@PostMapping("/app/cancel-booking/{bookingId}")
|
||||
public R<Boolean> 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<MeetingBookingEntity> 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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user