diff --git a/src/goals/goals.service.ts b/src/goals/goals.service.ts index 21c4745..a840ce8 100644 --- a/src/goals/goals.service.ts +++ b/src/goals/goals.service.ts @@ -146,6 +146,7 @@ export class GoalsService { */ async updateGoal(userId: string, goalId: string, updateGoalDto: UpdateGoalDto): Promise { try { + this.logger.log(`updateGoal updateGoalDto: ${JSON.stringify(updateGoalDto, null, 2)}`); const goal = await this.goalModel.findOne({ where: { id: goalId, userId, deleted: false }, }); @@ -166,10 +167,11 @@ export class GoalsService { throw new BadRequestException('已完成的目标不能修改状态'); } + + await goal.update({ ...updateGoalDto, - startDate: updateGoalDto.startDate ? new Date(updateGoalDto.startDate) : goal.startDate, - endDate: updateGoalDto.endDate ? new Date(updateGoalDto.endDate) : goal.endDate, + endDate: updateGoalDto.endDate ? new Date(updateGoalDto.endDate) : undefined, }); this.logger.log(`用户 ${userId} 更新了目标: ${goal.title}`);