From 6b15bf1a3ff63c91b9bd71a5bad2a3a6ed41f6a6 Mon Sep 17 00:00:00 2001 From: DongHyeok Lim Date: Mon, 29 Jan 2024 18:19:00 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=A8=20groupTypeId=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=EC=82=AC=ED=95=AD=20dto=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/backend/src/groups/dto/create-groups.dto.ts | 5 ++++- packages/apitype/dto/request/groups.ts | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/backend/src/groups/dto/create-groups.dto.ts b/app/backend/src/groups/dto/create-groups.dto.ts index a57f9778f..1982c4504 100644 --- a/app/backend/src/groups/dto/create-groups.dto.ts +++ b/app/backend/src/groups/dto/create-groups.dto.ts @@ -1,9 +1,12 @@ import { RequestGroupsDto } from '@morak/apitype/dto/request/groups'; -import { IsNotEmpty } from 'class-validator'; +import { IsInt, IsNotEmpty } from 'class-validator'; import { ApiProperty } from '@nestjs/swagger'; export class CreateGroupsDto implements RequestGroupsDto { @ApiProperty({ description: 'Title of the Group', example: '부스트캠프 웹·모바일 8기' }) @IsNotEmpty() title: string; + + @IsInt() + groupTypeId: number; } diff --git a/packages/apitype/dto/request/groups.ts b/packages/apitype/dto/request/groups.ts index 0366dc247..97b7c95af 100644 --- a/packages/apitype/dto/request/groups.ts +++ b/packages/apitype/dto/request/groups.ts @@ -1,3 +1,4 @@ export interface RequestGroupsDto { title: string; + groupTypeId: number; } From 3978e6ba40ca293c2432a2e62b4809a01b1dc937 Mon Sep 17 00:00:00 2001 From: DongHyeok Lim Date: Mon, 29 Jan 2024 18:20:37 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=E2=9C=A8=20=EA=B7=B8=EB=A3=B9=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EC=8B=9C=20=EA=B7=B8=EB=A3=B9=EC=9E=A5=EA=B3=BC=20?= =?UTF-8?q?=EA=B7=B8=EB=A3=B9=20=ED=83=80=EC=9E=85=EC=9D=98=20id=EB=A5=BC?= =?UTF-8?q?=20=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/backend/src/groups/groups.controller.ts | 4 ++-- app/backend/src/groups/groups.repository.ts | 10 +++++++--- app/backend/src/groups/groups.service.ts | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/backend/src/groups/groups.controller.ts b/app/backend/src/groups/groups.controller.ts index fe1bbfc48..c634c52c4 100644 --- a/app/backend/src/groups/groups.controller.ts +++ b/app/backend/src/groups/groups.controller.ts @@ -58,8 +58,8 @@ export class GroupsController { @ApiBody({ type: CreateGroupsDto }) @ApiResponse({ status: 201, description: 'Successfully created', type: CreateGroupsDto }) @ApiResponse({ status: 401, description: 'Unauthorized' }) - async createGroups(@Body() createGroupsDto: CreateGroupsDto): Promise { - return this.groupsService.createGroups(createGroupsDto); + async createGroups(@Body() createGroupsDto: CreateGroupsDto, @GetUser() member: Member): Promise { + return this.groupsService.createGroups(createGroupsDto, member); } @Post('/:id/join') diff --git a/app/backend/src/groups/groups.repository.ts b/app/backend/src/groups/groups.repository.ts index 9740e59c7..b5c92cecf 100644 --- a/app/backend/src/groups/groups.repository.ts +++ b/app/backend/src/groups/groups.repository.ts @@ -60,13 +60,17 @@ export class GroupsRepository { })); } - async createGroups(createGroupsDto: CreateGroupsDto): Promise { + async createGroups(createGroupsDto: CreateGroupsDto, member: Member): Promise { try { - const { title } = createGroupsDto; + const { title, groupTypeId } = createGroupsDto; const group = await this.prisma.group.create({ data: { - title, + title: title, + groupTypeId: groupTypeId, + member: { + connect: { id: Number(member.id) }, + }, }, }); diff --git a/app/backend/src/groups/groups.service.ts b/app/backend/src/groups/groups.service.ts index deb41ae17..afad00328 100644 --- a/app/backend/src/groups/groups.service.ts +++ b/app/backend/src/groups/groups.service.ts @@ -20,8 +20,8 @@ export class GroupsService { return this.groupsRepository.getAllMembersOfGroup(id); } - async createGroups(createGroupsDto: CreateGroupsDto): Promise { - return this.groupsRepository.createGroups(createGroupsDto); + async createGroups(createGroupsDto: CreateGroupsDto, member: Member): Promise { + return this.groupsRepository.createGroups(createGroupsDto, member); } async joinGroup(id: number, member: Member): Promise { From 0b34d96d94de9fea3caadf875b669ee3cb979f53 Mon Sep 17 00:00:00 2001 From: DongHyeok Lim Date: Mon, 29 Jan 2024 18:22:44 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=E2=9C=A8=20group=20response=20=EA=B3=B5?= =?UTF-8?q?=ED=86=B5=20dto=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/apitype/dto/response/groups.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/apitype/dto/response/groups.ts b/packages/apitype/dto/response/groups.ts index f325d2b16..3f589c42e 100644 --- a/packages/apitype/dto/response/groups.ts +++ b/packages/apitype/dto/response/groups.ts @@ -3,10 +3,12 @@ import { Bigint } from "../type"; export interface ResponseGroupsDto { id: Bigint; title: string; + groupOwnerId: Bigint; + groupTypeId: number; } export interface ResponseGroupsWithMemberCountDto { id: Bigint; title: string; memberCount: number; -} \ No newline at end of file +}