feat: added getTaskDetail API

This commit is contained in:
2026-07-06 16:01:36 +03:30
parent da71c20d6d
commit 0cd5a6a0cc
4 changed files with 41 additions and 2 deletions
@@ -1,4 +1,4 @@
import { BadRequestException, Injectable, NotFoundException } from "@nestjs/common";
import { BadRequestException, ForbiddenException, Injectable, NotFoundException } from "@nestjs/common";
import { InjectRepository } from "@nestjs/typeorm";
import { In, Repository } from "typeorm";
import { TaskRepository } from "../repositories/task.repository";
@@ -35,6 +35,7 @@ export class TaskService {
where: { id },
relations: {
taskPhase: true,
users: true
},
});
if (!task) throw new NotFoundException(TaskMessage.TASK_NOT_FOUND);
@@ -123,4 +124,14 @@ export class TaskService {
await this.findOneOrFail(id);
await this.taskRepository.delete(id);
}
async getTaskDetail(userId: string, taskId: string): Promise<TMTask | null> {
const task = await this.findOneOrFail(taskId);
const isTaskMember = task.users.some((user) => user.id === userId);
if(!isTaskMember) throw new ForbiddenException(TaskMessage.USER_NOT_TASK_MEMBER);
const taskDetail = await this.taskRepository.getTaskDetail(taskId);
return taskDetail;
}
}