import { Body, Controller, Get, Param, Patch, Post, Query, UseGuards } from '@nestjs/common'; import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger'; import { SchedulesService } from './schedules.service'; import { CreateTripDto, CreateFareRuleDto, UpdateTripStatusDto } from './schedules.dto'; import { JwtGuard } from '../../common/jwt.guard'; @ApiTags('Schedule') @Controller('schedule') export class SchedulesController { constructor(private service: SchedulesService) {} @Post('trips') @UseGuards(JwtGuard) @ApiBearerAuth('JWT-auth') @ApiOperation({ summary: 'Create trip' }) createTrip(@Body() dto: CreateTripDto) { return this.service.createTrip(dto); } @Get('trips/:id') @ApiOperation({ summary: 'Get trip details' }) getTrip(@Param('id') id: string) { return this.service.getTrip(id); } @Patch('trips/:id/status') @UseGuards(JwtGuard) @ApiBearerAuth('JWT-auth') @ApiOperation({ summary: 'Update trip status' }) updateStatus(@Param('id') id: string, @Body() dto: UpdateTripStatusDto) { return this.service.updateTripStatus(id, dto); } @Post('fares') @UseGuards(JwtGuard) @ApiBearerAuth('JWT-auth') @ApiOperation({ summary: 'Create fare rule' }) createFareRule(@Body() dto: CreateFareRuleDto) { return this.service.createFareRule(dto); } @Get('fares/:tripId') @ApiOperation({ summary: 'Get fare for trip and class' }) getFare(@Param('tripId') tripId: string, @Query('class') cls: string) { return this.service.getFare(tripId, cls ?? 'ECONOMY'); } }