diff --git a/src/goals/dto/goal-task.dto.ts b/src/goals/dto/goal-task.dto.ts index 3a6bc47..abb8139 100644 --- a/src/goals/dto/goal-task.dto.ts +++ b/src/goals/dto/goal-task.dto.ts @@ -83,14 +83,12 @@ export class GoalTaskQueryDto { @IsOptional() @IsInt() - @Min(1, { message: '页码必须大于0' }) + page?: number = 1; @IsOptional() @IsInt() - @Min(1, { message: '每页数量必须大于0' }) - @Max(100, { message: '每页数量不能超过100' }) - pageSize?: number = 20; + pageSize?: number = 200; } export class CompleteGoalTaskDto { diff --git a/src/goals/goals.controller.ts b/src/goals/goals.controller.ts index 6d85b1e..a208b4c 100644 --- a/src/goals/goals.controller.ts +++ b/src/goals/goals.controller.ts @@ -64,21 +64,6 @@ export class GoalsController { }; } - /** - * 获取单个目标详情 - */ - @Get(':id') - async getGoal( - @Param('id') id: string, - @CurrentUser() user: AccessTokenPayload, - ): Promise> { - const goal = await this.goalsService.getGoal(user.sub, id); - return { - code: ResponseCode.SUCCESS, - message: '获取目标详情成功', - data: goal, - }; - } /** * 更新目标 @@ -227,22 +212,6 @@ export class GoalsController { }; } - /** - * 获取单个任务详情 - */ - @Get('tasks/:taskId') - async getTask( - @Param('taskId') taskId: string, - @CurrentUser() user: AccessTokenPayload, - ): Promise> { - const task = await this.goalTaskService.getTask(user.sub, taskId); - return { - code: ResponseCode.SUCCESS, - message: '获取任务详情成功', - data: task, - }; - } - /** * 完成任务 */ diff --git a/src/goals/goals.service.ts b/src/goals/goals.service.ts index e848fea..291d981 100644 --- a/src/goals/goals.service.ts +++ b/src/goals/goals.service.ts @@ -136,46 +136,6 @@ export class GoalsService { } } - /** - * 获取单个目标详情 - */ - async getGoal(userId: string, goalId: string): Promise { - 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; - } - } /** * 更新目标 diff --git a/src/goals/services/goal-task.service.ts b/src/goals/services/goal-task.service.ts index a1c20fc..e14ecdf 100644 --- a/src/goals/services/goal-task.service.ts +++ b/src/goals/services/goal-task.service.ts @@ -314,7 +314,7 @@ export class GoalTaskService { // 先进行惰性生成 await this.generateTasksLazily(userId, query.goalId); - const { page = 1, pageSize = 20, goalId, status, startDate, endDate } = query; + const { page = 1, pageSize = 200, goalId, status, startDate, endDate } = query; const offset = (page - 1) * pageSize; const where: WhereOptions = { @@ -345,13 +345,6 @@ export class GoalTaskService { order: [['startDate', 'ASC'], ['createdAt', 'DESC']], offset, limit: pageSize, - include: [ - { - model: Goal, - as: 'goal', - attributes: ['id', 'title', 'repeatType', 'frequency', 'category'], - }, - ], }); return { @@ -366,33 +359,6 @@ export class GoalTaskService { } } - /** - * 获取单个任务详情 - */ - async getTask(userId: string, taskId: string): Promise { - try { - const task = await this.goalTaskModel.findOne({ - where: { id: taskId, userId, deleted: false }, - include: [ - { - model: Goal, - as: 'goal', - attributes: ['id', 'title', 'repeatType', 'frequency', 'category'], - }, - ], - }); - - if (!task) { - throw new NotFoundException('任务不存在'); - } - - return this.formatTaskResponse(task); - } catch (error) { - this.logger.error(`获取任务详情失败: ${error.message}`); - throw error; - } - } - /** * 完成任务 */