@@ -14,6 +14,9 @@ import { PageService } from './page.service';
1414import { CreatePageDto } from './dtos/createPage.dto' ;
1515import { UpdatePageDto } from './dtos/updatePage.dto' ;
1616import { ApiBody , ApiOperation , ApiResponse } from '@nestjs/swagger' ;
17+ import { MessageResponseDto } from './dtos/messageResponse.dto' ;
18+ import { FindPagesResponseDto } from './dtos/findPagesResponse.dto' ;
19+ import { FindPageResponseDto } from './dtos/findPageResponse.dto' ;
1720
1821export enum PageResponseMessage {
1922 PAGE_CREATED = '페이지와 노드를 생성했습니다.' ,
@@ -26,60 +29,74 @@ export enum PageResponseMessage {
2629@Controller ( 'page' )
2730export class PageController {
2831 constructor ( private readonly pageService : PageService ) { }
29-
32+ @ApiResponse ( {
33+ type : MessageResponseDto ,
34+ } )
3035 @ApiOperation ( { summary : '페이지를 생성하고 노드도 생성합니다.' } )
3136 @ApiBody ( {
3237 description : 'post' ,
3338 type : CreatePageDto ,
3439 } )
3540 @Post ( '/' )
3641 @HttpCode ( HttpStatus . CREATED )
37- async createPage ( @Body ( ) body : CreatePageDto ) : Promise < { message : string } > {
42+ async createPage ( @Body ( ) body : CreatePageDto ) : Promise < MessageResponseDto > {
3843 await this . pageService . createPage ( body ) ;
3944 return {
4045 message : PageResponseMessage . PAGE_CREATED ,
4146 } ;
4247 }
4348
49+ @ApiResponse ( {
50+ type : MessageResponseDto ,
51+ } )
4452 @ApiOperation ( {
4553 summary : '페이지를 삭제하고 노드도 삭제합니다. (cascade delete)' ,
4654 } )
4755 @Delete ( '/:id' )
4856 @HttpCode ( HttpStatus . OK )
49- async deletePage ( @Param ( 'id' ) id : number ) : Promise < { message : string } > {
57+ async deletePage ( @Param ( 'id' ) id : number ) : Promise < MessageResponseDto > {
5058 await this . pageService . deletePage ( id ) ;
5159 return {
5260 message : PageResponseMessage . PAGE_DELETED ,
5361 } ;
5462 }
63+
64+ @ApiResponse ( {
65+ type : MessageResponseDto ,
66+ } )
5567 @ApiOperation ( { summary : '페이지 제목, 내용을 수정합니다.' } )
5668 @Patch ( '/:id' )
5769 @HttpCode ( HttpStatus . OK )
5870 async updatePage (
5971 @Param ( 'id' ) id : number ,
6072 @Body ( ) body : UpdatePageDto ,
61- ) : Promise < { message : string } > {
73+ ) : Promise < MessageResponseDto > {
6274 await this . pageService . updatePage ( id , body ) ;
6375 return {
6476 message : PageResponseMessage . PAGE_UPDATED ,
6577 } ;
6678 }
6779
80+ @ApiResponse ( {
81+ type : FindPagesResponseDto ,
82+ } )
6883 @ApiOperation ( { summary : '모든 페이지를 가져옵니다.' } )
6984 @Get ( )
7085 @HttpCode ( HttpStatus . OK )
71- async findPages ( ) : Promise < { message : string ; pages : Partial < Page > [ ] } > {
86+ async findPages ( ) : Promise < FindPagesResponseDto > {
7287 return {
7388 message : PageResponseMessage . PAGE_LIST_RETURNED ,
7489 pages : await this . pageService . findPages ( ) ,
7590 } ;
7691 }
92+
93+ @ApiResponse ( {
94+ type : FindPageResponseDto ,
95+ } )
7796 @ApiOperation ( { summary : '특정 페이지를 가져옵니다.' } )
7897 @Get ( '/:id' )
7998 @HttpCode ( HttpStatus . OK )
80- async findPage (
81- @Param ( 'id' ) id : number ,
82- ) : Promise < { message : string ; page : Page } > {
99+ async findPage ( @Param ( 'id' ) id : number ) : Promise < FindPageResponseDto > {
83100 return {
84101 message : PageResponseMessage . PAGE_RETURNED ,
85102 page : await this . pageService . findPageById ( id ) ,
0 commit comments