import {
  Controller,
  Get,
  Put,
  Param,
  Body,
  Query,
  UseGuards,
} from '@nestjs/common';
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
import { SellerJwtAuthGuard } from '@/common/guards/seller-jwt-auth.guard';
import { CurrentSeller } from '@/common/decorators/current-seller.decorator';
import { MerchantRoomCalendarService } from './room-calendar.service';
import {
  QueryCalendarDto,
  BatchUpdateCalendarDto,
  SingleDayUpdateDto,
} from './dto/room-calendar.dto';

@ApiTags('房量房价(商家)')
@Controller('merchant/room-calendar')
@UseGuards(SellerJwtAuthGuard)
@ApiBearerAuth()
export class MerchantRoomCalendarController {
  constructor(private readonly calendarService: MerchantRoomCalendarService) {}

  @Get(':roomId')
  @ApiOperation({ summary: '查询房量日历' })
  async getCalendar(
    @Param('roomId') roomId: number,
    @Query() query: QueryCalendarDto,
  ) {
    return await this.calendarService.getCalendar(Number(roomId), query);
  }

  @Put('batch')
  @ApiOperation({ summary: '批量更新房量房价' })
  async batchUpdate(
    @CurrentSeller('sub') sellerId: number,
    @Body() dto: BatchUpdateCalendarDto,
  ) {
    return await this.calendarService.batchUpdate(dto, Number(sellerId));
  }

  @Put('single')
  @ApiOperation({ summary: '单日更新房量房价' })
  async singleDayUpdate(
    @CurrentSeller('sub') sellerId: number,
    @Body() dto: SingleDayUpdateDto,
  ) {
    return await this.calendarService.singleDayUpdate(dto, Number(sellerId));
  }
}
