-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from modern-agile-team/feature/comment
ADD(2swo/Comment) 댓글 기능 추가
- Loading branch information
Showing
10 changed files
with
623 additions
and
4 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { UserImage } from 'src/users/entities/user-image.entity'; | ||
|
||
export class commentResponseDTO { | ||
id: number; | ||
content: string; | ||
commentowner: true | false; | ||
userId: { | ||
name: string; | ||
userImage: UserImage | UserImage[]; | ||
}; | ||
} |
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,6 @@ | ||
import { IsString } from 'class-validator'; | ||
|
||
export class UpdateCommentDto { | ||
@IsString() | ||
content: 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
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
103 changes: 103 additions & 0 deletions
103
src/comments/swagger-decoratros/add-comment-decorators.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,103 @@ | ||
import { applyDecorators } from '@nestjs/common'; | ||
import { | ||
ApiBody, | ||
ApiHeaders, | ||
ApiOperation, | ||
ApiParam, | ||
ApiResponse, | ||
} from '@nestjs/swagger'; | ||
|
||
export function ApiAddComment() { | ||
return applyDecorators( | ||
ApiOperation({ | ||
summary: '댓글을 생성하는 API', | ||
description: '댓글을 생성하는 API', | ||
}), | ||
ApiResponse({ | ||
status: 200, | ||
description: '성공적으로 댓글을 생성한 경우', | ||
content: { | ||
JSON: { | ||
example: { | ||
content: '댓글 1차시도', | ||
userId: '작성한 userId가 넘어옵니다', | ||
boardId: '작성한 보드의 boardId가 넘어옵니다', | ||
id: '댓글 고유 id', | ||
createAt: '작성한 시간이 넘어옵니다', | ||
}, | ||
}, | ||
}, | ||
}), | ||
ApiResponse({ | ||
status: 401, | ||
description: '우리 서비스의 액세스 토큰이 아닌 경우', | ||
content: { | ||
JSON: { | ||
example: { statusCode: 401, message: '유효하지 않은 토큰입니다.' }, | ||
}, | ||
}, | ||
}), | ||
ApiResponse({ | ||
status: 403, | ||
description: '만료된 액세스 토큰인 경우', | ||
content: { | ||
JSON: { | ||
example: { statusCode: 403, message: '만료된 토큰입니다.' }, | ||
}, | ||
}, | ||
}), | ||
ApiResponse({ | ||
status: 404, | ||
description: 'DB에서 보드를 찾을 수 없는 경우', | ||
content: { | ||
JSON: { | ||
example: { statusCode: 404, message: '보드를 찾을 수 없습니다.' }, | ||
}, | ||
}, | ||
}), | ||
ApiResponse({ | ||
status: 411, | ||
description: '액세스 토큰이 제공되지 않은 경우', | ||
content: { | ||
JSON: { | ||
example: { statusCode: 411, message: '토큰이 제공되지 않았습니다.' }, | ||
}, | ||
}, | ||
}), | ||
ApiResponse({ | ||
status: 500, | ||
description: '댓글을 생성하는 중 오류가 발생한 경우', | ||
content: { | ||
JSON: { | ||
example: { | ||
statusCode: 500, | ||
message: '댓글을 생성하는 중 오류가 발생했습니다.', | ||
}, | ||
}, | ||
}, | ||
}), | ||
ApiHeaders([ | ||
{ | ||
name: 'access_token', | ||
description: '액세스 토큰', | ||
required: true, | ||
example: '여기에 액세스 토큰', | ||
}, | ||
]), | ||
ApiParam({ | ||
name: 'boardId', | ||
description: '댓글을 추가할 보드의 ID', | ||
}), | ||
ApiBody({ | ||
schema: { | ||
type: 'object', | ||
properties: { | ||
content: { type: 'string' }, | ||
}, | ||
example: { | ||
content: '추가할 댓글 입력입니다.', | ||
}, | ||
}, | ||
}), | ||
); | ||
} |
85 changes: 85 additions & 0 deletions
85
src/comments/swagger-decoratros/delete-comment-decorator.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,85 @@ | ||
import { applyDecorators } from '@nestjs/common'; | ||
import { | ||
ApiHeaders, | ||
ApiOperation, | ||
ApiParam, | ||
ApiResponse, | ||
} from '@nestjs/swagger'; | ||
|
||
export function ApiDeleteComment() { | ||
return applyDecorators( | ||
ApiOperation({ | ||
summary: '댓글을 삭제하는 API', | ||
description: '댓글을 삭제하는 API', | ||
}), | ||
ApiResponse({ | ||
status: 200, | ||
description: '성공적으로 댓글을 삭제한 경우', | ||
content: { | ||
JSON: { | ||
example: {}, | ||
}, | ||
}, | ||
}), | ||
ApiResponse({ | ||
status: 401, | ||
description: '우리 서비스의 액세스 토큰이 아닌 경우', | ||
content: { | ||
JSON: { | ||
example: { statusCode: 401, message: '유효하지 않은 토큰입니다.' }, | ||
}, | ||
}, | ||
}), | ||
ApiResponse({ | ||
status: 403, | ||
description: '만료된 액세스 토큰인 경우', | ||
content: { | ||
JSON: { | ||
example: { statusCode: 403, message: '만료된 토큰입니다.' }, | ||
}, | ||
}, | ||
}), | ||
ApiResponse({ | ||
status: 404, | ||
description: 'DB에서 댓글을 찾을 수 없는 경우', | ||
content: { | ||
JSON: { | ||
example: { statusCode: 404, message: '댓글을 찾을 수 없습니다.' }, | ||
}, | ||
}, | ||
}), | ||
ApiResponse({ | ||
status: 411, | ||
description: '액세스 토큰이 제공되지 않은 경우', | ||
content: { | ||
JSON: { | ||
example: { statusCode: 411, message: '토큰이 제공되지 않았습니다.' }, | ||
}, | ||
}, | ||
}), | ||
ApiResponse({ | ||
status: 500, | ||
description: '댓글을 삭제하는 오류가 발생한 경우', | ||
content: { | ||
JSON: { | ||
example: { | ||
statusCode: 500, | ||
message: '댓글을 삭제하는 중 오류가 발생했습니다.', | ||
}, | ||
}, | ||
}, | ||
}), | ||
ApiHeaders([ | ||
{ | ||
name: 'access_token', | ||
description: '액세스 토큰', | ||
required: true, | ||
example: '여기에 액세스 토큰', | ||
}, | ||
]), | ||
ApiParam({ | ||
name: 'commentId', | ||
description: '삭제할 댓글의 ID', | ||
}), | ||
); | ||
} |
Oops, something went wrong.