All files / subway subway.controller.ts

100% Statements 20/20
100% Branches 0/0
100% Functions 4/4
100% Lines 18/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 734x 4x 4x 4x 4x 4x 4x 4x 4x 4x       4x 16x                     4x 1x                                 4x     2x                                   4x         2x      
import { Controller, Get, HttpStatus, Param, Query } from '@nestjs/common';
import { ApiOperation, ApiParam, ApiTags } from '@nestjs/swagger';
import { ERROR } from 'src/commons/constants/error';
import { ApiExceptionResponse } from 'src/commons/decorators/api-exception-response.decorator';
import { ApiSuccessResponse } from 'src/commons/decorators/api-success-response.decorator';
import { ApiSubwayGetCheckRequestQueryDto } from 'src/subway/dto/api-subway-get-check-request-query.dto';
import { ApiSubwayGetCheckResponseDto } from 'src/subway/dto/api-subway-get-check-response.dto';
import { ApiSubwayGetLineResponseDto } from 'src/subway/dto/api-subway-get-line-response.dto';
import { ApiSubwayGetListResponseDto } from 'src/subway/dto/api-subway-get-list-response.dto';
import { SubwayService } from 'src/subway/subway.service';
 
@ApiTags('지하철')
@Controller('/api/subway')
export class SubwayController {
  constructor(private readonly subwayService: SubwayService) {}
 
  @Get('/line')
  @ApiOperation({
    summary: '지하철 호선 리스트',
    description: '지하철 호선 리스트',
  })
  @ApiSuccessResponse(ApiSubwayGetLineResponseDto, {
    description: '지하철 역 호선 조회 성공',
    status: HttpStatus.OK,
  })
  async subwayLineList(): Promise<ApiSubwayGetLineResponseDto> {
    return this.subwayService.subwayLineList();
  }
 
  @Get('/:line_uuid')
  @ApiOperation({
    summary: '지하철 호선 별 역 리스트 조회',
    description: '지하철 호선 별 역 리스트 조회',
  })
  @ApiSuccessResponse(ApiSubwayGetListResponseDto, {
    description: '지하철 역 리스트 조회 성공',
    status: HttpStatus.OK,
  })
  @ApiExceptionResponse([ERROR.NOT_EXIST_DATA], {
    description: '조회한 지하철역 호선이 없는 경우',
    status: HttpStatus.NOT_FOUND,
  })
  @ApiParam({ name: 'line_uuid', type: 'string', description: '지하철 호선 uuid' })
  async subwayStationList(
    @Param('line_uuid') lineUuid: string,
  ): Promise<ApiSubwayGetListResponseDto> {
    return this.subwayService.subwayStationList(lineUuid);
  }
 
  @Get('/:line_uuid/:station_uuid/customs-check')
  @ApiOperation({
    summary: '지하철 역 커스텀 체크',
    description: '지하철 역 커스텀 체크',
  })
  @ApiSuccessResponse(ApiSubwayGetCheckResponseDto, {
    description: '지하철 역 커스텀 체크 성공',
    status: HttpStatus.OK,
  })
  @ApiExceptionResponse([ERROR.NOT_EXIST_DATA], {
    description: '코스 uuid가 존재하지 않을 경우',
    status: HttpStatus.NOT_FOUND,
  })
  @ApiParam({ name: 'line_uuid', type: 'string', description: '지하철 호선 uuid' })
  @ApiParam({ name: 'station_uuid', type: 'string', description: '지하철 역 uuid' })
  async subwayCustomsCheck(
    @Param('line_uuid') lineUuid: string,
    @Param('station_uuid') stationUuid: string,
    @Query() dto: ApiSubwayGetCheckRequestQueryDto,
  ): Promise<ApiSubwayGetCheckResponseDto> {
    return this.subwayService.subwayCustomsCheck(lineUuid, stationUuid, dto);
  }
}