From ec9a40be8803f3c6a10b8677028be7b104f7baba Mon Sep 17 00:00:00 2001 From: BenjaminNH <1249376374@qq.com> Date: Mon, 21 Jul 2025 21:24:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=9E=E7=8E=B0=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E4=BF=AE=E6=94=B9=E9=A2=84=E7=BA=A6?= =?UTF-8?q?=E7=BB=93=E6=9D=9F=E6=97=B6=E9=97=B4=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ReservationController.java | 11 +++++++++-- .../service/ReservationService.java | 2 ++ .../service/impl/ReservationServiceImpl.java | 8 ++++++++ .../equipreservebackend/vo/LeaderApprovalVO.java | 2 ++ src/main/resources/mapper/ApprovalMapper.xml | 2 +- 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/main/java/github/benjamin/equipreservebackend/controller/ReservationController.java b/src/main/java/github/benjamin/equipreservebackend/controller/ReservationController.java index 4669875..dbdf9fe 100644 --- a/src/main/java/github/benjamin/equipreservebackend/controller/ReservationController.java +++ b/src/main/java/github/benjamin/equipreservebackend/controller/ReservationController.java @@ -2,11 +2,9 @@ package github.benjamin.equipreservebackend.controller; import com.alibaba.excel.EasyExcel; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import github.benjamin.equipreservebackend.constant.ReservationStatus; import github.benjamin.equipreservebackend.entity.Reservation; import github.benjamin.equipreservebackend.response.ResponseResult; import github.benjamin.equipreservebackend.service.ReservationService; -import github.benjamin.equipreservebackend.vo.DeviceStatsVO; import github.benjamin.equipreservebackend.vo.ReservationStatsVO; import github.benjamin.equipreservebackend.vo.ReservationVO; import github.benjamin.equipreservebackend.vo.UserReservationVO; @@ -22,6 +20,7 @@ import java.nio.charset.StandardCharsets; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.List; +import java.util.Map; @RestController @RequestMapping("/reservation") @@ -83,4 +82,12 @@ public class ReservationController { .doWrite(data); } + @PreAuthorize("hasRole('DEVICE_ADMIN')") + @PostMapping("/endTime/{reservationId}") + public ResponseResult updateEndTime(@PathVariable Long reservationId, + @RequestBody Map body) { + LocalDate endTime = LocalDate.parse(body.get("endTime")); + reservationService.updateEndTime(reservationId, endTime); + return ResponseResult.success(); + } } diff --git a/src/main/java/github/benjamin/equipreservebackend/service/ReservationService.java b/src/main/java/github/benjamin/equipreservebackend/service/ReservationService.java index 280d3c6..0b00557 100644 --- a/src/main/java/github/benjamin/equipreservebackend/service/ReservationService.java +++ b/src/main/java/github/benjamin/equipreservebackend/service/ReservationService.java @@ -22,4 +22,6 @@ public interface ReservationService { List getReservationStats(LocalDate start, LocalDate end); List getDeviceDetailStats(Long deviceId, LocalDate start, LocalDate end); + + void updateEndTime(Long reservationId, LocalDate endTime); } 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 b4d0eba..f14bdbf 100644 --- a/src/main/java/github/benjamin/equipreservebackend/service/impl/ReservationServiceImpl.java +++ b/src/main/java/github/benjamin/equipreservebackend/service/impl/ReservationServiceImpl.java @@ -1,6 +1,7 @@ package github.benjamin.equipreservebackend.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import github.benjamin.equipreservebackend.constant.ReservationStatus; import github.benjamin.equipreservebackend.entity.Device; @@ -165,4 +166,11 @@ public class ReservationServiceImpl implements ReservationService { .le(Reservation::getEndTime, end) .orderByAsc(Reservation::getApplicantName, Reservation::getStartTime)).stream().map(DeviceDetailStatsVO::new).toList(); } + + @Override + public void updateEndTime(Long reservationId, LocalDate endTime) { + reservationMapper.update(new LambdaUpdateWrapper() + .eq(Reservation::getId, reservationId) + .set(Reservation::getEndTime, endTime)); + } } diff --git a/src/main/java/github/benjamin/equipreservebackend/vo/LeaderApprovalVO.java b/src/main/java/github/benjamin/equipreservebackend/vo/LeaderApprovalVO.java index 7a21892..9ab34af 100644 --- a/src/main/java/github/benjamin/equipreservebackend/vo/LeaderApprovalVO.java +++ b/src/main/java/github/benjamin/equipreservebackend/vo/LeaderApprovalVO.java @@ -9,6 +9,8 @@ import java.time.LocalDate; @Data public class LeaderApprovalVO { + @JsonSerialize(using = ToStringSerializer.class) + private Long reservationId; @JsonSerialize(using = ToStringSerializer.class) private Long approvalId; private String applicantName; diff --git a/src/main/resources/mapper/ApprovalMapper.xml b/src/main/resources/mapper/ApprovalMapper.xml index a919672..a77cde2 100644 --- a/src/main/resources/mapper/ApprovalMapper.xml +++ b/src/main/resources/mapper/ApprovalMapper.xml @@ -5,7 +5,7 @@