Skip to content

Commit

Permalink
Merge pull request #519 from ldhbenecia/feature/groups
Browse files Browse the repository at this point in the history
[Feat] 그룹 생성 시 그룹장, 그룹 타입 id 반환
  • Loading branch information
ldhbenecia authored Jan 31, 2024
2 parents be0b9dd + 0b34d96 commit 42e9ef8
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
5 changes: 4 additions & 1 deletion app/backend/src/groups/dto/create-groups.dto.ts
Original file line number Diff line number Diff line change
@@ -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;
}
4 changes: 2 additions & 2 deletions app/backend/src/groups/groups.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Group> {
return this.groupsService.createGroups(createGroupsDto);
async createGroups(@Body() createGroupsDto: CreateGroupsDto, @GetUser() member: Member): Promise<Group> {
return this.groupsService.createGroups(createGroupsDto, member);
}

@Post('/:id/join')
Expand Down
10 changes: 7 additions & 3 deletions app/backend/src/groups/groups.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,17 @@ export class GroupsRepository {
}));
}

async createGroups(createGroupsDto: CreateGroupsDto): Promise<Group> {
async createGroups(createGroupsDto: CreateGroupsDto, member: Member): Promise<Group> {
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) },
},
},
});

Expand Down
4 changes: 2 additions & 2 deletions app/backend/src/groups/groups.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export class GroupsService {
return this.groupsRepository.getAllMembersOfGroup(id);
}

async createGroups(createGroupsDto: CreateGroupsDto): Promise<Group> {
return this.groupsRepository.createGroups(createGroupsDto);
async createGroups(createGroupsDto: CreateGroupsDto, member: Member): Promise<Group> {
return this.groupsRepository.createGroups(createGroupsDto, member);
}

async joinGroup(id: number, member: Member): Promise<void> {
Expand Down
1 change: 1 addition & 0 deletions packages/apitype/dto/request/groups.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export interface RequestGroupsDto {
title: string;
groupTypeId: number;
}
4 changes: 3 additions & 1 deletion packages/apitype/dto/response/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 42e9ef8

Please sign in to comment.