feat: 实现设备管理员修改预约结束时间接口
This commit is contained in:
parent
1b2753c9a3
commit
ec9a40be88
@ -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<String, String> body) {
|
||||
LocalDate endTime = LocalDate.parse(body.get("endTime"));
|
||||
reservationService.updateEndTime(reservationId, endTime);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
}
|
||||
|
@ -22,4 +22,6 @@ public interface ReservationService {
|
||||
List<ReservationStatsVO> getReservationStats(LocalDate start, LocalDate end);
|
||||
|
||||
List<DeviceDetailStatsVO> getDeviceDetailStats(Long deviceId, LocalDate start, LocalDate end);
|
||||
|
||||
void updateEndTime(Long reservationId, LocalDate endTime);
|
||||
}
|
||||
|
@ -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<Reservation>()
|
||||
.eq(Reservation::getId, reservationId)
|
||||
.set(Reservation::getEndTime, endTime));
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -5,7 +5,7 @@
|
||||
<mapper namespace="github.benjamin.equipreservebackend.mapper.ApprovalMapper">
|
||||
|
||||
<select id="getApproval" resultType="github.benjamin.equipreservebackend.vo.LeaderApprovalVO">
|
||||
SELECT a.id as approvalId, r.applicant_name, r.applicant_team, r.applicant_contact, d.name as deviceName, r.start_time, r.end_time, a.decision, r.status
|
||||
SELECT r.id as reservation_id, a.id as approval_id, r.applicant_name, r.applicant_team, r.applicant_contact, d.name as deviceName, r.start_time, r.end_time, a.decision, r.status
|
||||
FROM approvals a
|
||||
LEFT JOIN reservations r ON a.reservation_id = r.id
|
||||
LEFT JOIN devices d ON r.device_id = d.id
|
||||
|
Loading…
x
Reference in New Issue
Block a user