Skip to content

Conversation

@youngseo22
Copy link
Contributor

@youngseo22 youngseo22 commented Jun 22, 2025

작업 내용

  • [좋아요, 북마크] 사용자-작성자 혼동 수정
  • [메인페이지] 변수명 오류 수정
  • [게시글 보기] response 수정
  • 로그인 없이 메인페이지(+전체보기), 태그 모음 볼 수 있게
  • [게시글 작성하기] s3 업로드 api 추가

Summary by CodeRabbit

  • 신규 기능

    • 게시글 이미지 업로드 기능이 추가되었습니다. 이제 이미지를 업로드하고 마크다운 형식으로 받을 수 있습니다.
    • 게시글 및 메인 페이지 응답에 프로필 이미지 URL과 닉네임 정보가 포함됩니다.
  • 버그 수정

    • 사용자가 자신의 게시글을 북마크할 수 없도록 북마크 토글 로직이 수정되었습니다.
  • 개선 사항

    • 비로그인 사용자의 경우에도 기본 프로필 이미지가 제공되도록 메인 페이지 및 게시글 조회 로직이 개선되었습니다.
    • 페이지네이션 파라미터명이 명확하게 수정되어, 페이지 크기(size)와 페이지 번호(page)가 구분됩니다.
  • 테스트/모킹 데이터

    • 테스트용 데이터 자동 생성 기능이 제거되었습니다.
  • 기타

    • 오류 코드가 추가되어 이미지 업로드 실패 시 명확한 메시지를 제공합니다.
    • 설정 파일 내 주석 스타일이 개선되었습니다.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 22, 2025

Walkthrough

테스트 데이터 초기화 관련 mock 클래스들이 삭제되고, 이미지 업로드 기능 및 프로필 이미지 처리 로직이 추가되었습니다. 일부 컨트롤러의 파라미터 이름이 수정되었으며, DTO와 예외 코드가 확장되었습니다. application.properties의 주석 형식도 변경되었습니다.

Changes

파일/그룹 변경 요약
.../controller/Controller, .../mock/MemberTestDataInitializer.java, .../mock/PostTestDataInitializer.java, .../mock/TagTestDataInitializer.java 테스트/모의 데이터 초기화 관련 클래스 3종 및 테스트용 컨트롤러 삭제
.../controller/MainPageController.java 페이징 파라미터 이름을 "page"에서 "size"로 수정
.../controller/PostController.java, .../service/PostService.java 이미지 업로드 엔드포인트 및 서비스 메서드 추가, S3Service 의존성 주입
.../dto/post/PostDto.java 필드 userId, nickname 추가
.../dto/post/PostResponseDto.java profileImageUrl 필드 추가, createdAt 필드 위치 변경
.../exception/ErrorCode.java IMAGE_UPLOAD_FAILED 예외 코드 추가
.../service/MainPageService.java Optional로 현재 회원 조회 및 비로그인 시 기본 프로필 이미지 처리 추가, TODO 주석 추가
.../service/MemberService.java getCurrentOptionalMemberInfo() 메서드 추가, 기존 메서드에 주석 보완
src/main/resources/application.properties 주석 스타일 및 구조 변경, spring.config.import 주석 추가

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant PostController
    participant PostService
    participant S3Service

    Client->>PostController: POST /posts/images (imageFile)
    PostController->>PostService: uploadImage(imageFile)
    PostService->>S3Service: upload(imageFile)
    S3Service-->>PostService: S3 URL 반환
    PostService-->>PostController: 마크다운 이미지 링크 반환
    PostController-->>Client: 성공 응답 반환
