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

@ApiTags('socialPlatform')
@ApiBearerAuth('access-token')
@Controller('socialPlatform')
export class SocialPlatformController {
  constructor(private readonly socialPlatformService: SocialPlatformService) {}

  @Public()
  @Get()
  @ApiOperation({ summary: 'Get all social platforms' })
  async findAll() {
    return this.socialPlatformService.findAll();
  }

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

  @Public()
  @Get(':id')
  @ApiOperation({ summary: 'Get social platform by ID' })
  @ApiParam({ name: 'id', type: String })
  findOne(@Param('id') id: string) {
    return this.socialPlatformService.findOne(+id);
  }

  @Public()
  @Post()
  @ApiOperation({ summary: 'Create Social Platform' })
  @ApiBody({ schema: { type: 'object', description: 'Social Platform Data' } })
  create(@Body() body: any) {
    return this.socialPlatformService.create(body);
  }

  @Public()
  @Put(':id')
  @ApiOperation({ summary: 'Update Social Platform' })
  @ApiParam({ name: 'id', type: String })
  @ApiBody({ schema: { type: 'object', description: 'Social Platform Data' } })
  update(@Param('id') id: string, @Body() body: any) {
    return this.socialPlatformService.update(+id, body);
  }

  @Public()
  @Patch(':id')
  @ApiOperation({ summary: 'Patch Social Platform' })
  @ApiParam({ name: 'id', type: String })
  @ApiBody({ schema: { type: 'object', description: 'Social Platform Data' } })
  patch(@Param('id') id: string, @Body() body: any) {
    return this.socialPlatformService.update(+id, body);
  }

  @Public()
  @Delete(':id')
  @ApiOperation({ summary: 'Delete social platform' })
  @ApiParam({ name: 'id', type: String })
  remove(@Param('id') id: string) {
    return this.socialPlatformService.remove(+id);
  }
}
