-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feat] 프로젝트 관련 API 구현 #63
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
eeaf845
fix: 유저 생성 dto 검증 추가
jjeonghak 586a3b3
feat: 프로젝트 생성 API 구현
jjeonghak 4e84d0a
chore: 엔티티 타임 스탬프 설정
jjeonghak 1916f18
feat: 프로젝트 목록 조회 API 구현
jjeonghak 8ebacfd
feat: 프로젝트 멤버 초대 API 구현
jjeonghak 13a08b3
feat: 프로젝트 멤버 조회 API 구현
jjeonghak c173cb0
fix: username 이메일 형식 제거
jjeonghak 031f472
fix: 프로젝트 생성 기능 트랜잭션 적용
jjeonghak f657a78
feat: 프로젝트 초대 승인/거절 API 구현
jjeonghak 391a0b4
feat: 프로젝트 초대 목록 조회 API 구현
jjeonghak d0d43de
fix: 프로젝트 목록 조회 응답 데이터 수정
jjeonghak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { CreateDateColumn, UpdateDateColumn } from 'typeorm'; | ||
|
||
export class EntityTimestamp { | ||
@CreateDateColumn() | ||
createdAt: Date; | ||
|
||
@UpdateDateColumn() | ||
updatedAt: Date; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Body, Controller, Get, Param, Patch, Post, UseGuards } from '@nestjs/common'; | ||
import { ProjectService } from '../service/project.service'; | ||
import { AccessTokenGuard } from '@/account/guard/accessToken.guard'; | ||
import { CreateProjectRequest } from '../dto/create-project-request.dto'; | ||
import { AuthUser } from '@/account/decorator/authUser.decorator'; | ||
import { Account } from '@/account/entity/account.entity'; | ||
import { InviteUserRequest } from '../dto/invite-user-request.dto'; | ||
import { UpdateContributorRequest } from '../dto/update-contributor-request.dts'; | ||
|
||
@UseGuards(AccessTokenGuard) | ||
@Controller('projects') | ||
export class ProjectController { | ||
constructor(private projectService: ProjectService) {} | ||
|
||
@Get() | ||
getProjects(@AuthUser() user: Account) { | ||
return this.projectService.getUserProjects(user.id); | ||
} | ||
|
||
@Get(':id/members') | ||
getContributors(@AuthUser() user: Account, @Param('id') projectId: number) { | ||
return this.projectService.getContributors(user.id, projectId); | ||
} | ||
|
||
@Get('invitation') | ||
getInvitations(@AuthUser() user: Account) { | ||
return this.projectService.getInvitations(user.id); | ||
} | ||
|
||
@Post() | ||
create(@AuthUser() user: Account, @Body() body: CreateProjectRequest) { | ||
return this.projectService.create(user.id, body.title); | ||
} | ||
|
||
@Post('invitation') | ||
async invite(@AuthUser() user: Account, @Body() body: InviteUserRequest) { | ||
await this.projectService.invite(user.id, body.projectId, body.username); | ||
return { message: 'Successfully invite user', success: true }; | ||
} | ||
|
||
@Patch('invitation') | ||
async updateInvitation(@AuthUser() user: Account, @Body() body: UpdateContributorRequest) { | ||
await this.projectService.updateInvitation(user.id, body.contributorId, body.status); | ||
return { message: 'Successfully update invitation', success: true }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { IsNotEmpty, IsString, Length } from 'class-validator'; | ||
|
||
export class CreateProjectRequest { | ||
@IsNotEmpty() | ||
@IsString() | ||
@Length(1, 20) | ||
title: string; | ||
} |
12 changes: 12 additions & 0 deletions
12
apps/server/src/project/dto/create-project-response.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Project } from '../entity/project.entity'; | ||
|
||
export class CreateProjectResponse { | ||
id: number; | ||
|
||
title: string; | ||
|
||
constructor(project: Project) { | ||
this.id = project.id; | ||
this.title = project.title; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { IsNotEmpty, IsNumber, IsPositive, Length } from 'class-validator'; | ||
|
||
export class InviteUserRequest { | ||
@IsNotEmpty() | ||
@Length(8, 15) | ||
username: string; | ||
|
||
@IsNotEmpty() | ||
@IsNumber() | ||
@IsPositive() | ||
projectId: number; | ||
} |
15 changes: 15 additions & 0 deletions
15
apps/server/src/project/dto/project-contributors-response-dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { ContributorStatus } from '../enum/contributor-status.enum'; | ||
|
||
export class ProjectContributorsResponse { | ||
id: number; | ||
|
||
username: string; | ||
|
||
role: ContributorStatus; | ||
|
||
constructor(id: number, username: string, role: ContributorStatus) { | ||
this.id = id; | ||
this.username = username; | ||
this.role = role; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
apps/server/src/project/dto/update-contributor-request.dts.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { IsEnum, IsIn, IsNotEmpty, IsNumber, IsPositive } from 'class-validator'; | ||
import { ContributorStatus } from '../enum/contributor-status.enum'; | ||
|
||
export class UpdateContributorRequest { | ||
@IsNotEmpty() | ||
@IsNumber() | ||
@IsPositive() | ||
contributorId: number; | ||
|
||
@IsNotEmpty() | ||
@IsEnum(ContributorStatus) | ||
@IsIn([ContributorStatus.ACCEPTED, ContributorStatus.REJECTED], { | ||
message: 'Required ACCEPTED or REJECTED', | ||
}) | ||
status: ContributorStatus; | ||
} |
16 changes: 16 additions & 0 deletions
16
apps/server/src/project/dto/user-invitation-response.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export class UserInvitationResponse { | ||
contributorId: number; | ||
|
||
projectId: number; | ||
|
||
projectTitle: string; | ||
|
||
inviter: string; | ||
|
||
constructor(contributorId: number, projectId: number, projectTitle: string, inviter: string) { | ||
this.contributorId = contributorId; | ||
this.projectId = projectId; | ||
this.projectTitle = projectTitle; | ||
this.inviter = inviter; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { ContributorStatus } from '../enum/contributor-status.enum'; | ||
|
||
export class UserProjectsResponse { | ||
role: ContributorStatus; | ||
|
||
project: { id: number; title: string; createdAt: Date }; | ||
|
||
constructor(role: ContributorStatus, project: { id: number; title: string; createdAt: Date }) { | ||
this.role = role; | ||
this.project = project; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm'; | ||
import { ContributorStatus } from '../enum/contributor-status.enum'; | ||
import { ProjectRole } from '../enum/project-role.enum'; | ||
import { EntityTimestamp } from '@/common/entity-timestamp.entity'; | ||
|
||
@Entity() | ||
export class Contributor extends EntityTimestamp { | ||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@Column() | ||
userId: number; | ||
|
||
@Column() | ||
inviterId: number; | ||
|
||
@Column() | ||
projectId: number; | ||
|
||
@Column({ type: 'enum', enum: ContributorStatus }) | ||
status: ContributorStatus; | ||
|
||
@Column({ type: 'enum', enum: ProjectRole }) | ||
role: ProjectRole; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm'; | ||
import { EntityTimestamp } from '@/common/entity-timestamp.entity'; | ||
|
||
@Entity() | ||
export class Project extends EntityTimestamp { | ||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@Column() | ||
title: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export enum ContributorStatus { | ||
PENDING = 'PENDING', | ||
ACCEPTED = 'ACCEPTED', | ||
REJECTED = 'REJECTED', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export enum ProjectRole { | ||
ADMIN = 'ADMIN', | ||
GUEST = 'GUEST', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { ProjectService } from './service/project.service'; | ||
import { ProjectController } from './controller/project.controller'; | ||
import { Project } from './entity/project.entity'; | ||
import { Contributor } from './entity/contributor.entity'; | ||
import { Account } from '@/account/entity/account.entity'; | ||
|
||
@Module({ | ||
imports: [TypeOrmModule.forFeature([Project, Contributor, Account])], | ||
controllers: [ProjectController], | ||
providers: [ProjectService], | ||
}) | ||
export class ProjectModule {} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Contributor가 팀원인가용
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
팀원이라고 보시면 됩니다. 초대 관련 여러가지 정보를 담고 있어요