Skip to content

Commit 62b50ca

Browse files
committed
- valid: ConfirmDepartureTimeDto 추가 및 validation 추가
1 parent 01ae08b commit 62b50ca

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { IsDate } from "class-validator";
2+
import { Transform } from "class-transformer";
3+
import { parseSeoulDate } from "@src/global/utils/convert-date";
4+
5+
export class ConfirmDepartureTimeDto {
6+
@IsDate()
7+
@Transform(({ value }) => parseSeoulDate(value))
8+
departure_time: Date;
9+
}

src/pot/pot.controller.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
PotEventListResDto,
2121
} from "@src/pot/dto/pot.event.dto";
2222
import { PotOverviewDto } from "@src/pot/dto/pot.overview.dto";
23+
import { ConfirmDepartureTimeDto } from "@src/pot/dto/confirm-departure-time.pot.dto";
2324

2425
@Controller("/api/v1/pot")
2526
export class PotController {
@@ -98,9 +99,9 @@ export class PotController {
9899
@UseGuards(UserGuard)
99100
async confirmDepartureTime(
100101
@Param("potPk") potPk: string,
101-
@Body("departure_time") departureTime: Date,
102+
@Body() req: ConfirmDepartureTimeDto,
102103
@GetUser() userCtx: UserContext,
103104
): Promise<BaseResultDto> {
104-
return this.potService.confirmDepartureTime(potPk, departureTime, userCtx);
105+
return this.potService.confirmDepartureTime(potPk, req, userCtx);
105106
}
106107
}

src/pot/pot.service.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import { AccountingResultDto } from "@src/accounting/dto/confirm-accounting.dto"
4949
import { toDateFormatWithTimezone } from "@src/global/utils/convert-date";
5050
import { ko } from "date-fns/locale";
5151
import { formatInTimeZone } from "date-fns-tz";
52+
import { ConfirmDepartureTimeDto } from "@src/pot/dto/confirm-departure-time.pot.dto";
5253

5354
@Injectable()
5455
export class PotService {
@@ -593,7 +594,7 @@ export class PotService {
593594
*/
594595
async confirmDepartureTime(
595596
potPk: string,
596-
departureTime: Date,
597+
req: ConfirmDepartureTimeDto,
597598
userCtx: UserContext,
598599
): Promise<BaseResultDto> {
599600
const pot = await this.getPot(potPk);
@@ -608,7 +609,7 @@ export class PotService {
608609
{
609610
potRoomPk: potPk,
610611
userPk: userCtx.userId,
611-
departureTime: departureTime,
612+
departureTime: req.departure_time,
612613
},
613614
);
614615

@@ -673,22 +674,22 @@ export class PotService {
673674
);
674675

675676
// 출발 확정을 20분 안으로 했을 경우 바로 발송
676-
if (subMinutes(departureTime, 20) < new Date()) {
677+
if (subMinutes(req.departure_time, 20) < new Date()) {
677678
this.popoService.asyncSendPopoChatMsgToPotRoom(
678679
taxiCallPopoChatMsg,
679680
null,
680681
pot,
681682
{
682683
remainDepartureTime: Math.floor(
683-
(departureTime.getTime() - new Date().getTime()) / 60000,
684+
(req.departure_time.getTime() - new Date().getTime()) / 60000,
684685
),
685686
},
686687
);
687688
} else {
688689
// departureTime 시간 20분 전 taxi call reminder 메세지 발송 예약
689690
this.popoService.asyncReservePopoChatMsg(
690691
taxiCallPopoChatMsg,
691-
subMinutes(departureTime, 20),
692+
subMinutes(req.departure_time, 20),
692693
null,
693694
pot,
694695
{
@@ -704,7 +705,7 @@ export class PotService {
704705
// departureTime 시간 2시간 후 accounting reminder 메세지 발송 예약
705706
this.popoService.asyncReservePopoChatMsg(
706707
accountingPopoChatMsg,
707-
addHours(departureTime, 2),
708+
addHours(req.departure_time, 2),
708709
null,
709710
pot,
710711
);

0 commit comments

Comments
 (0)