mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 21:08:12 +00:00
Initial commit of edr-passenger-api alpha version
This commit is contained in:
@@ -1,37 +1,21 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
Param,
|
||||
ParseUUIDPipe,
|
||||
Post,
|
||||
} from "@nestjs/common";
|
||||
import { ApiOperation, ApiTags } from "@nestjs/swagger";
|
||||
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';
|
||||
|
||||
import { CreateScheduleDto } from "./dto/create-schedule.dto";
|
||||
import { SchedulesService } from "./schedules.service";
|
||||
|
||||
@ApiTags("schedules")
|
||||
// @UseGuards(JwtAuthGuard) — TODO: integrate @edr/auth
|
||||
@Controller("schedules")
|
||||
@ApiTags('Schedule')
|
||||
@Controller('schedule')
|
||||
export class SchedulesController {
|
||||
constructor(private readonly schedulesService: SchedulesService) {}
|
||||
|
||||
@Post()
|
||||
@ApiOperation({ summary: "Publish a new train schedule" })
|
||||
create(@Body() dto: CreateScheduleDto) {
|
||||
return this.schedulesService.create(dto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({ summary: "List all schedules" })
|
||||
findAll() {
|
||||
return this.schedulesService.findAll();
|
||||
}
|
||||
|
||||
@Get(":id")
|
||||
@ApiOperation({ summary: "Get a schedule by ID" })
|
||||
findOne(@Param("id", ParseUUIDPipe) id: string) {
|
||||
return this.schedulesService.findById(id);
|
||||
}
|
||||
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'); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user