Loading
sequenceDiagram
    participant Client
    participant MainPageController
    participant MainPageService
    participant MemberService

    Client->>MainPageController: GET /mainPageView
    MainPageController->>MainPageService: mainPageView(sort, size)
    MainPageService->>MemberService: getCurrentOptionalMemberInfo()
    alt 로그인 사용자
        MemberService-->>MainPageService: Optional<Member> (존재)
        MainPageService->>MainPageService: 프로필 이미지 URL 추출
    else 비로그인 사용자
        MemberService-->>MainPageService: Optional.empty
        MainPageService->>MainPageService: 기본 프로필 이미지 URL 할당
    end
    MainPageService-->>MainPageController: 응답 데이터 반환
    MainPageController-->>Client: 응답 반환
Loading

Suggested labels

youngseo

Suggested reviewers

  • semsemin
  • sungchaewon

Poem

🐇
테스트 데이터는 안녕,
새 기능이 토글토글 등장해요.
이미지는 척 S3로,
프로필 사진도 챙겼죠!
코드의 봄바람 따라
바뀐 주석, 늘어난 DTO,
오늘도 토끼는 깡충깡충!

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (4)
src/main/java/com/example/FixLog/service/MainPageService.java (2)

59-59: TODO 코멘트의 구체적인 해결책이 필요합니다.

인기순 정렬에서 좋아요가 0인 게시글과 totalPages 계산 문제를 언급했는데, 이 문제들을 어떻게 해결할지 구체적인 계획이 필요합니다.

이 문제를 해결하기 위한 구체적인 해결책을 제안해드릴까요? 예를 들어, 좋아요 수로 정렬할 때 생성일자를 2차 정렬 기준으로 사용하거나, 페이지네이션 로직을 개선하는 방법이 있습니다.


87-96: 일관된 Optional 패턴 적용이 좋습니다.

mainPageFullView 메서드에도 동일한 Optional 패턴을 적용하여 일관성을 유지한 것이 좋습니다. 코드 중복이 있지만 현재로서는 적절합니다.

향후에는 프로필 이미지 URL 처리 로직을 별도 메서드로 추출하여 중복을 제거하는 것을 고려해보세요:

+private String getProfileImageUrl(Optional<Member> optionalMember) {
+    if (optionalMember.isPresent()) {
+        Member member = optionalMember.get();
+        String imageUrl = member.getProfileImageUrl();
+        return getDefaultImage(imageUrl);
+    } else {
+        return "https://example.com/default-cover-image.png";
+    }
+}
src/main/java/com/example/FixLog/service/PostService.java (2)

90-90: TODO 코멘트가 구체적이지 않습니다.

"사진 발생하면 s3 처리하기"라는 표현이 모호합니다. 어떤 사진을 언제 어떻게 처리할지 더 구체적으로 명시해주세요.

-// Todo : 여기서 사진 발생하면 s3 처리하기
+// TODO: 게시글 내용에 포함된 이미지들을 S3로 업로드하고 URL 변환 처리

147-147: TODO 코멘트의 개선 제안이 유용합니다.

사용자에게 어떤 태그가 누락되었는지 알려주는 것은 좋은 UX 개선 아이디어입니다.

이 기능을 구현하는 코드를 작성해드릴까요? ErrorCode에 세부 메시지 지원을 추가하거나 별도의 validation response DTO를 만드는 방법이 있습니다.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a456416 and 48a0d56.

📒 Files selected for processing (13)
  • src/main/java/com/example/FixLog/controller/Controller (0 hunks)
  • src/main/java/com/example/FixLog/controller/MainPageController.java (1 hunks)
  • src/main/java/com/example/FixLog/controller/PostController.java (2 hunks)
  • src/main/java/com/example/FixLog/dto/post/PostDto.java (1 hunks)
  • src/main/java/com/example/FixLog/dto/post/PostResponseDto.java (1 hunks)
  • src/main/java/com/example/FixLog/exception/ErrorCode.java (1 hunks)
  • src/main/java/com/example/FixLog/mock/MemberTestDataInitializer.java (0 hunks)
  • src/main/java/com/example/FixLog/mock/PostTestDataInitializer.java (0 hunks)
  • src/main/java/com/example/FixLog/mock/TagTestDataInitializer.java (0 hunks)
  • src/main/java/com/example/FixLog/service/MainPageService.java (4 hunks)
  • src/main/java/com/example/FixLog/service/MemberService.java (1 hunks)
  • src/main/java/com/example/FixLog/service/PostService.java (8 hunks)
  • src/main/resources/application.properties (1 hunks)
