feat: added get user projects function in project

This commit is contained in:
2026-07-06 12:06:33 +03:30
parent 9f61152d94
commit 16a0c14149
8 changed files with 54 additions and 13 deletions
@@ -140,8 +140,8 @@ export class ProjectService {
},
});
if(!project) throw new NotFoundException(ProjectMessage.PROJECT_NOT_FOUND);
if (!project) throw new NotFoundException(ProjectMessage.PROJECT_NOT_FOUND);
const taskPhases = project.taskPhases;
if (taskPhases !== undefined && taskPhases.length) {
throw new BadRequestException(ProjectMessage.PROJECT_CONTAINS_TASK_PHASES);
@@ -149,4 +149,14 @@ export class ProjectService {
await this.projectRepository.delete(id);
return project;
}
async findUserProjects(userId: string, pagination: PaginationDto): Promise<{ projects: TMProject[]; count: number; paginate: true }> {
const page = pagination.page ?? 1;
const limit = pagination.limit ?? 10;
const skip = (page - 1) * limit;
const [projects, count] = await this.projectRepository.findUserProjects(userId, skip, limit);
return { projects, count, paginate: true };
}
}