Skip to content

Commit 789ea63

Browse files
committed
fix reservation check logic
1 parent 6acdcf5 commit 789ea63

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/popo/reservation/place/reserve.place.controller.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class ReservePlaceController {
4848
) {
4949
const user = req.user as JwtPayload;
5050

51-
return this.reservePlaceService.checkReservationPossible(dto, user.uuid);
51+
return this.reservePlaceService.checkReservationPossible(dto, user.uuid, false);
5252
}
5353

5454
@Post()
@@ -57,7 +57,7 @@ export class ReservePlaceController {
5757
const user = req.user as JwtPayload;
5858
const existPlace = await this.placeService.findOneByUuidOrFail(dto.place_id);
5959

60-
await this.reservePlaceService.checkReservationPossible(dto, user.uuid);
60+
await this.reservePlaceService.checkReservationPossible(dto, user.uuid, false);
6161

6262
const new_reservation = await this.reservePlaceService.save(
6363
Object.assign(dto, { booker_id: user.uuid }),
@@ -215,6 +215,7 @@ export class ReservePlaceController {
215215
end_time: reservation.end_time,
216216
},
217217
reservation.booker_id,
218+
true,
218219
)
219220
const response = await this.reservePlaceService.updateStatus(
220221
reservation.uuid,
@@ -254,6 +255,7 @@ export class ReservePlaceController {
254255
end_time: reservation.end_time,
255256
},
256257
reservation.booker_id,
258+
true
257259
)
258260
}
259261

src/popo/reservation/place/reserve.place.service.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export class ReservePlaceService {
119119
return true;
120120
}
121121

122-
async checkReservationPossible(dto: DeepPartial<CreateReservePlaceDto>, booker_id: string) {
122+
async checkReservationPossible(dto: DeepPartial<CreateReservePlaceDto>, booker_id: string, isPatch: boolean = true) {
123123
const { place_id, date, start_time, end_time } = dto;
124124

125125
if (
@@ -179,12 +179,13 @@ export class ReservePlaceService {
179179
)
180180
}
181181

182+
182183
const reservationsOfDay = await this.reservePlaceRepo.find({
183184
where: {
184185
booker_id: booker_id,
185186
place_id: place_id,
186187
date: date,
187-
status: In([ReservationStatus.accept, ReservationStatus.in_process]),
188+
status: In(isPatch ? [ReservationStatus.accept] : [ReservationStatus.accept, ReservationStatus.in_process]),
188189
},
189190
});
190191

0 commit comments

Comments
 (0)