import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  Query,
} from '@nestjs/common';
import { CommentService } from './comment.service';
import { CreateCommentDto } from './dto/create-comment.dto';
import { UpdateCommentDto } from './dto/update-comment.dto';
import { AuthPayload, AuthUser } from 'src/auth/decorators/auth.payload';
import { SearchCommentDto } from './dto/search-comment,dto';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
@ApiTags('Comment API')
@ApiBearerAuth()
@Controller('comment')
export class CommentController {
  constructor(private readonly commentService: CommentService) { }

  @Post()
  create(
    @Body() createCommentDto: CreateCommentDto,
    @AuthUser() user: AuthPayload,
  ) {
    return this.commentService.create(createCommentDto, user);
  }

  @Get('by-slot/:slot_id')
  findAll(
    @Param('slot_id') slot_id: number,
    @Query() query: SearchCommentDto,
    @AuthUser() user: AuthPayload,
  ) {
    return this.commentService.findAll(+slot_id, query, user);
  }

  @Post('react/:id')
  react(
    @Param('id') slot_id: number,
    // @Query() query: SearchCommentDto,
    @AuthUser() user: AuthPayload,
  ) {
    return this.commentService.reactComment(+slot_id, user);
  }

  @Get(':id')
  findOne(@Param('id') id: number) {
    return this.commentService.findOne(+id);
  }

  @Patch(':id')
  update(
    @Param('id') id: number,
    @Body() updateCommentDto: UpdateCommentDto,
    @AuthUser() user: AuthPayload,
  ) {
    return this.commentService.update(+id, updateCommentDto, user);
  }

  @Delete(':id')
  remove(@Param('id') id: number, @AuthUser() user: AuthPayload,) {
    return this.commentService.remove(+id, user);
  }
}
