[3주차] 강지훈/[feat] User, Post, Comment, Report 도메인 API 구현#121
Open
theSnackOverflow wants to merge 7 commits intoLeets-Official:강지훈/mainfrom
Hidden character warning
The head ref may contain hidden characters: "\uac15\uc9c0\ud6c8/3\uc8fc\ucc28"
Open
[3주차] 강지훈/[feat] User, Post, Comment, Report 도메인 API 구현#121theSnackOverflow wants to merge 7 commits intoLeets-Official:강지훈/mainfrom
theSnackOverflow wants to merge 7 commits intoLeets-Official:강지훈/mainfrom
Conversation
- ApiResponse를 dto에서 global/response로 이동 - ErrorCode enum 기반 BusinessException 도입 - BusinessException, MissingRequestHeader, TypeMismatch 등 핸들러 추가
- User 엔티티에 정적 팩토리/update 메서드 추가 - UserRepository, UserService, UserController 작성 - 이메일 중복 검사, Bean Validation 적용
- Post 엔티티에 정적 팩토리/update 메서드 추가 - PostRepository, PostService, PostController 작성 - status/페이지네이션 필터, 작성자 권한 검증
- Comment 엔티티에 정적 팩토리/update 메서드 추가 - CommentRepository, CommentService, CommentController 작성 - 1뎁스 대댓글 제한, 작성자 권한 검증
- Report 엔티티에 정적 팩토리 메서드 추가 - ReportRepository, ReportService, ReportController 작성 - POST/COMMENT 대상 분기 처리 및 검증
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
1. 과제 요구사항 중 구현한 내용
@RequestParam,@PathVariable,@RequestBody,@RequestHeader)ApiResponse<T>) 적용GlobalExceptionHandler) 구현/swagger-ui.html) 연동2. 핵심 변경 사항
패키지 구조 개편
controller/,service/,dto/)를 도메인별 구조(domain/{user,post,comment,report}/)로 전환global/response/,global/exception/으로 분리공통 인프라
global/response/ApiResponse<T>: 공통 응답 래퍼 (success,error정적 팩토리)global/exception/ErrorCode(enum): HTTP 상태 + 에러 코드 + 메시지 일원화global/exception/GlobalExceptionHandler:BusinessException, Validation, TypeMismatch, MissingHeader, 500 안전망 핸들러 추가도메인별 API (
/api/v1/...)POST /users,GET /users/{userId},PATCH /users/{userId},DELETE /users/{userId}POST /posts,GET /posts?status=&page=&size=,GET /posts/{postId},PATCH /posts/{postId},DELETE /posts/{postId}POST /posts/{postId}/comments,GET /posts/{postId}/comments,PATCH /comments/{commentId},DELETE /comments/{commentId}POST /reports,GET /reports인증 처리: Spring Security 미도입 상태로 작성자 식별은
X-User-Id헤더로 임시 처리Jackson snake_case 전역 설정으로 응답 필드 자동 변환
3. 실행 및 검증 결과
로컬에서 H2 인메모리 DB 기반으로 동작 확인 (
./gradlew bootRun)사용자 생성
POST /api/v1/users게시글 작성
POST /api/v1/posts(X-User-Id: 1)댓글 + 대댓글 조회
GET /api/v1/posts/1/comments{ "data": [{ "comment_id": 1, "content": "첫 댓글", "replies": [{ "comment_id": 2, "content": "대댓글", "parent_comment_id": 1 }] }] }권한 없는 게시글 수정 → 403
{ "status": "error", "message": "접근 권한이 없습니다." }빈 제목으로 게시글 작성 → 400
{ "status": "error", "message": "제목은 필수입니다." }4. 완료 사항
global/response,global/exception) 분리5. 추가 사항
X-User-Id헤더 기반 임시 처리이며, Spring Security 도입 시 교체 예정Report) 대상 구분은target_type(POST/COMMENT) 필드로 처리제출 체크리스트
강지훈/main브랜치다강지훈/3주차브랜치다