2026-09-19 21:54:21 +03:30
|
|
|
import {
|
|
|
|
|
Body,
|
|
|
|
|
Controller,
|
|
|
|
|
Get,
|
|
|
|
|
Param,
|
|
|
|
|
Patch,
|
|
|
|
|
Post,
|
|
|
|
|
Query,
|
|
|
|
|
UseGuards,
|
|
|
|
|
} from '@nestjs/common';
|
2026-09-19 22:42:51 +03:30
|
|
|
import { CurrentUser } from '../auth/current-user.decorator';
|
2026-09-19 21:54:21 +03:30
|
|
|
import {
|
2026-09-19 22:42:51 +03:30
|
|
|
CreatePlatformAdminDto,
|
2026-09-19 21:54:21 +03:30
|
|
|
CreatePlatformOrganizationDto,
|
2026-09-19 22:42:51 +03:30
|
|
|
ResetPlatformAdminPasswordDto,
|
2026-09-19 21:54:21 +03:30
|
|
|
ResetPlatformUserPasswordDto,
|
|
|
|
|
UpdatePlatformMembershipRoleDto,
|
|
|
|
|
UpdatePlatformOrganizationDto,
|
|
|
|
|
UpdatePlatformStatusDto,
|
|
|
|
|
} from './dto';
|
|
|
|
|
import { PlatformAuthGuard } from './platform-auth.guard';
|
2026-09-19 22:42:51 +03:30
|
|
|
import type { PlatformActor } from './platform-jwt.strategy';
|
2026-09-19 21:54:21 +03:30
|
|
|
import { PlatformService } from './platform.service';
|
|
|
|
|
|
|
|
|
|
@Controller('platform')
|
|
|
|
|
@UseGuards(PlatformAuthGuard)
|
|
|
|
|
export class PlatformController {
|
|
|
|
|
constructor(private readonly platform: PlatformService) {}
|
|
|
|
|
|
|
|
|
|
@Get('stats')
|
|
|
|
|
stats() {
|
|
|
|
|
return this.platform.stats();
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-19 22:42:51 +03:30
|
|
|
@Get('admins')
|
|
|
|
|
listAdmins() {
|
|
|
|
|
return this.platform.listAdmins();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Post('admins')
|
|
|
|
|
createAdmin(@Body() dto: CreatePlatformAdminDto) {
|
|
|
|
|
return this.platform.createAdmin(dto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Patch('admins/:id')
|
|
|
|
|
setAdminActive(
|
|
|
|
|
@Param('id') id: string,
|
|
|
|
|
@Body() dto: UpdatePlatformStatusDto,
|
|
|
|
|
@CurrentUser() actor: PlatformActor,
|
|
|
|
|
) {
|
|
|
|
|
return this.platform.setAdminActive(id, dto.isActive, actor.platformAdminId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Patch('admins/:id/password')
|
|
|
|
|
resetAdminPassword(
|
|
|
|
|
@Param('id') id: string,
|
|
|
|
|
@Body() dto: ResetPlatformAdminPasswordDto,
|
|
|
|
|
) {
|
|
|
|
|
return this.platform.resetAdminPassword(id, dto);
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-19 21:54:21 +03:30
|
|
|
@Get('organizations')
|
|
|
|
|
listOrganizations(@Query('q') q?: string) {
|
|
|
|
|
return this.platform.listOrganizations(q);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Post('organizations')
|
|
|
|
|
createOrganization(@Body() dto: CreatePlatformOrganizationDto) {
|
|
|
|
|
return this.platform.createOrganization(dto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Get('organizations/:id')
|
|
|
|
|
getOrganization(@Param('id') id: string) {
|
|
|
|
|
return this.platform.getOrganization(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Patch('organizations/:id')
|
|
|
|
|
updateOrganization(
|
|
|
|
|
@Param('id') id: string,
|
|
|
|
|
@Body() dto: UpdatePlatformOrganizationDto,
|
|
|
|
|
) {
|
|
|
|
|
return this.platform.updateOrganization(id, dto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Get('users')
|
|
|
|
|
listUsers(@Query('q') q?: string) {
|
|
|
|
|
return this.platform.listUsers(q);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Get('users/:id')
|
|
|
|
|
getUser(@Param('id') id: string) {
|
|
|
|
|
return this.platform.getUser(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Patch('users/:id')
|
|
|
|
|
setUserActive(@Param('id') id: string, @Body() dto: UpdatePlatformStatusDto) {
|
|
|
|
|
return this.platform.setUserActive(id, dto.isActive);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Patch('users/:id/password')
|
|
|
|
|
resetUserPassword(
|
|
|
|
|
@Param('id') id: string,
|
|
|
|
|
@Body() dto: ResetPlatformUserPasswordDto,
|
|
|
|
|
) {
|
|
|
|
|
return this.platform.resetUserPassword(id, dto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Patch('memberships/:id')
|
|
|
|
|
setMembershipActive(
|
|
|
|
|
@Param('id') id: string,
|
|
|
|
|
@Body() dto: UpdatePlatformStatusDto,
|
|
|
|
|
) {
|
|
|
|
|
return this.platform.setMembershipActive(id, dto.isActive);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Patch('memberships/:id/role')
|
|
|
|
|
updateMembershipRole(
|
|
|
|
|
@Param('id') id: string,
|
|
|
|
|
@Body() dto: UpdatePlatformMembershipRoleDto,
|
|
|
|
|
) {
|
|
|
|
|
return this.platform.updateMembershipRole(id, dto.role);
|
|
|
|
|
}
|
|
|
|
|
}
|