From 062a78a83967f17b29fa316025ecf8dae7f9d3ee Mon Sep 17 00:00:00 2001 From: richarjiang Date: Fri, 22 Aug 2025 11:22:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E7=9B=AE=E6=A0=87?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E9=80=BB=E8=BE=91=EF=BC=8C=E5=A4=84=E7=90=86?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E5=92=8C=E6=97=B6=E9=97=B4=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E7=9A=84=E7=A9=BA=E5=80=BC=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新目标创建逻辑,确保在创建目标时,startDate、startTime和endTime字段可以处理空值,提升数据的灵活性和安全性。 --- src/goals/goals.service.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/goals/goals.service.ts b/src/goals/goals.service.ts index 3a6b62b..87aabaf 100644 --- a/src/goals/goals.service.ts +++ b/src/goals/goals.service.ts @@ -30,10 +30,10 @@ export class GoalsService { const goal = await Goal.create({ userId, ...createGoalDto, - startDate: new Date(createGoalDto.startDate), + startDate: createGoalDto.startDate ? new Date(createGoalDto.startDate) : null, endDate: createGoalDto.endDate ? new Date(createGoalDto.endDate) : null, - startTime: createGoalDto.startTime, - endTime: createGoalDto.endTime, + startTime: createGoalDto.startTime ? createGoalDto.startTime : null, + endTime: createGoalDto.endTime ? createGoalDto.endTime : null, }); this.logger.log(`用户 ${userId} 创建了目标: ${goal.title}`);