refactor: removing useless get projects by workspace function
This commit is contained in:
@@ -67,19 +67,6 @@ export class ProjectController {
|
|||||||
return this.projectService.remove(id);
|
return this.projectService.remove(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("/workspace/:wsId")
|
|
||||||
@PermissionsDec(PermissionEnum.PROJECT)
|
|
||||||
@ApiOperation({ summary: "Get projects of a specific workspace" })
|
|
||||||
@ApiParam({ name: "wsId", description: "Workspace ID" })
|
|
||||||
@ApiResponse({ status: 200, description: "received projects successfully!" })
|
|
||||||
@ApiResponse({ status: 404, description: "WorkSpace not found" })
|
|
||||||
findByWorkspace(
|
|
||||||
@Param("wsId") wsId: string,
|
|
||||||
@Query() pagination: PaginationDto,
|
|
||||||
): Promise<{ projects: TMProject[]; count: number; paginate: true }> {
|
|
||||||
return this.projectService.findByWorkspace(wsId, pagination);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get("/user")
|
@Get("/user")
|
||||||
@ApiOperation({ summary: "Get user projects!" })
|
@ApiOperation({ summary: "Get user projects!" })
|
||||||
@ApiResponse({ status: 200, description: "Got user projects successfully!" })
|
@ApiResponse({ status: 200, description: "Got user projects successfully!" })
|
||||||
|
|||||||
@@ -42,32 +42,6 @@ export class ProjectService {
|
|||||||
return { projects, count, paginate: true };
|
return { projects, count, paginate: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
async findByWorkspace(workspaceId: string, pagination: PaginationDto): Promise<{ projects: TMProject[]; count: number; paginate: true }> {
|
|
||||||
await this.workspaceService.findOneOrFail(workspaceId);
|
|
||||||
|
|
||||||
const page = pagination.page ?? 1;
|
|
||||||
const limit = pagination.limit ?? 10;
|
|
||||||
const skip = (page - 1) * limit;
|
|
||||||
|
|
||||||
const [projects, count] = await this.projectRepository.findAndCount({
|
|
||||||
where: { workspaceId },
|
|
||||||
relations: {
|
|
||||||
users: true,
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
users: {
|
|
||||||
id: true,
|
|
||||||
firstName: true,
|
|
||||||
lastName: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
skip,
|
|
||||||
take: limit,
|
|
||||||
});
|
|
||||||
|
|
||||||
return { projects, count, paginate: true };
|
|
||||||
}
|
|
||||||
|
|
||||||
async findOneOrFail(id: string): Promise<TMProject> {
|
async findOneOrFail(id: string): Promise<TMProject> {
|
||||||
const project = await this.projectRepository.findOne({ where: { id } });
|
const project = await this.projectRepository.findOne({ where: { id } });
|
||||||
if (!project) throw new NotFoundException(ProjectMessage.PROJECT_NOT_FOUND);
|
if (!project) throw new NotFoundException(ProjectMessage.PROJECT_NOT_FOUND);
|
||||||
|
|||||||
Reference in New Issue
Block a user