From f65c4fd26dbc7e24cf11247330020b6e638034d4 Mon Sep 17 00:00:00 2001 From: leGit-y Date: Wed, 20 Dec 2023 10:28:44 +0900 Subject: [PATCH] =?UTF-8?q?[FIX]=20=EA=B3=A0=EB=AF=BC=EC=83=9D=EC=84=B1=20?= =?UTF-8?q?response=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;