This commit is contained in:
2025-11-23 14:48:58 +03:30
parent 7dd1b61cac
commit a3f0593443
4 changed files with 48 additions and 13 deletions
@@ -1,4 +1,4 @@
import { Controller, Post, Body, HttpCode, HttpStatus, Get, UseGuards, Patch, Param } from '@nestjs/common';
import { Controller, Post, Body, HttpCode, HttpStatus, Get, UseGuards, Patch, Param, Delete } from '@nestjs/common';
import { AdminService } from '../providers/admin.service';
import { CreateAdminDto } from '../dto/create-admin.dto';
import { UpdateAdminDto } from '../dto/update-admin.dto';
@@ -26,8 +26,8 @@ export class AdminController {
@Get('profile')
@ApiOperation({ summary: 'admin' })
@ApiResponse({ status: 201, description: 'Admins' })
async getMe(@AdminId() adminId: string) {
const admin = await this.adminService.findById(adminId);
async getMe(@AdminId() adminId: string, @RestId() restId: string) {
const admin = await this.adminService.findById(adminId, restId);
return admin;
}
@@ -56,4 +56,20 @@ export class AdminController {
update(@Param('id') id: string, @Body() dto: UpdateAdminDto, @RestId() restId: string): Promise<Admin> {
return this.adminService.update(id, restId, dto);
}
@Get(':adminId')
@ApiOperation({ summary: 'Get an admin by ID' })
@ApiParam({ name: 'id', description: 'Admin ID' })
@ApiResponse({ status: 200, description: 'Admin found successfully' })
@ApiResponse({ status: 404, description: 'Admin not found' })
getById(@Param('adminId') adminId: string, @RestId() restId: string): Promise<Admin | null> {
return this.adminService.findById(adminId, restId);
}
@Delete(':adminId')
@ApiOperation({ summary: 'Delete an admin by ID' })
@ApiParam({ name: 'id', description: 'Admin ID' })
@ApiResponse({ status: 200, description: 'Admin deleted successfully' })
@ApiResponse({ status: 404, description: 'Admin not found' })
deleteById(@Param('adminId') adminId: string, @RestId() restId: string): Promise<void> {
return this.adminService.remove(adminId, restId);
}
}