del old version
This commit is contained in:
parent
c77dd23dd1
commit
b40b2e4430
@ -44,14 +44,15 @@ export class ProjectsController {
|
|||||||
return this.projectsService.findAll();
|
return this.projectsService.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation({ summary: 'Get my projects' })
|
@ApiOperation({ summary: 'Get all projects where I participate' })
|
||||||
@ApiResponse({ status: 200, description: 'List of projects', type: Project, isArray: true })
|
@ApiResponse({ status: 200, description: 'List of projects', type: Project, isArray: true })
|
||||||
@UseGuards(JwtAuthGuard)
|
@UseGuards(JwtAuthGuard)
|
||||||
@Get('my')
|
@Get('my')
|
||||||
async findMyProjects(@Request() req): Promise<Project[]> {
|
async findUserProjects(@Request() req): Promise<Project[]> {
|
||||||
return this.projectsService.findByOwner(req.user.sub);
|
return this.projectsService.findUserProjects(req.user.sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation({ summary: 'Get single project by ID' })
|
@ApiOperation({ summary: 'Get single project by ID' })
|
||||||
@ApiParam({ name: 'id', type: 'number' })
|
@ApiParam({ name: 'id', type: 'number' })
|
||||||
@ApiResponse({ status: 200, description: 'Found project', type: Project })
|
@ApiResponse({ status: 200, description: 'Found project', type: Project })
|
||||||
|
|||||||
@ -29,6 +29,14 @@ export class ProjectsService {
|
|||||||
return this.projectsRepository.find({ where: { ownerId } });
|
return this.projectsRepository.find({ where: { ownerId } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async findUserProjects(userId: number): Promise<Project[]> {
|
||||||
|
return this.projectsRepository
|
||||||
|
.createQueryBuilder('project')
|
||||||
|
.leftJoin('project_members', 'member', 'member.projectId = project.id')
|
||||||
|
.where('project.ownerId = :userId OR member.userId = :userId', { userId })
|
||||||
|
.getMany();
|
||||||
|
}
|
||||||
|
|
||||||
async findOneById(id: number): Promise<Project | null> {
|
async findOneById(id: number): Promise<Project | null> {
|
||||||
return this.projectsRepository.findOne({ where: { id } });
|
return this.projectsRepository.findOne({ where: { id } });
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,7 +46,7 @@ export class AuthController {
|
|||||||
description: 'User created successfully',
|
description: 'User created successfully',
|
||||||
})
|
})
|
||||||
@ApiResponse({
|
@ApiResponse({
|
||||||
status: 409,
|
status: 401,
|
||||||
description: 'Username already exists',
|
description: 'Username already exists',
|
||||||
})
|
})
|
||||||
@Post('register')
|
@Post('register')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user