feat: 移除获取目标和任务详情的API及相关逻辑

- 删除GoalsController和GoalsService中获取单个目标和任务详情的API实现,简化代码结构。
- 更新GoalTaskService中的分页参数,将每页数量调整为200,提升数据处理能力。
- 优化GoalTaskQueryDto,移除页码和每页数量的验证装饰器,简化DTO结构。
This commit is contained in:
richarjiang
2025-08-22 17:23:14 +08:00
parent 3530d123fc
commit f6b4c99e75
4 changed files with 3 additions and 110 deletions

View File

@@ -136,46 +136,6 @@ export class GoalsService {
}
}
/**
* 获取单个目标详情
*/
async getGoal(userId: string, goalId: string): Promise<Goal> {
try {
// 惰性生成任务
await this.goalTaskService.generateTasksLazily(userId, goalId);
const goal = await this.goalModel.findOne({
where: { id: goalId, userId, deleted: false },
include: [
{
model: GoalCompletion,
as: 'completions',
where: { deleted: false },
required: false,
order: [['completedAt', 'DESC']],
limit: 10, // 只显示最近10次完成记录
},
{
model: GoalTask,
as: 'tasks',
where: { deleted: false },
required: false,
order: [['startDate', 'ASC']],
limit: 20, // 显示最近20个任务
},
],
});
if (!goal) {
throw new NotFoundException('目标不存在');
}
return this.formatGoalResponse(goal);
} catch (error) {
this.logger.error(`获取目标详情失败: ${error.message}`);
throw error;
}
}
/**
* 更新目标