feat(admin): manage match participants
This commit is contained in:
1 parent
994a9fcad0
commit
6a192276e8
4 files changed
+437
-1
No files matched your search
@@ -27,6 +27,7 @@ import {
|
||||
CreateMatchDto,
|
||||
JoinMatchDto,
|
||||
UpdateMatchDto,
|
||||
UpdateParticipantDto,
|
||||
} from './dto/create-match.dto';
|
||||
import { MatchService } from './match.service';
|
||||
|
||||
@@ -137,6 +138,49 @@ export class MatchController {
|
||||
});
|
||||
}
|
||||
|
||||
// 관리자 전용 — 참가자 주/부 포지션 변경.
|
||||
@Patch(':matchId/participants/:userId')
|
||||
@Roles('admin', 'owner')
|
||||
@UseGuards(RolesGuard)
|
||||
public async updateParticipant(
|
||||
@CurrentUser() currentUser: UserDocument,
|
||||
@Param('communityId', ParseObjectIdPipe)
|
||||
communityId: mongoose.Types.ObjectId,
|
||||
@Param('matchId', ParseObjectIdPipe) matchId: mongoose.Types.ObjectId,
|
||||
@Param('userId', ParseObjectIdPipe) userId: mongoose.Types.ObjectId,
|
||||
@Body() body: UpdateParticipantDto,
|
||||
) {
|
||||
this.assertSameCommunity(currentUser, communityId);
|
||||
const match = await this.matchService.updateParticipantPositions({
|
||||
matchId,
|
||||
communityId,
|
||||
targetUserId: userId,
|
||||
mainPosition: body.mainPosition,
|
||||
subPosition: body.subPosition,
|
||||
});
|
||||
return this.matchService.serialize(match);
|
||||
}
|
||||
|
||||
// 관리자 전용 — 참가자 강제 제외.
|
||||
@Delete(':matchId/participants/:userId')
|
||||
@Roles('admin', 'owner')
|
||||
@UseGuards(RolesGuard)
|
||||
@HttpCode(HttpStatus.NO_CONTENT)
|
||||
public async removeParticipant(
|
||||
@CurrentUser() currentUser: UserDocument,
|
||||
@Param('communityId', ParseObjectIdPipe)
|
||||
communityId: mongoose.Types.ObjectId,
|
||||
@Param('matchId', ParseObjectIdPipe) matchId: mongoose.Types.ObjectId,
|
||||
@Param('userId', ParseObjectIdPipe) userId: mongoose.Types.ObjectId,
|
||||
) {
|
||||
this.assertSameCommunity(currentUser, communityId);
|
||||
await this.matchService.removeParticipant({
|
||||
matchId,
|
||||
communityId,
|
||||
targetUserId: userId,
|
||||
});
|
||||
}
|
||||
|
||||
private resolveJoinerUserId(
|
||||
currentUser: UserDocument | undefined,
|
||||
bodyUserId?: string,
|
||||
|
||||
Reference in new issue
Block a user