Skip to content

토론 게시판 기능 구현#26

Merged
sgn07124 merged 17 commits intomainfrom
feat/discussions
Aug 20, 2025
Merged

토론 게시판 기능 구현#26
sgn07124 merged 17 commits intomainfrom
feat/discussions

Conversation

@sgn07124
Copy link
Owner

@sgn07124 sgn07124 commented Aug 20, 2025

User description

관련 이슈 (Related Issues)


PR Type

Enhancement, Tests


Description

  • 토론 글 CRUD 및 조회 API 추가

  • 댓글 작성·수정·삭제·조회 기능 구현

  • MyBatis 매퍼 및 SQL 추가, 예외코드 확장

  • 컨트롤러·서비스 테스트 다수 추가


Diagram Walkthrough

flowchart LR
  Controller["PostController, QuestionController"] --> Service["SharedPostServiceImpl, CommentServiceImpl, AnswerServiceImpl"]
  Service --> Mapper["SharedPostMapper, CommentMapper, AnswerMapper"]
  Mapper --> SQL["shared-post-mapper.xml, comment-mapper.xml, answer-mapper.xml"]
  Service --> DTO["Post/Comment DTOs, PreviewResponse"]
  Controller --> Response["ApiSuccessCode 확장"]
  Tests["WebMvcTest + Service 단위테스트"] --> Controller
  Tests --> Service
Loading

File Walkthrough

Relevant files
Enhancement
20 files
PostController.java
토론 글 및 댓글 REST 엔드포인트 추가                                                                   
+102/-0 
CommentRequest.java
댓글 생성·수정 요청 DTO 추가                                                                             
+25/-0   
CommentResponse.java
댓글 응답/조회 DTO 추가                                                                                   
+46/-0   
PostRequest.java
글 생성 및 소유자/상태 DTO                                                                               
+39/-0   
PostResponse.java
글 상세/목록 응답 DTO 추가                                                                               
+62/-0   
CommentMapper.java
댓글용 MyBatis 매퍼 인터페이스                                                                         
+26/-0   
SharedPostMapper.java
공유 글 MyBatis 매퍼 인터페이스                                                                       
+35/-0   
CommentService.java
댓글 서비스 인터페이스 정의                                                                                   
+17/-0   
SharedPostService.java
공유 글 서비스 인터페이스 정의                                                                               
+16/-0   
CommentServiceImpl.java
댓글 생성/수정/삭제/조회 구현                                                                               
+131/-0 
SharedPostServiceImpl.java
글 생성/상세/상태변경/목록 구현                                                                             
+93/-0   
QuestionController.java
답변 프리뷰 조회 엔드포인트 추가                                                                             
+8/-0     
PreviewResponse.java
질문·답변 프리뷰 DTO 추가                                                                                 
+15/-0   
AnswerMapper.java
프리뷰/소유검증 쿼리 메서드 추가                                                                             
+5/-0     
AnswerService.java
프리뷰 조회 메서드 추가                                                                                       
+3/-0     
AnswerServiceImpl.java
프리뷰 조회 로직 구현                                                                                         
+12/-0   
ApiSuccessCode.java
글/댓글/프리뷰 성공 코드 추가                                                                               
+11/-1   
answer-mapper.xml
프리뷰/소유 확인 쿼리 추가                                                                                   
+18/-0   
comment-mapper.xml
댓글 CRUD 및 페이지 쿼리                                                                                 
+77/-0   
shared-post-mapper.xml
글 생성/상세/목록/상태변경 쿼리                                                                             
+148/-0 
Documentation
2 files
PostControllerDocs.java
Swagger 문서 인터페이스 정의                                                                           
+53/-0   
QuestionControllerDocs.java
프리뷰 조회 API 문서화                                                                                     
+4/-0     
Error handling
3 files
PostErrorCode.java
글/댓글 예외 코드 정의                                                                                       
+25/-0   
PostException.java
도메인 커스텀 예외 추가                                                                                       
+13/-0   
QuestionErrorCode.java
답변 없음 예외 코드 추가                                                                                     
+2/-1     
Tests
4 files
CommentControllerTest.java
댓글 컨트롤러 WebMvc 테스트                                                                             
+217/-0 
PostControllerTest.java
글 컨트롤러 WebMvc 테스트                                                                               
+154/-0 
CommentServiceImplTest.java
댓글 서비스 단위 테스트                                                                                       
+479/-0 
SharedPostServiceImplTest.java
글 서비스 단위 테스트                                                                                         
+293/-0 
Configuration changes
1 files
sql-map-config.xml
sharedPost/comment 타입 별칭 등록                                                           
+2/-0     

@sgn07124 sgn07124 self-assigned this Aug 20, 2025
@sgn07124 sgn07124 added ✨ Feature 새로운 기능 추가 ✅ Test 테스트 코드 추가 및 수정 labels Aug 20, 2025
@sgn07124 sgn07124 linked an issue Aug 20, 2025 that may be closed by this pull request
8 tasks
@codecov
Copy link

codecov bot commented Aug 20, 2025

@github-actions
Copy link

github-actions bot commented Aug 20, 2025

PR Reviewer Guide 🔍

(Review updated until commit 1396f5d)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

CreatedAt Consistency

댓글 생성 응답의 createdAt을 서비스에서 LocalDateTime.now()로 세팅하고 있습니다. DB의 created_at과 시간 차/타임존 불일치가 생길 수 있어 조회 시점 혹은 DB 반환값과 일치시키는 것이 좋습니다.

commentMapper.insertComment(comment);

return CommentRes.builder()
        .commentId(comment.getId())
        .content(comment.getContent())
        .authorId(me.getId())
        .authorNickname(me.getNickname())
        .postId(postId)
        .createdAt(LocalDateTime.now())
        .build();
Sequence Retrieval

PostgreSQL 시퀀스 currval 사용 시 같은 세션 내에서만 안전합니다. insert 이전에 selectKey AFTER currval 호출은 동시성/초기 세션에서 null 에러를 유발할 수 있습니다. RETURNING id 또는 SELECT lastval() 패턴 검토가 필요합니다.

    <selectKey keyProperty="id" resultType="long" order="AFTER">
        SELECT currval(pg_get_serial_sequence('comment','id'))
    </selectKey>
    INSERT INTO comment (created_at, updated_at, content, member_id, post_id)
    VALUES (NOW(), NOW(), #{content}, #{member.id}, #{sharedPost.id})
</insert>
Pagination Defaults

컨트롤러에서 page,size 기본값을 전달만 하고 서비스에서 보정합니다. 음수/0 전달 시 API 문서와 실제 동작의 불일치가 생길 수 있어 컨트롤러 레벨에서 @min 제약 등으로 검증을 추가하는 것이 좋습니다.

public ResponseEntity<ApiResponse<PageResponse<PostListItemDto>>> list(
        @RequestParam(defaultValue = "1") int page,
        @RequestParam(defaultValue = "10") int size
) {
    PageResponse<PostListItemDto> body = sharedPostService.getPosts(page, size);
    return ResponseEntity.ok(ApiResponse.of(ApiSuccessCode.GET_POSTS_SUCCESS, body));
}

@github-actions
Copy link

Persistent review updated to latest commit e096928

@github-actions
Copy link

Persistent review updated to latest commit 1396f5d

@sgn07124 sgn07124 merged commit 3a161e8 into main Aug 20, 2025
1 of 2 checks passed
@sgn07124 sgn07124 deleted the feat/discussions branch August 20, 2025 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review effort 3/5 ✨ Feature 새로운 기능 추가 ✅ Test 테스트 코드 추가 및 수정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

질문 공유 게시판 기능 구현

1 participant