Skip to content

Commit

Permalink
[HOTFIX] 최종결정 등록하기 안됨 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
leGit-y committed Oct 31, 2023
1 parent ff42b92 commit 51061f9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/service/worryService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ const getWorryDetail =async (worryId: number,userId: number) => {
}

const patchFinalAnswer =async (finalAnswerCreateDTO: finalAnswerCreateDTO) => {
const worry = await worryRepository.createFinalAnswer(finalAnswerCreateDTO);
const worry = await worryRepository.findWorryById(finalAnswerCreateDTO.worryId);

if (!worry) {
throw new ClientException(rm.MAKE_FINAL_ANSWER_FAIL);
throw new ClientException("해당 id의 고민글이 존재하지 않습니다.");
}

if (worry.user_id != finalAnswerCreateDTO.userId) {
throw new ClientException("고민글 작성자만 최종결정할 수 있습니다.");
}
Expand All @@ -159,6 +159,11 @@ const patchFinalAnswer =async (finalAnswerCreateDTO: finalAnswerCreateDTO) => {
throw new ClientException("한 번 내린 최종결정은 수정 불가합니다.");
}

const updatedWorry = await worryRepository.createFinalAnswer(finalAnswerCreateDTO);
if (!updatedWorry) {
throw new ClientException(rm.MAKE_FINAL_ANSWER_FAIL);
}

const quotes = await quoteRepository.findAllQuote();
const random_quote = quotes[calculate_random_num(quotes.length)].content

Expand Down

0 comments on commit 51061f9

Please sign in to comment.