import { Body, Controller, Get, Post, UseGuards } from '@nestjs/common';
import { DesignationsService } from './designations.service';
import { JwtAuthGuard } from '../common/guards/jwt-auth.guard';
import { RolesGuard } from '../common/guards/roles.guard';
import { Roles } from '../common/decorators/roles.decorator';
import { Role } from '../common/roles/role.enum';

@Controller('designations')
@UseGuards(JwtAuthGuard)
export class DesignationsController {
    constructor(private readonly designationsService: DesignationsService) {}

    @Get()
    findAll() {
        return this.designationsService.findAll();
    }

    @Post()
    @UseGuards(RolesGuard)
    @Roles(Role.ADMIN)
    create(@Body('name') name: string) {
        return this.designationsService.create(name);
    }
}
