import { Controller, Get, Post, Body, Param } from '@nestjs/common';
import { ReviewsService } from './reviews.service';
import { ReviewItemDto } from './review-item.dto';

@Controller('reviews')
export class ReviewsController {
  constructor(private readonly reviewsService: ReviewsService) {}

  @Post()
  create(@Body() dto: ReviewItemDto) {
    return this.reviewsService.createReview(dto);
  }

  @Get('user/:userId')
  findByUserId(@Param('userId') userId: string) {
    return this.reviewsService.getReviewsByUserId(Number(userId));
  }

  @Get('yacht/:yachtId')
  findByYachtId(@Param('yachtId') yachtId: string) {
    return this.reviewsService.getReviewsByYachtId(Number(yachtId));
  }

  @Get()
  findAll() {
    return this.reviewsService.getAllReviews();
  }
}
