Skip to content

Commit bd2ee08

Browse files
fix: 워크스페이스들 가져오기 수정
1 parent d48bbc7 commit bd2ee08

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

apps/backend/src/workspace/dtos/getUserWorkspacesResponse.dto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ApiProperty } from '@nestjs/swagger';
22
import { IsString, IsArray } from 'class-validator';
33
import { UserWorkspaceDto } from './userWorkspace.dto';
44

5-
export class getUserWorkspacesResponseDto {
5+
export class GetUserWorkspacesResponseDto {
66
@ApiProperty({
77
example: 'OO 생성에 성공했습니다.',
88
description: 'api 요청 결과 메시지',

apps/backend/src/workspace/workspace.controller.ts

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ import { MessageResponseDto } from './dtos/messageResponse.dto';
1717
import { CreateWorkspaceDto } from './dtos/createWorkspace.dto';
1818
import { UserWorkspaceDto } from './dtos/userWorkspace.dto';
1919
import { CreateWorkspaceResponseDto } from './dtos/createWorkspaceResponse.dto';
20+
import { GetUserWorkspacesResponseDto } from './dtos/getUserWorkspacesResponse.dto';
2021

2122
export enum WorkspaceResponseMessage {
2223
WORKSPACE_CREATED = '워크스페이스를 생성했습니다.',
2324
WORKSPACE_DELETED = '워크스페이스를 삭제했습니다.',
2425
WORKSPACES_RETURNED = '사용자가 참여하고 있는 모든 워크스페이스들을 가져왔습니다',
26+
WORKSPACE_INVITED = '워크스페이스 게스트 초대 링크가 생성되었습니다',
2527
}
2628

2729
@Controller('workspace')
@@ -73,15 +75,39 @@ export class WorkspaceController {
7375
};
7476
}
7577

76-
@ApiResponse({ status: HttpStatus.OK, type: [UserWorkspaceDto] })
78+
@ApiResponse({ type: GetUserWorkspacesResponseDto })
7779
@ApiOperation({
7880
summary: '사용자가 참여 중인 워크스페이스 목록을 가져옵니다.',
7981
})
8082
@UseGuards(JwtAuthGuard)
8183
@Get('/user')
8284
@HttpCode(HttpStatus.OK)
83-
async getUserWorkspaces(@Request() req): Promise<UserWorkspaceDto[]> {
85+
async getUserWorkspaces(@Request() req) {
8486
const userId = req.user.sub; // 인증된 사용자의 ID
85-
return await this.workspaceService.getUserWorkspaces(userId);
87+
const workspaces = this.workspaceService.getUserWorkspaces(userId);
88+
return {
89+
message: WorkspaceResponseMessage.WORKSPACES_RETURNED,
90+
workspaces,
91+
};
92+
}
93+
94+
// TODO: 후에 역할 나눠서 초대링크 만들 수 있게 확장
95+
@Post('/:id/invite')
96+
@UseGuards(JwtAuthGuard) // 로그인 인증
97+
@HttpCode(HttpStatus.CREATED)
98+
async generateInviteLink(
99+
@Request() req,
100+
@Param('workspaceId') workspaceId: string,
101+
) {
102+
const userId = req.user.sub; // 인증된 사용자 ID
103+
const inviteUrl = await this.workspaceService.generateInviteToken(
104+
userId,
105+
id,
106+
);
107+
108+
return {
109+
message: '초대 URL이 생성되었습니다.',
110+
inviteUrl,
111+
};
86112
}
87113
}

0 commit comments

Comments
 (0)