import {
  Controller,
  Get,
  Post,
  Put,
  Delete,
  Param,
  Body,
  Query,
  Patch,
} from '@nestjs/common';
import { EducationLevelsService } from './education_levels.service';
import { EducationLevels } from './entities/education_levels.entity';
import { Public } from '../auth/public.decorator';
import {
  ApiBearerAuth,
  ApiTags,
  ApiBody,
  ApiParam,
  ApiQuery,
  ApiOperation,
} from '@nestjs/swagger';

@ApiTags('education_levels')
@ApiBearerAuth('access-token')
@Controller('education_levels')
export class EducationLevelsController {
  constructor(
    private readonly educationLevelsService: EducationLevelsService,
  ) {}
  @Public()
  @Get()
  @ApiOperation({ summary: 'Get All Education Levels' })
  findAll(): Promise<EducationLevels[]> {
    return this.educationLevelsService.findAll();
  }

  @Public()
  @Get('filtered')
  @ApiOperation({ summary: 'Get Education Levels Paginated' })
  @ApiQuery({ name: 'page', required: false, type: Number })
  @ApiQuery({ name: 'limit', required: false, type: Number })
  findAllPaginated(
    @Query('page') page: number = 1,
    @Query('limit') limit: number = 10,
  ) {
    return this.educationLevelsService.findAllPaginated(
      Number(page || 1),
      Number(limit || 10),
    );
  }
  @Public()
  @Get(':id')
  findOne(@Param('id') id: number): Promise<EducationLevels> {
    return this.educationLevelsService.findOne(id);
  }
  @Public()
  @Post()
  @ApiOperation({ summary: 'Create Education Level' })
  @ApiBody({ schema: { type: 'object', description: 'Education level data' } })
  create(@Body() createEducationLevelsDto: any): Promise<EducationLevels> {
    return this.educationLevelsService.create(createEducationLevelsDto);
  }
  @Public()
  @Put(':id')
  @ApiOperation({ summary: 'Update Education Level' })
  @ApiParam({ name: 'id', type: Number })
  @ApiBody({ schema: { type: 'object', description: 'Education level data' } })
  update(
    @Param('id') id: number,
    @Body() updateEducationLevelsDto: any,
  ): Promise<EducationLevels> {
    return this.educationLevelsService.update(id, updateEducationLevelsDto);
  }
  @Public()
  @Patch(':id')
  @ApiOperation({ summary: 'Patch Education Level' })
  @ApiParam({ name: 'id', type: Number })
  @ApiBody({ schema: { type: 'object', description: 'Education level data' } })
  patch(
    @Param('id') id: number,
    @Body() updateEducationLevelsDto: any,
  ): Promise<EducationLevels> {
    return this.educationLevelsService.update(id, updateEducationLevelsDto);
  }
  @Public()
  @Delete(':id')
  remove(@Param('id') id: number): Promise<void> {
    return this.educationLevelsService.remove(id);
  }
}