💤 Files with no reviewable changes (4)
  • src/main/java/com/example/FixLog/mock/TagTestDataInitializer.java
  • src/main/java/com/example/FixLog/controller/Controller
  • src/main/java/com/example/FixLog/mock/MemberTestDataInitializer.java
  • src/main/java/com/example/FixLog/mock/PostTestDataInitializer.java
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (17)
src/main/resources/application.properties (2)

5-6: 주석 형식 및 계층화 일관화
DEV 섹션 내 각 서브 섹션(JPA, AWS S3, JWT, Spring Security 디버깅 로그 등)의 주석을 ## 계층으로 통일하고 빈 주석 라인을 추가해 가독성을 개선했습니다. 실제 설정 값에는 영향이 없습니다.

Also applies to: 12-13, 18-19, 24-25, 27-28


7-7: 새로운 .env 파일 optional import 설정
spring.config.import=optional:.env 설정이 주석 처리된 상태로 추가되었습니다. Dev 환경에서 환경변수 파일을 불러올 필요가 있을 경우 해당 주석을 해제하여 사용하세요.

src/main/java/com/example/FixLog/service/MemberService.java (2)

60-60: 주석 추가로 메서드 동작이 명확해졌습니다.

예외 처리 여부를 명시한 주석이 메서드의 의도를 명확하게 전달합니다.


68-74: Optional 반환 메서드 추가가 적절합니다.

인증되지 않은 사용자 처리를 위한 안전한 방법을 제공하며, 기존 메서드와 일관된 패턴을 따르고 있습니다. 메인 페이지나 게시글 조회에서 로그인하지 않은 사용자도 접근할 수 있도록 하는 요구사항에 잘 부합합니다.

src/main/java/com/example/FixLog/dto/post/PostDto.java (1)

11-12: 게시글 작성자 정보 필드 추가가 적절합니다.

게시글과 작성자 정보를 함께 전달하기 위한 userId와 nickname 필드 추가가 논리적으로 타당합니다. 필드 위치도 중요도에 따라 적절히 배치되었습니다.

src/main/java/com/example/FixLog/dto/post/PostResponseDto.java (2)

12-12: 필드 순서 조정이 논리적입니다.

createdAt를 postInfo 바로 다음에 배치하여 게시글 메타데이터를 함께 그룹화한 것이 좋습니다.


15-15: 프로필 이미지 URL 필드 추가가 적절합니다.

사용자 정보인 nickname과 profileImageUrl을 인접하게 배치하여 관련된 데이터를 논리적으로 그룹화했습니다.

src/main/java/com/example/FixLog/service/MainPageService.java (2)

17-17: Optional import 추가가 적절합니다.

Optional 패턴을 사용하여 로그인하지 않은 사용자를 안전하게 처리하기 위한 변경입니다.


41-50: Optional 패턴으로 안전한 회원 정보 처리가 개선되었습니다.

로그인하지 않은 사용자도 메인페이지에 접근할 수 있도록 Optional을 사용한 것은 좋은 개선입니다. 기본 이미지 URL 처리도 적절합니다.

src/main/java/com/example/FixLog/controller/MainPageController.java (2)

19-19: 파라미터 이름 수정이 올바릅니다.

@RequestParam(value = "size",...)로 변경하여 실제 사용 용도와 일치하도록 수정한 것이 좋습니다.


27-27: 일관된 파라미터 이름 적용이 좋습니다.

두 메서드 모두에서 일관되게 파라미터 이름을 수정하여 코드의 가독성과 일관성을 높였습니다.

