-
Notifications
You must be signed in to change notification settings - Fork 0
Develop #102
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
Develop #102
Conversation
Walkthrough이 변경사항은 게시글 및 태그 관련 서비스의 입력 검증, 권한 확인, 이미지 URL 기본값 처리, 예외 처리, DTO 필드 타입 및 생성자 개선 등을 포함합니다. 태그는 이제 이름으로 조회하며, 게시글 수정 시 작성자 본인만 가능하도록 권한 검사가 추가되었습니다. 기본 이미지 URL 처리 메서드가 프로필과 커버로 분리되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant PostService
participant TagRepository
participant PostRepository
User->>PostService: editPost(postId, postRequestDto)
PostService->>PostRepository: findById(postId)
PostRepository-->>PostService: Post
PostService->>Post: check if currentUser == post.author
alt Not Author
PostService-->>User: throw POST_UPDATE_FORBIDDEN
else Author
PostService->>TagRepository: findByTagName for each tagName
TagRepository-->>PostService: Tag list
PostService->>Post: update fields
PostService->>PostRepository: save(Post)
PostRepository-->>PostService: Post
PostService-->>User: Success
end
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (5)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (3)
🔇 Additional comments (1)
✨ 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: 6
🧹 Nitpick comments (1)
src/main/java/com/example/FixLog/repository/tag/TagRepository.java (1)
12-12: 태그 이름 기반 조회 메서드 추가 확인
findByTagName메서드가 추가되어 문자열 기반 태그 조회를 지원합니다. 메서드 시그니처가 적절합니다.성능 최적화를 위해
tagName필드에 인덱스 추가를 고려해보세요:CREATE INDEX idx_tag_name ON tag(tag_name);문자열 기반 조회는 ID 기반 조회보다 성능이 떨어질 수 있으므로 데이터베이스 인덱스 최적화가 중요합니다.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
src/main/java/com/example/FixLog/domain/tag/Tag.java(1 hunks)src/main/java/com/example/FixLog/dto/post/MyPostPageResponseDto.java(1 hunks)src/main/java/com/example/FixLog/dto/post/NewPostRequestDto.java(1 hunks)src/main/java/com/example/FixLog/dto/post/PostRequestDto.java(1 hunks)src/main/java/com/example/FixLog/exception/CustomException.java(1 hunks)src/main/java/com/example/FixLog/exception/ErrorCode.java(1 hunks)src/main/java/com/example/FixLog/mock/TagMockDataInitializer.java(1 hunks)src/main/java/com/example/FixLog/repository/tag/TagRepository.java(1 hunks)src/main/java/com/example/FixLog/service/MainPageService.java(5 hunks)src/main/java/com/example/FixLog/service/PostService.java(8 hunks)
🔇 Additional comments (13)
src/main/java/com/example/FixLog/dto/post/PostRequestDto.java (1)
20-20: API 계약 변경에 대한 영향 검증 필요
tags필드 타입이List<Long>에서List<String>으로 변경되었습니다. 이는 API 계약의 중대한 변경사항입니다.다음 스크립트를 실행하여 모든 호출부가 업데이트되었는지 확인해주세요:
#!/bin/bash # Description: PostRequestDto 사용처 검증 및 tags 필드 접근 패턴 확인 # PostRequestDto 사용처 찾기 echo "=== PostRequestDto 사용처 ===" rg -A 5 -B 5 "PostRequestDto" # tags 필드에 Long 타입으로 접근하는 코드가 남아있는지 확인 echo "=== tags 필드 Long 타입 접근 패턴 확인 ===" rg -A 3 -B 3 "\.getTags\(\).*Long|Long.*\.getTags\(\)"src/main/java/com/example/FixLog/dto/post/NewPostRequestDto.java (1)
20-20: PostRequestDto와 일관성 유지 확인
PostRequestDto와 동일하게tags필드 타입을List<String>으로 변경하여 일관성을 유지했습니다. 이는 올바른 접근입니다.단, 이 변경사항도 API 계약 변경이므로 모든 클라이언트 코드가 업데이트되었는지 확인이 필요합니다.
src/main/java/com/example/FixLog/repository/tag/TagRepository.java (1)
8-8: 필요한 import 추가 확인
Optionalimport가 새로 추가된findByTagName메서드를 위해 적절히 추가되었습니다.src/main/java/com/example/FixLog/domain/tag/Tag.java (2)
26-31: 간소화된 팩토리 메서드 추가 확인
tagInfo없이 태그를 생성할 수 있는 새로운 팩토리 메서드가 추가되었습니다. 코드 구조가 올바르고 기존 메서드와 일관성을 유지합니다.
24-24: 데이터베이스 제약 조건 변경에 대한 검증 필요
tagInfo필드에서@Column(nullable = false)제약 조건이 제거되었습니다. 이는 데이터베이스 스키마 변경을 의미합니다.다음 사항들을 확인해주세요:
- 데이터베이스 마이그레이션 스크립트 필요성
- 기존 데이터 무결성 확인
- 애플리케이션 레벨에서의 검증 로직 필요 여부
다음 스크립트로 관련 사용처를 확인할 수 있습니다:
#!/bin/bash # Description: tagInfo 필드 사용처 및 null 체크 패턴 확인 # tagInfo 필드 접근 패턴 확인 echo "=== tagInfo 필드 사용처 ===" rg -A 3 -B 3 "\.getTagInfo\(\)|tagInfo" # null 체크가 필요한 곳 찾기 echo "=== tagInfo null 체크 패턴 ===" rg -A 5 -B 5 "tagInfo.*null|null.*tagInfo"src/main/java/com/example/FixLog/exception/CustomException.java (1)
9-18: 명시적 생성자 구현이 적절합니다.Lombok 의존성을 제거하고 두 개의 생성자를 명시적으로 구현한 것이 좋습니다. 이를 통해 상황에 따라 기본 에러 메시지 또는 커스텀 메시지를 유연하게 사용할 수 있게 되었습니다.
src/main/java/com/example/FixLog/mock/TagMockDataInitializer.java (1)
35-74: 태그 생성 로직이 간소화되어 좋습니다.Tag.of() 메서드 호출이 단순화되어 코드 가독성이 향상되었습니다. MINOR_CATEGORY만 추가 정보를 유지하는 것도 적절해 보입니다.
src/main/java/com/example/FixLog/service/MainPageService.java (2)
56-56: 비로그인 사용자 기본 이미지 URL 통일이 적절합니다.프로필 이미지 기본값을 일관되게 사용하도록 수정한 것이 좋습니다.
Also applies to: 102-102
54-54: 이미지 처리 메서드가 적절하게 적용되었습니다.프로필과 썸네일 이미지를 구분하여 처리하도록 메서드를 올바르게 사용하고 있습니다.
Also applies to: 77-81, 100-100, 119-123
src/main/java/com/example/FixLog/dto/post/MyPostPageResponseDto.java (1)
49-50: from 메서드가 적절하게 업데이트되었습니다.프로필과 커버 이미지를 구분하여 처리하도록 잘 구현되었습니다.
src/main/java/com/example/FixLog/service/PostService.java (3)
111-148: 태그 처리 방식 개선이 잘 되었습니다.태그를 ID 대신 이름으로 처리하도록 변경한 것이 좋습니다. 또한 에러 메시지를 더 구체적으로 제공하도록 개선한 것도 적절합니다.
190-193: 권한 검사 및 유효성 검증 추가가 적절합니다.게시글 수정 시 작성자 본인만 수정할 수 있도록 권한 검사를 추가하고, 수정 내용의 유효성도 검증하도록 한 것이 좋은 보안 개선입니다.
Also applies to: 214-214
255-255: 이미지 처리 메서드가 적절하게 적용되었습니다.조회 시에도 프로필과 커버 이미지를 구분하여 처리하도록 잘 구현되었습니다.
Also applies to: 275-275, 283-283
| // 이미지 null일 때 default 사진으로 변경 - 프로필 사진 | ||
| public String getDefaultProfile(String image){ | ||
| String imageUrl = (image == null || image.isBlank()) | ||
| ? "https://fixlog-bucket.s3.ap-northeast-2.amazonaws.com/default/profile.png" : image; | ||
| System.out.println(imageUrl); | ||
| return imageUrl; | ||
| } | ||
| // 이미지 null일 때 default 사진으로 변경 - 썸네일 | ||
| public String getDefaultCover(String image){ | ||
| String imageUrl = (image == null || image.isBlank()) | ||
| ? "https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaulThumnail.png" : image; | ||
| System.out.println(imageUrl); | ||
| return imageUrl; | ||
| } |
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.
이미지 타입별 메서드 분리는 좋으나 URL 오타 수정 필요
프로필과 썸네일 이미지를 구분하여 처리하는 것은 좋은 설계입니다. 하지만 40번 라인의 URL에 오타가 있습니다.
- ? "https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaulThumnail.png" : image;
+ ? "https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaultThumbnail.png" : image;📝 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.
| // 이미지 null일 때 default 사진으로 변경 - 프로필 사진 | |
| public String getDefaultProfile(String image){ | |
| String imageUrl = (image == null || image.isBlank()) | |
| ? "https://fixlog-bucket.s3.ap-northeast-2.amazonaws.com/default/profile.png" : image; | |
| System.out.println(imageUrl); | |
| return imageUrl; | |
| } | |
| // 이미지 null일 때 default 사진으로 변경 - 썸네일 | |
| public String getDefaultCover(String image){ | |
| String imageUrl = (image == null || image.isBlank()) | |
| ? "https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaulThumnail.png" : image; | |
| System.out.println(imageUrl); | |
| return imageUrl; | |
| } | |
| // 이미지 null일 때 default 사진으로 변경 - 썸네일 | |
| public String getDefaultCover(String image){ | |
| String imageUrl = (image == null || image.isBlank()) | |
| ? "https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaultThumbnail.png" : image; | |
| System.out.println(imageUrl); | |
| return imageUrl; | |
| } |
🤖 Prompt for AI Agents
In src/main/java/com/example/FixLog/service/MainPageService.java between lines
30 and 43, the URL in the getDefaultCover method contains a typo in the bucket
name and the default thumbnail filename. Correct the URL to match the proper
bucket name and filename format, ensuring it is consistent with the profile
image URL style and points to the correct resource.
src/main/java/com/example/FixLog/dto/post/MyPostPageResponseDto.java
Outdated
Show resolved
Hide resolved
| // 이미지 null일 때 default 사진으로 변경 - 프로필 사진 | ||
| public static String getDefaultProfile(String image){ | ||
| String imageUrl = (image == null || image.isBlank()) | ||
| ? "https://fixlog-bucket.s3.ap-northeast-2.amazonaws.com/default/profile.png" : image; | ||
| System.out.println(imageUrl); | ||
| return imageUrl; | ||
| } | ||
| // 이미지 null일 때 default 사진으로 변경 - 썸네일 | ||
| public static String getDefaultCover(String image){ | ||
| String imageUrl = (image == null || image.isBlank()) | ||
| ? "https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaulThumnail.png" : image; | ||
| System.out.println(imageUrl); | ||
| return imageUrl; | ||
| } |
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.
URL 오타 수정 필요
기본 이미지 처리 메서드 추가는 좋으나, 38번 라인의 URL에 오타가 있습니다.
- ? "https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaulThumnail.png" : image;
+ ? "https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaultThumbnail.png" : image;📝 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.
| // 이미지 null일 때 default 사진으로 변경 - 프로필 사진 | |
| public static String getDefaultProfile(String image){ | |
| String imageUrl = (image == null || image.isBlank()) | |
| ? "https://fixlog-bucket.s3.ap-northeast-2.amazonaws.com/default/profile.png" : image; | |
| System.out.println(imageUrl); | |
| return imageUrl; | |
| } | |
| // 이미지 null일 때 default 사진으로 변경 - 썸네일 | |
| public static String getDefaultCover(String image){ | |
| String imageUrl = (image == null || image.isBlank()) | |
| ? "https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaulThumnail.png" : image; | |
| System.out.println(imageUrl); | |
| return imageUrl; | |
| } | |
| // 이미지 null일 때 default 사진으로 변경 - 프로필 사진 | |
| public static String getDefaultProfile(String image){ | |
| String imageUrl = (image == null || image.isBlank()) | |
| ? "https://fixlog-bucket.s3.ap-northeast-2.amazonaws.com/default/profile.png" : image; | |
| System.out.println(imageUrl); | |
| return imageUrl; | |
| } | |
| // 이미지 null일 때 default 사진으로 변경 - 썸네일 | |
| public static String getDefaultCover(String image){ | |
| String imageUrl = (image == null || image.isBlank()) | |
| ? "https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaultThumbnail.png" : image; | |
| System.out.println(imageUrl); | |
| return imageUrl; | |
| } |
🤖 Prompt for AI Agents
In src/main/java/com/example/FixLog/dto/post/MyPostPageResponseDto.java between
lines 28 and 41, the URL in the getDefaultCover method contains a typo in the
domain name. Correct the URL by fixing the domain from "fixlogsmwubucket" to the
proper bucket name, ensuring it matches the intended S3 bucket URL for the
default thumbnail image.
| // 이미지 null일 때 default 사진으로 변경 - 프로필 사진 | ||
| public String getDefaultProfile(String image){ | ||
| String imageUrl = (image == null || image.isBlank()) | ||
| ? "https://fixlog-bucket.s3.ap-northeast-2.amazonaws.com/default/profile.png" : image; | ||
| System.out.println(imageUrl); | ||
| return imageUrl; | ||
| } | ||
| // 이미지 null일 때 default 사진으로 변경 - 썸네일 | ||
| public String getDefaultCover(String image){ | ||
| String imageUrl = (image == null || image.isBlank()) | ||
| ? "https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaulThumnail.png" : image; | ||
| System.out.println(imageUrl); | ||
| return imageUrl; | ||
| } |
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.
이미지 타입별 메서드 분리는 좋으나 URL 오타 수정 필요
프로필과 썸네일 이미지를 구분하는 것은 좋은 설계입니다. 하지만 68번 라인의 URL에 오타가 있습니다.
- ? "https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaulThumnail.png" : image;
+ ? "https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaultThumbnail.png" : image;🤖 Prompt for AI Agents
In src/main/java/com/example/FixLog/service/PostService.java between lines 58
and 71, the getDefaultCover method contains a typo in the default thumbnail URL
on line 68. Correct the URL by fixing the misspelled bucket name or path segment
to match the intended S3 bucket and file name, ensuring the URL is valid and
consistent with the profile image URL format.
작업 내용
Summary by CodeRabbit
신규 기능
버그 수정
기타