Thêm tính năng xóa thành viên ra khỏi tour

This commit is contained in:
2026-06-14 17:43:28 +07:00
parent 4bec095a40
commit bb15b2bf15
15 changed files with 154 additions and 21 deletions
+16 -1
View File
@@ -361,7 +361,7 @@ class TourController {
async addMember(@Param('tourId', ParseUUIDPipe) tourId: string, @Body() body: { userId: string; role?: string }, @Req() req: any) {
const validRoles = ['OWNER', 'MANAGER', 'MEMBER', 'MEMBER_NO_FINANCE', 'VIEWER_ONLY'] as const;
const role = validRoles.includes(body.role as any) ? body.role as 'OWNER' | 'MANAGER' | 'MEMBER' | 'MEMBER_NO_FINANCE' | 'VIEWER_ONLY' : 'MEMBER';
const participation = await this.prisma.tourParticipant.findUnique({
where: { tourId_userId: { tourId, userId: body.userId } },
});
@@ -381,6 +381,21 @@ class TourController {
include: { user: { select: { id: true, name: true, email: true } } },
});
}
@UseGuards(JwtAuthGuard, TourRoleGuard)
@Delete(':tourId/members/:userId')
async removeMember(@Param('tourId', ParseUUIDPipe) tourId: string, @Param('userId', ParseUUIDPipe) userId: string) {
const participation = await this.prisma.tourParticipant.findUnique({
where: { tourId_userId: { tourId, userId } },
});
if (!participation) {
throw new NotFoundException('Thành viên này không có trong tour');
}
await this.prisma.tourParticipant.delete({
where: { tourId_userId: { tourId, userId } },
});
return { message: 'Đã xóa thành viên khỏi tour' };
}
}
@Controller('v1/locations')