feat: added get user projects function in project
This commit is contained in:
@@ -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 };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user