Skip to content

Commit

Permalink
📝 add bearerAuth on Controller and add return bundle failed response …
Browse files Browse the repository at this point in the history
…dto #114

add bearerAuth on Controller and add return bundle failed response dto #114
  • Loading branch information
sichoi42 committed Nov 6, 2022
1 parent 187faa3 commit 1676933
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
7 changes: 6 additions & 1 deletion backend/src/v3/lent/lent.controller.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { Controller, Get, HttpCode, HttpException, HttpStatus, InternalServerErrorException, Logger, Param, ParseIntPipe, Post, UseGuards } from '@nestjs/common';
import { ApiBadRequestResponse, ApiConflictResponse, ApiCreatedResponse, ApiForbiddenResponse, ApiNotFoundResponse, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiBadRequestResponse, ApiBearerAuth, ApiConflictResponse, ApiCreatedResponse, ApiForbiddenResponse, ApiNotFoundResponse, ApiOperation, ApiResponse, ApiTags, ApiUnauthorizedResponse } from '@nestjs/swagger';
import { JWTAuthGuard } from 'src/auth/auth.guard';
import { LentService } from './lent.service';

@ApiTags('(V3) Lent')
@ApiTags('(V3) Return')
@ApiBearerAuth()
@ApiUnauthorizedResponse({
description: '로그아웃 상태',
})
@Controller({
version: '3',
path: 'lent',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { ApiProperty } from "@nestjs/swagger";

export class ReturnBundleFailedResponseDto {
@ApiProperty({
description: '처리에 실패한 user_id 배열',
example: [1000000000, -5],
required: false,
})
user_failures?: number[];

@ApiProperty({
description: '처리에 실패한 cabinet_id 배열',
example: [1000000000, -4],
required: false,
})
cabinet_failures?: number[];
}
4 changes: 2 additions & 2 deletions backend/src/v3/return/dto/return.bundle.data.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { ApiProperty } from "@nestjs/swagger";
export class ReturnBundleDataDto {
@ApiProperty({
description: 'user_id 배열',
default: [],
example: [85330, 110804, 110819, 1000000000, -5],
required: false,
})
users: number[];

@ApiProperty({
description: 'cabinet_id 배열',
default: [],
example: [1, 2, 3, 1000000000, -4],
required: false,
})
cabinets: number[];
Expand Down
11 changes: 8 additions & 3 deletions backend/src/v3/return/return.controller.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { Body, Controller, Delete, HttpCode, HttpException, HttpStatus, InternalServerErrorException, Logger, Param, ParseArrayPipe, ParseIntPipe, UseGuards } from '@nestjs/common';
import { ApiBadRequestResponse, ApiBody, ApiNoContentResponse, ApiNotFoundResponse, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiBadRequestResponse, ApiBearerAuth, ApiBody, ApiNoContentResponse, ApiNotFoundResponse, ApiOperation, ApiResponse, ApiTags, ApiUnauthorizedResponse } from '@nestjs/swagger';
import { JWTAuthGuard } from 'src/auth/auth.guard';
import { ReturnBundleFailedResponseDto } from './dto/response/return.bundle.failed.response.dto';
import { ReturnBundleDataDto } from './dto/return.bundle.data.dto';
import { ReturnService } from './return.service';

@ApiTags('(V3) Return')
@ApiBearerAuth()
@ApiUnauthorizedResponse({
description: '로그아웃 상태',
})
@Controller({
version: '3',
path: 'return',
Expand Down Expand Up @@ -87,8 +92,8 @@ export class ReturnController {
description: '모든 요청에 대해 반납에 성공 시, 204 No Content를 응답합니다.',
})
@ApiBadRequestResponse({
description:
`대여중인 사물함이 없는 유저가 있거나 대여중인 유저가 없는 사물함이 있는 경우, 400 Bad Request를 응답합니다.
type: ReturnBundleFailedResponseDto,
description: `대여중인 사물함이 없는 유저가 있거나 대여중인 유저가 없는 사물함이 있는 경우, 400 Bad Request를 응답합니다.
이때 response body로 처리에 실패한 user_id나 cabinet_id의 배열을 전달합니다.`,
})
@ApiBody({ type: ReturnBundleDataDto })
Expand Down

0 comments on commit 1676933

Please sign in to comment.