Skip to content

Commit

Permalink
[FIX] 고민생성 response 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
leGit-y committed Dec 20, 2023
1 parent e7f69ce commit f65c4fd
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/service/worryService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down

0 comments on commit f65c4fd

Please sign in to comment.