54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
import { Controller, Post, Get, Body, Param, Query } from '@nestjs/common';
|
|
import { TransitService } from './transit.service';
|
|
import { CreateRouteDto, CreateStationDto, CreateSupervisorDto, StartTripDto, BuyTicketDto } from './dto/transit.dto';
|
|
|
|
@Controller('transit')
|
|
export class TransitController {
|
|
constructor(private readonly transitService: TransitService) {}
|
|
|
|
@Post('routes')
|
|
createRoute(@Body() dto: CreateRouteDto) {
|
|
return this.transitService.createRoute(dto);
|
|
}
|
|
|
|
@Get('routes')
|
|
getRoutes(@Query('tenant_id') tenant_id: string) {
|
|
return this.transitService.getRoutes(tenant_id);
|
|
}
|
|
|
|
@Post('stations')
|
|
createStation(@Body() dto: CreateStationDto) {
|
|
return this.transitService.createStation(dto);
|
|
}
|
|
|
|
@Get('routes/:routeId/stations')
|
|
getStations(@Param('routeId') routeId: string) {
|
|
return this.transitService.getStations(routeId);
|
|
}
|
|
|
|
@Post('supervisors')
|
|
assignSupervisor(@Body() dto: CreateSupervisorDto) {
|
|
return this.transitService.assignSupervisor(dto);
|
|
}
|
|
|
|
@Get('reports/supervisor/:userId')
|
|
getSupervisorReports(@Param('userId') userId: string) {
|
|
return this.transitService.getSupervisorReports(userId);
|
|
}
|
|
|
|
@Post('trips/start')
|
|
startTrip(@Body() dto: StartTripDto) {
|
|
return this.transitService.startTrip(dto);
|
|
}
|
|
|
|
@Post('trips/:id/end')
|
|
endTrip(@Param('id') id: string) {
|
|
return this.transitService.endTrip(id);
|
|
}
|
|
|
|
@Post('tickets/buy')
|
|
buyTicket(@Body() dto: BuyTicketDto) {
|
|
return this.transitService.buyTicket(dto);
|
|
}
|
|
}
|