Skip to content

[3주차] 시재욱/[feat] 게시글 도메인 API 구현#90

Open
seejaewook456-maker wants to merge 4 commits intoLeets-Official:시재욱/mainfrom
seejaewook456-maker:시재욱/3주차

Hidden character warning

The head ref may contain hidden characters: "\uc2dc\uc7ac\uc6b1/3\uc8fc\ucc28"
Open

[3주차] 시재욱/[feat] 게시글 도메인 API 구현#90
seejaewook456-maker wants to merge 4 commits intoLeets-Official:시재욱/mainfrom
seejaewook456-maker:시재욱/3주차

Conversation

@seejaewook456-maker
Copy link
Copy Markdown

@seejaewook456-maker seejaewook456-maker commented Apr 6, 2026

1. 과제 요구사항 중 구현한 내용

  • 게시글 생성, 수정, 삭제
  • 게시글 조회, 존재하지 않는 게시글에 관한 안내
  • 잘못된 입력값으로 요청 받았을 때 해당 내용 안내
  • 요청에 대한 처리를 성공한 경우 / 실패한 경우에 대한 결과 메시지

2. 핵심 변경 사항

  1. user, comment, post의 각 속성에 잘못된 입력에 대한 검증 과정을 추가했고 안내 메시지를 지정했습니다.
  2. global.exception.GlobalExceptionHandler 클래스로 잘못된 입력에 대한 처리 과정을 작성했습니다.
  3. global.exception.ApiResponse 클래스로 올바른/잘못된 입력에 대한 응답 메시지를 통일했습니다.

3. 실행 및 검증 결과

게시글 등록 성공한 경우

게시글 등록 성공

게시글 등록 과정에서 제목을 입력하지 않은 경우

게시글 제목 없음

게시글 조회

게시글 조회

4. 완료 사항

  1. 게시글 생성, 수정, 삭제, 조회
  2. 잘못된 입력 검증
  3. 요청 성공한 경우 / 실패한 경우 안내 메시지 지정

5. 추가 사항

#89

제출 체크리스트

  • PR 제목이 규칙에 맞다
  • base가 {이름}/main 브랜치다
  • compare가 {이름}/{숫자}주차 브랜치다
  • 프로젝트가 정상 실행된다
  • 본인을 Assignee로 지정했다
  • 파트 담당 Reviewer를 지정했다
  • 리뷰 피드백을 반영한 뒤 머지/PR close를 진행한다

Reviewer 참고

@seejaewook456-maker seejaewook456-maker requested a review from a team April 6, 2026 08:43
@seejaewook456-maker seejaewook456-maker self-assigned this Apr 6, 2026
Copy link
Copy Markdown

@yeonjuncho yeonjuncho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 필요한 부분 깔끔하게 코드 작성해주신 것 같습니다. 고생하셨습니다!

Copy link
Copy Markdown

@LGH0507 LGH0507 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

코드 작성하시느라 수고 많으셨습니다! 전체적으로 공통 응답 구조 (ApiResponse, BaseCode) 및 유효성 검증 어노테이션 등을 적절히 활용하셔서 잘 작성하신 것 같습니다 👍


@Getter
@RequiredArgsConstructor
public enum BaseCode {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

모든 API 응답을 ApiResponse로 통일하고 BaseCode를 enum으로 코드와 메시지를 관리한 부분 잘 설계하신 것 같습니다!👍

import java.util.Map;

@RestControllerAdvice
public class GlobalExceptionHandler {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vaild 로 컨트롤러에서 활성화하고 유효성 검증 어노테이션(@NotNull, @notblank 등)을 적절히 활용한 부분 좋은 설계인 것 같습니다! 👍

public PostResponse createPost(PostCreateRequest request) {

User user = userRepository.findById(request.getUserId())
.orElseThrow(() -> new IllegalArgumentException("유저 없음"));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재는 메시지를 에러코드가 아닌 문자열로 반환하고 있는데 USER_NOT_FOUND 와 같이 전역 예외처리를 한다면 더욱 통일성 있는 응답 구조가 될 것 같습니다. 💊

.orElseThrow(() -> new IllegalArgumentException("게시글 없음"));

List<PostBlockResponse> blocks = post.getBlocks().stream()
.sorted((a, b) -> a.getSortOrder() - b.getSortOrder())
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 스트림에서 정렬하는 것도 좋지만, DB 쿼리 단계에서 ORDER BY를 사용하거나 엔티티의 @orderby 어노테이션을 활용하면 애플리케이션의 메모리 부담을 줄일 수 있습니다. ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants