init studio admin backend
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import { Body, Controller, Delete, Get, Param, Patch, Post } from '@nestjs/common';
|
||||
|
||||
import {
|
||||
CreateAdminSshKeyDto,
|
||||
CreateAdminDto,
|
||||
ResetAdminPasswordDto,
|
||||
UpdateAdminRoleDto,
|
||||
UpdateAdminStatusDto,
|
||||
} from './dto';
|
||||
import { AdminRoles } from '../admin-auth/decorators/admin-auth.decorators';
|
||||
import { AdminRole } from './admin-role';
|
||||
import { AdminsService } from './admins.service';
|
||||
|
||||
@AdminRoles(AdminRole.OWNER)
|
||||
@Controller('admins')
|
||||
export class AdminsController {
|
||||
constructor(private readonly adminsService: AdminsService) {}
|
||||
|
||||
@Get('roles')
|
||||
listRoles() {
|
||||
return this.adminsService.listRoles();
|
||||
}
|
||||
|
||||
@Get()
|
||||
list() {
|
||||
return this.adminsService.list();
|
||||
}
|
||||
|
||||
@Post()
|
||||
create(@Body() body: CreateAdminDto) {
|
||||
return this.adminsService.create(body);
|
||||
}
|
||||
|
||||
@Patch(':id/status')
|
||||
updateStatus(@Param('id') id: string, @Body() body: UpdateAdminStatusDto) {
|
||||
return this.adminsService.updateStatus(id, body);
|
||||
}
|
||||
|
||||
@Patch(':id/role')
|
||||
updateRole(@Param('id') id: string, @Body() body: UpdateAdminRoleDto) {
|
||||
return this.adminsService.updateRole(id, body);
|
||||
}
|
||||
|
||||
@Patch(':id/password')
|
||||
resetPassword(@Param('id') id: string, @Body() body: ResetAdminPasswordDto) {
|
||||
return this.adminsService.resetPassword(id, body);
|
||||
}
|
||||
|
||||
@Post(':id/ssh-keys')
|
||||
createSshKey(@Param('id') id: string, @Body() body: CreateAdminSshKeyDto) {
|
||||
return this.adminsService.createSshKey(id, body);
|
||||
}
|
||||
|
||||
@Delete(':id/ssh-keys/:keyId')
|
||||
deleteSshKey(@Param('id') id: string, @Param('keyId') keyId: string) {
|
||||
return this.adminsService.deleteSshKey(id, keyId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user