import { Body, Controller, Get, Param, Post, Patch, Delete, UseGuards, Query } from '@nestjs/common'; import { ApiTags, ApiOperation, ApiBearerAuth, ApiQuery } from '@nestjs/swagger'; import { StationsService } from './stations.service'; import { CreateStationDto } from './stations.dto'; import { JwtGuard } from '../../common/jwt.guard'; @ApiTags('Stations') @Controller('stations') export class StationsController { constructor(private service: StationsService) {} @Get() @ApiOperation({ summary: 'List all stations with country information', description: 'Returns all stations on the Ethio-Djibouti Railway with country codes (ET for Ethiopia, DJ for Djibouti)' }) @ApiQuery({ name: 'search', required: false, description: 'Search by station name or code' }) @ApiQuery({ name: 'country', required: false, description: 'Filter by country code (ET, DJ)' }) @ApiQuery({ name: 'operational', required: false, description: 'Filter by operational status (true, false)' }) findAll( @Query('search') search?: string, @Query('country') country?: string, @Query('operational') operational?: string, ) { return this.service.findAll({ search, country, operational }); } @Get(':id') @ApiOperation({ summary: 'Get station details by ID', description: 'Returns station information including name, code, country, coordinates, and facilities' }) findOne(@Param('id') id: string) { return this.service.findOne(id); } @Post() @UseGuards(JwtGuard) @ApiBearerAuth('JWT-auth') @ApiOperation({ summary: 'Create new station' }) create(@Body() dto: CreateStationDto) { return this.service.create(dto); } @Patch(':id') @UseGuards(JwtGuard) @ApiBearerAuth('JWT-auth') @ApiOperation({ summary: 'Update station' }) update(@Param('id') id: string, @Body() dto: Partial) { return this.service.update(id, dto); } @Delete(':id') @UseGuards(JwtGuard) @ApiBearerAuth('JWT-auth') @ApiOperation({ summary: 'Delete station' }) remove(@Param('id') id: string) { return this.service.remove(id); } }