Skip to content

Commit a159729

Browse files
authored
Merge pull request #143 from codeit-moving/release
Release -> Main 20250111 프론트 요청 반영
2 parents 3fd8389 + 4a38e6b commit a159729

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

src/repositorys/movingRequestRepository.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,16 @@ const getActiveRequest = (customerId: number) => {
326326
id: true,
327327
},
328328
},
329+
quote: {
330+
select: {
331+
mover: {
332+
select: {
333+
id: true,
334+
},
335+
},
336+
},
337+
},
338+
designateCount: true,
329339
},
330340
});
331341
};

src/services/movingRequestService.ts

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -423,33 +423,29 @@ const designateMover = async (moverId: number, customerId: number) => {
423423
return throwHttpError(422, "일반 견적 요청을 먼저 진행해 주세요.");
424424
}
425425

426-
const mover = await moverRepository.getMoverById(null, moverId);
427-
428-
if (!mover) {
429-
return throwHttpError(404, "기사를 찾을 수 없습니다.");
430-
}
431-
432-
//지정 가능 인원 조회
433-
const designateCountPromise = movingRequestRepository.getDesignateCount(
434-
activeRequest.id
426+
const isQuote = activeRequest.quote.some(
427+
(quote) => quote.mover.id === moverId
435428
);
436429

437-
const designatedMoversPromise = movingRequestRepository.getDesignatedMovers(
438-
activeRequest.id,
439-
moverId
430+
const isDesignated = activeRequest.mover.some(
431+
(mover) => mover.id === moverId
440432
);
441433

442-
const [result, designatedMovers] = await Promise.all([
443-
designateCountPromise,
444-
designatedMoversPromise,
445-
]);
446-
447-
if (designatedMovers) {
434+
if (isDesignated) {
448435
return throwHttpError(400, "이미 지정된 기사 입니다.");
449436
}
450437

438+
if (isQuote) {
439+
return throwHttpError(400, "받은 일반 견적이 있습니다.");
440+
}
441+
442+
const mover = await moverRepository.getMoverById(null, moverId);
443+
if (!mover) {
444+
return throwHttpError(404, "기사를 찾을 수 없습니다.");
445+
}
446+
451447
//지정 가능 인원 초과 체크
452-
if (!result || result._count.mover >= 3) {
448+
if (activeRequest.designateCount >= 3) {
453449
return throwHttpError(
454450
400,
455451
"지정 요청 가능한 인원이 초과되었습니다. (최대 3명)"

0 commit comments

Comments
 (0)