From d604dcdc6cd8779c1d8cee1bd101eb208ae6aed9 Mon Sep 17 00:00:00 2001 From: ez <105545215+ezcolin2@users.noreply.github.com> Date: Thu, 14 Nov 2024 20:28:45 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=ED=8E=98=EC=9D=B4=EC=A7=80=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=EC=8B=9C=20page=20id=20=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/db | Bin 0 -> 36864 bytes .../src/page/dtos/createPageResponse.dto.ts | 18 ++++++++++++++++++ backend/src/page/page.controller.spec.ts | 12 +++++++++++- backend/src/page/page.controller.ts | 10 +++++++--- 4 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 backend/db create mode 100644 backend/src/page/dtos/createPageResponse.dto.ts diff --git a/backend/db b/backend/db new file mode 100644 index 0000000000000000000000000000000000000000..39523de47acb04e56b44cc06d3a121524e8ea2ea GIT binary patch literal 36864 zcmeI)&u`jh7zgmzkN{2-+)9gbedS3@thO13KuD`f^N2H{Qb-9*il&JfV`o$ePQmFC zO}pfWI;qF0(lqr@P2C~WPCISVF8dR5-gzgo99wDXVeiY229q>hl1o~Bk&Mmz`h9ud z&+}k|059ClR9%bOPJP92X^dPZfmZq||2T4K zp9De!Bpeq19VVfH;q~F%$ll1_3GGk?0SG_<0uX?}xdpbbh`}*M5gvZN9qeqSU8B5g zxz@_6v(;c_qocyZc9~UKviRal<#nx~(}MPKMyE0_lIet8t;n=mbFC$-PUrLKJ6e8` z-qshXRxISwS=Q!`o-NR9jxEJZ<{Fjly0bFxuqHBnVARboje2jb>zq)xvC5vZ(}?wC zI?GPIw}5wDsyP*_)H5o!qw5?~n#yGt3VAKfMkmkRE=@)3NMgp0Csd*-Ijt%*&vX7H**h354+J+Eg|`T~{tlXp}Un#)`^jrI*BZY1o88n?|v(kxpsGZC>9)A5LDs%HN{dggWBVJKTpupM=+ zl?kiHlEs&hH|o6TOi_2M?($*qdLwQ+EPHr1+-o>BPet7_T&tq7stVh1t1H&4Y6d%} z6*C1o(XE;ouQ^|hD+&wu+A1$RL&FDFy-{^)hY8)2wmh=w!(8`Au7AJ}5?f*`UHF*z67Z(W z_@$G&;|)qGzxQu`I@HR(9m&((ptn1|>zT4|U8eT3!#>gU1a#w=GCs8vgRCZ})Jj}U zm_{OI$L*LgQz=Iy$x1oi6XZ@WM}z$O)^>l8yM1_q%nMIV52=_XozVUKJKwG3jJO!@9p_)l94J;eaPneU%e6W5v40S}KGHPkGwx-1Hn} z`pzwEo|`U92zH9vdB3%zcVON}eM#c2M7p$2(f{*gq>S*Rz~ytl!9WKPfB*y_009U< z00Izz00bZa0SH`Rfgv_FpY(!AFQk_jc$gR(1Rwwb2tWV=5P$##AOHafKmY=#7Z~sp z!RPmj;)wJ&@k@I|`b#=sE8HLe0SG_<0uX=z1Rwwb2tWV=5O^B|LVo|K!2dVn3khtC z|AT~ozb}fsEa>x(hWH=(*i1x`*YV%~`=kT@{r|z+Fg=VB0uX=z1Rwwb2tWV=5P$## zAOL|k2?TwE{Q7?3a8TeIVmOTd|G&u$^$>sn1Rwwb2tWV=5P$##AOL}PMu1<-zkNZ_ zcVt{!u!aBxAOHafKmY;|fB*y_ z009U<;Pe8Y`9kDFEfy1mn$>V8?=|TD<}dp{>^6UWEc24)Pk+$;?PvSHfB(bk04SEs0|-iRh{MB~R4`Fyv85E;J`i;1MU^IP+~Cv^YmljhI6Uw?CC zZ#8yIQTzJ;&x!O>dVczup#=mW009U<00Izz00bZa0SG_<0vA_c&@Tu+cKv@M{s+d9 BxsLz< literal 0 HcmV?d00001 diff --git a/backend/src/page/dtos/createPageResponse.dto.ts b/backend/src/page/dtos/createPageResponse.dto.ts new file mode 100644 index 00000000..b03b6719 --- /dev/null +++ b/backend/src/page/dtos/createPageResponse.dto.ts @@ -0,0 +1,18 @@ +import { ApiProperty } from '@nestjs/swagger'; +import { IsInt, IsString } from 'class-validator'; + +export class CreatePageResponseDto { + @ApiProperty({ + example: 'OO 생성에 성공했습니다.', + description: 'api 요청 결과 메시지', + }) + @IsString() + message: string; + + @ApiProperty({ + example: 1, + description: '페이지의 PK', + }) + @IsInt() + pageId: number; +} diff --git a/backend/src/page/page.controller.spec.ts b/backend/src/page/page.controller.spec.ts index 7cb8af69..a1e16e1f 100644 --- a/backend/src/page/page.controller.spec.ts +++ b/backend/src/page/page.controller.spec.ts @@ -47,8 +47,18 @@ describe('PageController', () => { }; const expectedResponse = { message: PageResponseMessage.PAGE_CREATED, + pageId: 1, }; - + const newDate = new Date(); + jest.spyOn(pageService, 'createPage').mockResolvedValue({ + id: 1, + title: 'New Page', + content: {} as JSON, + createdAt: newDate, + updatedAt: newDate, + version: 1, + node: null, + }); const result = await controller.createPage(dto); expect(pageService.createPage).toHaveBeenCalledWith(dto); diff --git a/backend/src/page/page.controller.ts b/backend/src/page/page.controller.ts index 96ebdec6..aa32bdbb 100644 --- a/backend/src/page/page.controller.ts +++ b/backend/src/page/page.controller.ts @@ -17,6 +17,7 @@ import { ApiBody, ApiOperation, ApiResponse } from '@nestjs/swagger'; import { MessageResponseDto } from './dtos/messageResponse.dto'; import { FindPagesResponseDto } from './dtos/findPagesResponse.dto'; import { FindPageResponseDto } from './dtos/findPageResponse.dto'; +import { CreatePageResponseDto } from './dtos/createPageResponse.dto'; export enum PageResponseMessage { PAGE_CREATED = '페이지와 노드를 생성했습니다.', @@ -31,7 +32,7 @@ export class PageController { constructor(private readonly pageService: PageService) {} @ApiResponse({ - type: MessageResponseDto, + type: CreatePageResponseDto, }) @ApiOperation({ summary: '페이지를 생성하고 노드도 생성합니다.' }) @ApiBody({ @@ -40,10 +41,13 @@ export class PageController { }) @Post('/') @HttpCode(HttpStatus.CREATED) - async createPage(@Body() body: CreatePageDto): Promise { - await this.pageService.createPage(body); + async createPage( + @Body() body: CreatePageDto, + ): Promise { + const newPage = await this.pageService.createPage(body); return { message: PageResponseMessage.PAGE_CREATED, + pageId: newPage.id, }; } From ce4e3383b63a3b4d7461744ff963fcd62fcc47e5 Mon Sep 17 00:00:00 2001 From: ez <105545215+ezcolin2@users.noreply.github.com> Date: Thu, 14 Nov 2024 20:30:42 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix=20db=20=ED=8C=8C=EC=9D=BC=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/db | Bin 36864 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 backend/db diff --git a/backend/db b/backend/db deleted file mode 100644 index 39523de47acb04e56b44cc06d3a121524e8ea2ea..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 36864 zcmeI)&u`jh7zgmzkN{2-+)9gbedS3@thO13KuD`f^N2H{Qb-9*il&JfV`o$ePQmFC zO}pfWI;qF0(lqr@P2C~WPCISVF8dR5-gzgo99wDXVeiY229q>hl1o~Bk&Mmz`h9ud z&+}k|059ClR9%bOPJP92X^dPZfmZq||2T4K zp9De!Bpeq19VVfH;q~F%$ll1_3GGk?0SG_<0uX?}xdpbbh`}*M5gvZN9qeqSU8B5g zxz@_6v(;c_qocyZc9~UKviRal<#nx~(}MPKMyE0_lIet8t;n=mbFC$-PUrLKJ6e8` z-qshXRxISwS=Q!`o-NR9jxEJZ<{Fjly0bFxuqHBnVARboje2jb>zq)xvC5vZ(}?wC zI?GPIw}5wDsyP*_)H5o!qw5?~n#yGt3VAKfMkmkRE=@)3NMgp0Csd*-Ijt%*&vX7H**h354+J+Eg|`T~{tlXp}Un#)`^jrI*BZY1o88n?|v(kxpsGZC>9)A5LDs%HN{dggWBVJKTpupM=+ zl?kiHlEs&hH|o6TOi_2M?($*qdLwQ+EPHr1+-o>BPet7_T&tq7stVh1t1H&4Y6d%} z6*C1o(XE;ouQ^|hD+&wu+A1$RL&FDFy-{^)hY8)2wmh=w!(8`Au7AJ}5?f*`UHF*z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