src/main/java/com/example/FixLog/service/PostService.java (6)

23-23: MultipartFile import 추가가 적절합니다.

이미지 업로드 기능을 위한 필수 import입니다.


40-40: S3Service 의존성 주입이 올바르게 구현되었습니다.

생성자 주입 패턴을 사용하여 S3Service를 추가한 것이 Spring의 모범 사례를 따르고 있습니다.

Also applies to: 44-45, 52-52


100-108: 이미지 업로드 메서드 구현이 좋습니다.

null/empty 체크, S3 업로드, 마크다운 형식 반환까지 적절하게 구현되었습니다. 예외 처리도 CustomException을 사용하여 일관성을 유지했습니다.


162-162: Optional 패턴으로 비로그인 사용자 지원이 잘 구현되었습니다.

로그인하지 않은 사용자도 게시글을 볼 수 있도록 Optional를 사용한 것이 좋습니다. 각 필드에 대한 기본값 처리도 적절합니다.

Also applies to: 185-202, 206-206


168-169: 게시글 작성자 정보 접근이 개선되었습니다.

getUserId()를 통해 작성자의 ID와 닉네임을 가져오는 방식이 더 명확해졌습니다.


243-243: 북마크 로직 버그 수정이 중요한 개선입니다.

기존에 북마크 폴더 소유자와 비교하던 것을 게시글 작성자와 비교하도록 수정한 것이 올바른 로직입니다. 자신의 게시글을 북마크하지 못하도록 하는 의도에 맞게 수정되었습니다.

이 버그 수정은 사용자가 자신의 게시글을 북마크하지 못하도록 하는 비즈니스 로직을 올바르게 구현합니다.

Comment on lines +28 to +32
@PostMapping("/images")
public Response<String> uploadImage(@RequestPart("imageFile") MultipartFile imageFile){
String markdownImage = postService.uploadImage(imageFile);
return Response.success("이미지 마크다운 형식으로 변환", markdownImage);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

이미지 업로드 엔드포인트에 입력 검증을 추가해주세요.

MultipartFile에 대한 기본적인 검증(null 체크, 파일 크기, 파일 타입 등)을 컨트롤러 레벨에서 수행하는 것이 좋습니다.

 @PostMapping("/images")
-public Response<String> uploadImage(@RequestPart("imageFile") MultipartFile imageFile){
+public Response<String> uploadImage(@RequestPart("imageFile") MultipartFile imageFile){
+    if (imageFile == null || imageFile.isEmpty()) {
+        throw new CustomException(ErrorCode.IMAGE_UPLOAD_FAILED);
+    }
     String markdownImage = postService.uploadImage(imageFile);
     return Response.success("이미지 마크다운 형식으로 변환", markdownImage);
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@PostMapping("/images")
public Response<String> uploadImage(@RequestPart("imageFile") MultipartFile imageFile){
String markdownImage = postService.uploadImage(imageFile);
return Response.success("이미지 마크다운 형식으로 변환", markdownImage);
}
@PostMapping("/images")
public Response<String> uploadImage(@RequestPart("imageFile") MultipartFile imageFile) {
if (imageFile == null || imageFile.isEmpty()) {
throw new CustomException(ErrorCode.IMAGE_UPLOAD_FAILED);
}
String markdownImage = postService.uploadImage(imageFile);
return Response.success("이미지 마크다운 형식으로 변환", markdownImage);
}
🤖 Prompt for AI Agents
In src/main/java/com/example/FixLog/controller/PostController.java around lines
28 to 32, the uploadImage method lacks input validation for the MultipartFile
parameter. Add null checks to ensure the file is provided, validate the file
size against a maximum allowed limit, and verify the file type (e.g., image MIME
types) before processing. If validation fails, return an appropriate error
response to prevent invalid files from being processed.

@youngseo22 youngseo22 merged commit 524e680 into main Jun 22, 2025
2 checks passed
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.

3 participants