import { Body, Controller, Delete, Get, Param, Patch, Post, Query, UseGuards, } from '@nestjs/common'; import { AuthGuard } from '@nestjs/passport'; import { GemeindeService } from './gemeinde.service'; import { CreateGemeindeDto } from './dto/create-gemeinde.dto'; import { UpdateGemeindeDto } from './dto/update-gemeinde.dto'; import { Roles } from '../common/roles.decorator'; import { RolesGuard } from '../common/roles.guard'; import { Role } from '../common/role.enum'; /// Gemeinde (congregation) management. Reserved for the Leitungsteam, which is /// global across all KCs (see RolesGuard); Gemeinde Verantwortliche/Teamer /// learn their own Gemeinde from their Membership, not from this endpoint. @Controller('gemeinde') @UseGuards(AuthGuard(['authentik', 'team']), RolesGuard) @Roles(Role.LEITUNGSTEAM) export class GemeindeController { constructor(private readonly gemeinde: GemeindeService) {} @Post() create(@Body() dto: CreateGemeindeDto) { return this.gemeinde.create(dto.kcId, dto.name); } @Get() list(@Query('kcId') kcId: string) { return this.gemeinde.list(kcId); } @Get(':id') get(@Param('id') id: string) { return this.gemeinde.get(id); } @Patch(':id') update(@Param('id') id: string, @Body() dto: UpdateGemeindeDto) { return this.gemeinde.update(id, dto.name); } @Delete(':id') remove(@Param('id') id: string) { return this.gemeinde.remove(id); } }