-
Notifications
You must be signed in to change notification settings - Fork 0
Main <- Develop #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Main <- Develop #79
Conversation
최신 miain 브랜치 머지
Walkthrough테스트 데이터 초기화 관련 mock 클래스들이 삭제되고, 이미지 업로드 기능 및 프로필 이미지 처리 로직이 추가되었습니다. 일부 컨트롤러의 파라미터 이름이 수정되었으며, DTO와 예외 코드가 확장되었습니다. application.properties의 주석 형식도 변경되었습니다. Changes
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: 성공 응답 반환
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: 응답 반환
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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
📒 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: 북마크 로직 버그 수정이 중요한 개선입니다.기존에 북마크 폴더 소유자와 비교하던 것을 게시글 작성자와 비교하도록 수정한 것이 올바른 로직입니다. 자신의 게시글을 북마크하지 못하도록 하는 의도에 맞게 수정되었습니다.
이 버그 수정은 사용자가 자신의 게시글을 북마크하지 못하도록 하는 비즈니스 로직을 올바르게 구현합니다.
| @PostMapping("/images") | ||
| public Response<String> uploadImage(@RequestPart("imageFile") MultipartFile imageFile){ | ||
| String markdownImage = postService.uploadImage(imageFile); | ||
| return Response.success("이미지 마크다운 형식으로 변환", markdownImage); | ||
| } |
There was a problem hiding this comment.
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.
| @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.
작업 내용
Summary by CodeRabbit
신규 기능
버그 수정
개선 사항
테스트/모킹 데이터
기타