import { Controller, Get, Query, Param } from '@nestjs/common';
import { ApiTags, ApiOperation } from '@nestjs/swagger';
import { RoomService } from './room.service';
import { QueryAvailableRoomsDto } from './dto/room.dto';

@ApiTags('房源')
@Controller('app/rooms')
export class RoomController {
  constructor(private readonly roomService: RoomService) {}

  @Get()
  @ApiOperation({ summary: '查询可用房源' })
  async findAvailable(@Query() query: QueryAvailableRoomsDto) {
    return this.roomService.findAvailable(query);
  }

  @Get(':id')
  @ApiOperation({ summary: '获取房源详情' })
  async findOne(@Param('id') id: number) {
    return this.roomService.findById(id);
  }

  @Get(':id/calendar')
  @ApiOperation({ summary: '获取房源日历' })
  async getCalendar(
    @Param('id') id: number,
    @Query('startDate') startDate: string,
    @Query('endDate') endDate: string,
  ) {
    return this.roomService.getRoomCalendar(id, startDate, endDate);
  }
}
