@@ -17,11 +17,13 @@ import { MessageResponseDto } from './dtos/messageResponse.dto';
1717import { CreateWorkspaceDto } from './dtos/createWorkspace.dto' ;
1818import { UserWorkspaceDto } from './dtos/userWorkspace.dto' ;
1919import { CreateWorkspaceResponseDto } from './dtos/createWorkspaceResponse.dto' ;
20+ import { GetUserWorkspacesResponseDto } from './dtos/getUserWorkspacesResponse.dto' ;
2021
2122export 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