import { Controller, Post, Body, HttpCode, HttpStatus, Get, UseGuards } from '@nestjs/common'; import { AdminService } from '../providers/admin.service'; import { CreateAdminDto } from '../dto/create-admin.dto'; import { ApiTags, ApiOperation, ApiBody, ApiResponse, ApiBearerAuth } from '@nestjs/swagger'; import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard'; @UseGuards(AdminAuthGuard) @ApiBearerAuth() @ApiTags('admin') @Controller('admin') export class AdminController { constructor(private readonly adminService: AdminService) {} @Get() @ApiOperation({ summary: 'admin' }) @ApiResponse({ status: 201, description: 'Admins' }) async getAll() { const admin = await this.adminService.findAll(); return admin; } @Post() @HttpCode(HttpStatus.CREATED) @ApiOperation({ summary: 'Create a new admin' }) @ApiBody({ type: CreateAdminDto }) @ApiResponse({ status: 201, description: 'Admin created' }) async create(@Body() dto: CreateAdminDto) { const admin = await this.adminService.create({ phone: dto.phone, firstName: dto.firstName, lastName: dto.lastName, roleId: dto.roleId, restId: dto.restId, }); return admin; } }