From e7f69cec99ca8536093e2b2373139416346dc084 Mon Sep 17 00:00:00 2001 From: leGit-y Date: Tue, 19 Dec 2023 21:45:11 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[FIX]=20updated=20=EB=90=9C=20worry?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EB=A6=AC=ED=84=B4=EA=B0=92=20=EA=B0=80?= =?UTF-8?q?=EC=A0=B8=EC=98=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/service/worryService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/service/worryService.ts b/src/service/worryService.ts index ed28724..78a7663 100644 --- a/src/service/worryService.ts +++ b/src/service/worryService.ts @@ -62,7 +62,7 @@ const patchWorry =async (worryUpdateDTO: worryUpdateDTO) => { } const data = { - updatedAt: moment(worry.updated_at).utc().utcOffset(9).format('YYYY-MM-DD'), + updatedAt: moment(updatedWorry.updated_at).utc().utcOffset(9).format('YYYY-MM-DD'), } return data; From f65c4fd26dbc7e24cf11247330020b6e638034d4 Mon Sep 17 00:00:00 2001 From: leGit-y Date: Wed, 20 Dec 2023 10:28:44 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[FIX]=20=EA=B3=A0=EB=AF=BC=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20response=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/service/worryService.ts | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/service/worryService.ts b/src/service/worryService.ts index 78a7663..4e54022 100644 --- a/src/service/worryService.ts +++ b/src/service/worryService.ts @@ -11,13 +11,13 @@ import moment from "moment"; const postWorry =async (worryCreateDTO: worryCreateDTO) => { const date = new Date(); // utc기준 현재시간 - const d_day = worryCreateDTO.deadline; + const deadline = worryCreateDTO.deadline; // const moment = require('moment'); // moment() = kst기준 현재시간 let deadlineDate; - if(d_day != -1){ - const deadline = moment().add(d_day, 'days').format('YYYY-MM-DD'); - deadlineDate = new Date(deadline); + if(deadline != -1){ + const today_plus_deadline = moment().add(deadline, 'days').format('YYYY-MM-DD'); + deadlineDate = new Date(today_plus_deadline); } else{ deadlineDate = null; @@ -34,13 +34,26 @@ const postWorry =async (worryCreateDTO: worryCreateDTO) => { if (!worry) { throw new ClientException(rm.CREATE_WORRY_FAIL); } - - const data = { + + const template = await templateRepository.findTemplateById(worry.template_id); + if (!template) { + throw new ClientException(rm.CREATE_WORRY_FAIL); + } + + const data:any = { + worryId: worry.id, + title: worry.title, + templateId: worry.template_id, + subtitles: template.subtitles, + answers: worry.answers, createdAt: moment(worry.created_at).utc().utcOffset(9).format('YYYY-MM-DD'), - deadline: "데드라인이 없습니다." + deadline: "데드라인이 없습니다.", + dDay: -888 } - if(worry.deadline != null) + if(worry.deadline != null){ data.deadline = worry.deadline.toISOString().substring(0,10) + data.dDay = deadline + } return data; From 469aff675ebb4c4a99bb4ab993abef9a19dc546d Mon Sep 17 00:00:00 2001 From: leGit-y Date: Wed, 20 Dec 2023 10:54:55 +0900 Subject: [PATCH 3/3] [REFACTOR] d-day -> dDay --- src/service/worryService.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/service/worryService.ts b/src/service/worryService.ts index 4e54022..2abf79d 100644 --- a/src/service/worryService.ts +++ b/src/service/worryService.ts @@ -134,7 +134,7 @@ const getWorryDetail =async (worryId: number,userId: number) => { "period": "아직 고민중인 글입니다.", "updatedAt": kst_updated_at, "deadline": "데드라인이 없습니다.", - "d-day": gap, + "dDay": gap, "finalAnswer": worry.final_answer, "review": null } @@ -233,7 +233,7 @@ const patchDeadline =async (deadlineUpdateDTO: deadlineUpdateDTO) => { const data = { "deadline": "데드라인이 없습니다.", - "d-day": gap, + "dDay": gap, } if(worry.deadline != null)