This commit is contained in:
2025-12-11 18:22:18 +03:30
parent 10b0bfe554
commit 2cf554caa4
12 changed files with 13 additions and 76 deletions
@@ -2,7 +2,7 @@ import { Controller, Post, Body, HttpCode, HttpStatus, Get, UseGuards, Patch, Pa
import { AdminService } from '../providers/admin.service';
import { CreateAdminDto } from '../dto/create-admin.dto';
import { UpdateAdminDto } from '../dto/update-admin.dto';
import { ApiTags, ApiOperation, ApiBody, ApiResponse, ApiBearerAuth, ApiParam } from '@nestjs/swagger';
import { ApiTags, ApiOperation, ApiBody, ApiBearerAuth, ApiParam } from '@nestjs/swagger';
import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard';
import { RestId } from 'src/common/decorators';
import { AdminId } from 'src/common/decorators/admin-id.decorator';
@@ -17,7 +17,6 @@ export class AdminController {
@Get()
@ApiOperation({ summary: 'admin' })
@ApiResponse({ status: 201, description: 'Admins' })
async getAll(@RestId() restId: string) {
const admin = await this.adminService.findAllByRestaurantId(restId);
return admin;
@@ -25,7 +24,6 @@ export class AdminController {
@Get('profile')
@ApiOperation({ summary: 'admin' })
@ApiResponse({ status: 201, description: 'Admins' })
async getMe(@AdminId() adminId: string, @RestId() restId: string) {
const admin = await this.adminService.findById(adminId, restId);
return admin;
@@ -35,7 +33,6 @@ export class AdminController {
@HttpCode(HttpStatus.CREATED)
@ApiOperation({ summary: 'Create a new admin' })
@ApiBody({ type: CreateAdminDto })
@ApiResponse({ status: 201, description: 'Admin created' })
async create(@Body() dto: CreateAdminDto, @RestId() restId: string) {
const admin = await this.adminService.createAdminForMyRestaurant(restId, dto);
return admin;
@@ -45,24 +42,18 @@ export class AdminController {
@ApiOperation({ summary: 'Update an admin' })
@ApiParam({ name: 'adminId', description: 'Admin ID' })
@ApiBody({ type: UpdateAdminDto })
@ApiResponse({ status: 200, description: 'Admin updated successfully' })
@ApiResponse({ status: 404, description: 'Admin not found' })
update(@Param('adminId') adminId: string, @Body() dto: UpdateAdminDto, @RestId() restId: string): Promise<Admin> {
return this.adminService.update(adminId, 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);
}