import { Body, Controller, Get, Param, Post, Req, UseGuards } from "@nestjs/common";
import { JwtAccessAuthGuard } from "src/middleware/auth/guard/access-token.guard";
import { ScheduleService } from "./schedule.service";
import { SchedulerDTO as DTO } from '@baekyangdan/core-utils';
import { HttpApiUrl } from "@baekyangdan/core-utils";

const ScheduleApi = HttpApiUrl.Schedule;

@UseGuards(JwtAccessAuthGuard)
@Controller(ScheduleApi.base)
export class ScheduleController {
  constructor(private readonly scheduleService: ScheduleService) {}

  @Post(ScheduleApi.getList)
  async getList(@Req() req, @Body() data: DTO.ScheduleListRequest): Promise<DTO.ScheduleListResponse> {
    const result = await this.scheduleService.getList(req.user.id, data);
    return result;
  }

  @Get(ScheduleApi.getDetail)
  async getDetail(@Param('id') id: string): Promise<DTO.ScheduleDetailResponse> {
    const result = await this.scheduleService.getDetail(id);
    return result;
  }

  @Post(ScheduleApi.create)
  async create(@Req() req, @Body() data: DTO.ScheduleCreateRequest): Promise<DTO.ScheduleCreateResponse> {
    const result = await this.scheduleService.create(req.user.id, data);
    return result;
  }
}