From 6196cb41c257b3aa9a429264b67211b104f3d3d9 Mon Sep 17 00:00:00 2001 From: DongHyeok Lim Date: Wed, 22 Nov 2023 21:37:09 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Swagger=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/backend/src/member/dto/member.dto.ts | 4 +- app/backend/src/member/member.controller.ts | 3 +- .../src/mogaco/dto/create-mogaco.dto.ts | 8 ++++ app/backend/src/mogaco/dto/mogaco.dto.ts | 22 ++++++++++ .../src/mogaco/dto/response-mogaco.dto.ts | 40 +++++++++++++++++++ .../mogaco/dto/response-participants.dto.ts | 18 +++++++++ 6 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 app/backend/src/mogaco/dto/response-mogaco.dto.ts create mode 100644 app/backend/src/mogaco/dto/response-participants.dto.ts diff --git a/app/backend/src/member/dto/member.dto.ts b/app/backend/src/member/dto/member.dto.ts index 339fecfe0..92d6c2d45 100644 --- a/app/backend/src/member/dto/member.dto.ts +++ b/app/backend/src/member/dto/member.dto.ts @@ -4,10 +4,10 @@ export class MemberDto { @ApiProperty({ description: 'Provider ID of the user', example: '123456' }) providerId: string; - @ApiProperty({ description: 'Email address of the user', example: 'user@example.com' }) + @ApiProperty({ description: 'Email address of the user', example: 'bcwm.morak@gmail.com' }) email: string; - @ApiProperty({ description: 'Nickname of the user', example: 'john_doe' }) + @ApiProperty({ description: 'Nickname of the user', example: 'morak morak' }) nickname: string; @ApiProperty({ description: "URL of the user's profile picture", example: 'https://example.com/profile.jpg' }) diff --git a/app/backend/src/member/member.controller.ts b/app/backend/src/member/member.controller.ts index b06dcf434..72fc4064e 100644 --- a/app/backend/src/member/member.controller.ts +++ b/app/backend/src/member/member.controller.ts @@ -1,9 +1,10 @@ import { Controller, Get, Req, Res, UnauthorizedException } from '@nestjs/common'; import { MemberService } from './member.service'; -import { ApiOperation, ApiResponse } from '@nestjs/swagger'; +import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; import { Request, Response } from 'express'; import { MemberDto } from './dto/member.dto'; +@ApiTags('Member Infomation API') @Controller('member') export class MemberController { constructor(private readonly memberService: MemberService) {} diff --git a/app/backend/src/mogaco/dto/create-mogaco.dto.ts b/app/backend/src/mogaco/dto/create-mogaco.dto.ts index 5ab22daf1..cc607737b 100644 --- a/app/backend/src/mogaco/dto/create-mogaco.dto.ts +++ b/app/backend/src/mogaco/dto/create-mogaco.dto.ts @@ -1,27 +1,35 @@ import { IsDateString, IsEnum, IsInt, IsNotEmpty, IsOptional } from 'class-validator'; import { MogacoStatus } from './mogaco-status.enum'; +import { ApiProperty } from '@nestjs/swagger'; export class CreateMogacoDto { + @ApiProperty({ description: 'Group ID', example: '1' }) @IsNotEmpty() @IsInt() groupId: number; + @ApiProperty({ description: 'Title of the Mogaco', example: '사당역 모각코' }) @IsNotEmpty() title: string; + @ApiProperty({ description: 'Contents of the Mogaco', example: '사당역에서 모각코를 열려고 합니다.' }) @IsNotEmpty() contents: string; + @ApiProperty({ description: 'Date of the Mogaco', example: '2023-11-25T12:00:00.000Z' }) @IsNotEmpty() @IsDateString() date: string; + @ApiProperty({ description: 'Maximum number of participants', example: 5 }) @IsNotEmpty() maxHumanCount: number; + @ApiProperty({ description: 'Address of the Mogaco', example: '서울특별시 관악구 어디길 22 모락 카페' }) @IsNotEmpty() address: string; + @ApiProperty({ description: 'Status of the Mogaco', example: '모집 중' }) @IsOptional() @IsEnum(MogacoStatus, { message: 'Invalid status' }) status?: string; diff --git a/app/backend/src/mogaco/dto/mogaco.dto.ts b/app/backend/src/mogaco/dto/mogaco.dto.ts index a43e5b306..f68b6e6d6 100644 --- a/app/backend/src/mogaco/dto/mogaco.dto.ts +++ b/app/backend/src/mogaco/dto/mogaco.dto.ts @@ -1,10 +1,32 @@ +import { ApiProperty } from '@nestjs/swagger'; + export class MogacoDto { + @ApiProperty({ description: 'ID of the Mogaco', example: 1 }) id: bigint; + + @ApiProperty({ description: 'Group ID', example: 1 }) groupId: bigint; + + @ApiProperty({ description: 'Title of the Mogaco', example: '사당역 모각코' }) title: string; + + @ApiProperty({ description: 'Contents of the Mogaco', example: '사당역에서 모각코를 열려고 합니다.' }) contents: string; + + @ApiProperty({ description: 'Date of the Mogaco', example: '2023-11-22T12:00:00Z' }) date: Date; + + @ApiProperty({ description: 'Maximum number of participants', example: 5 }) maxHumanCount: number; + + @ApiProperty({ description: 'Address of the Mogaco', example: '서울특별시 관악구 어디길 22 모락 카페' }) address: string; + + @ApiProperty({ description: 'Status of the Mogaco', example: '모집 중' }) + status: string; +} + +export class StatusDto { + @ApiProperty({ description: 'Status of the Mogaco', example: '모집 마감' }) status: string; } diff --git a/app/backend/src/mogaco/dto/response-mogaco.dto.ts b/app/backend/src/mogaco/dto/response-mogaco.dto.ts new file mode 100644 index 000000000..f0a795b93 --- /dev/null +++ b/app/backend/src/mogaco/dto/response-mogaco.dto.ts @@ -0,0 +1,40 @@ +import { ApiProperty } from '@nestjs/swagger'; +import { MemberDto } from 'src/member/dto/member.dto'; + +export class MogacoWithMemberDto { + @ApiProperty({ description: 'ID of the Mogaco', example: '3' }) + id: string; + + @ApiProperty({ description: 'Group ID', example: '1' }) + groupId: string; + + @ApiProperty({ description: 'Title of the Mogaco', example: '사당역 모각코' }) + title: string; + + @ApiProperty({ description: 'Contents of the Mogaco', example: '사당역에서 모각코를 열려고 합니다.' }) + contents: string; + + @ApiProperty({ description: 'Date of the Mogaco', example: '2023-11-25T12:00:00.000Z' }) + date: string; + + @ApiProperty({ description: 'Maximum number of participants', example: 5 }) + maxHumanCount: number; + + @ApiProperty({ description: 'Address of the Mogaco', example: '서울특별시 관악구 어디길 22 모락 카페' }) + address: string; + + @ApiProperty({ description: 'Status of the Mogaco', example: '모집 마감' }) + status: string; + + @ApiProperty({ description: 'Date of Mogaco creation', example: '2023-11-22T12:16:08.913Z' }) + createdAt: string; + + @ApiProperty({ description: 'Date of Mogaco update', example: '2023-11-22T12:16:08.913Z' }) + updatedAt: string; + + @ApiProperty({ description: 'Date of Mogaco deletion', example: null }) + deletedAt: string | null; + + @ApiProperty({ description: 'Member information', type: MemberDto }) + member: MemberDto; +} diff --git a/app/backend/src/mogaco/dto/response-participants.dto.ts b/app/backend/src/mogaco/dto/response-participants.dto.ts new file mode 100644 index 000000000..02a64e0fb --- /dev/null +++ b/app/backend/src/mogaco/dto/response-participants.dto.ts @@ -0,0 +1,18 @@ +import { ApiProperty } from '@nestjs/swagger'; + +export class ParticipantResponseDto { + @ApiProperty({ description: 'ID of the Member', example: '1' }) + id: string; + + @ApiProperty({ description: 'Provider ID', example: '117187214221556274884' }) + providerId: string; + + @ApiProperty({ description: 'Email of the Member', example: 'bcwm.morak@gmail.com' }) + email: string; + + @ApiProperty({ description: 'Social Type', example: 'google' }) + socialType: string; + + @ApiProperty({ description: 'Date of Member creation', example: '2023-11-22T04:55:02.988Z' }) + createdAt: string; +}