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

@ApiTags('companySizes')
@ApiBearerAuth('access-token')
@Controller('companySizes')
export class CompanySizesController {
  constructor(private readonly companySizesService: CompanySizesService) {}

  @Public()
  @Get('filtered')
  @ApiOperation({ summary: 'Get Company Sizes 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.companySizesService.findAllPaginated(
      Number(page || 1),
      Number(limit || 10),
    );
  }

  @Public()
  @Post()
  @ApiOperation({ summary: 'Create Company Size' })
  @ApiBody({ schema: { type: 'object', description: 'Company size data' } })
  create(@Body() body: any) {
    return this.companySizesService.create(body);
  }

  @Public()
  @Put(':id')
  @ApiOperation({ summary: 'Update Company Size' })
  @ApiParam({ name: 'id', type: String })
  @ApiBody({ schema: { type: 'object', description: 'Company size data' } })
  update(@Param('id') id: string, @Body() body: any) {
    return this.companySizesService.update(+id, body);
  }

  @Public()
  @Patch(':id')
  @ApiOperation({ summary: 'Patch Company Size' })
  @ApiParam({ name: 'id', type: String })
  @ApiBody({ schema: { type: 'object', description: 'Company size data' } })
  patch(@Param('id') id: string, @Body() body: any) {
    return this.companySizesService.update(+id, body);
  }

  @Public()
  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.companySizesService.remove(+id);
  }
}
