Skip to content
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

fix: 카페 이미지 3개 초과하여 저장 시 예외 반환하는 로직 버그 수정 #140

Merged
merged 3 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

public class ExceedCageImagesTotalCountsException extends BadRequestException{
public ExceedCageImagesTotalCountsException() {
super("카페 이미지는 3개 이상 등록하실 수 없습니다.", 2008);
super("카페 이미지는 4개 이상 등록하실 수 없습니다.", 2008);
Copy link
Member

Choose a reason for hiding this comment

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

그동안 이런 오타가 있었다니 새삼 놀랍네요ㅋㅋㅋ

}
}
2 changes: 1 addition & 1 deletion src/main/java/mocacong/server/service/CafeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public CafeImagesSaveResponse saveCafeImage(Long memberId, String mapId, List<Mu
private void validateOwnedCafeImagesCounts(Cafe cafe, Member member, List<MultipartFile> requestCafeImages) {
List<CafeImage> currentOwnedCafeImages = cafe.getCafeImages()
.stream()
.filter(cafeImage -> cafeImage.isOwned(member))
.filter(cafeImage -> cafeImage.isOwned(member) && cafeImage.getIsUsed())
Copy link
Member

Choose a reason for hiding this comment

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

cafeImage.isOwned(member) && cafeImage.getIsUsed()로 분기가 되니까 조금 이해하기 어렵더라고요. PR의 overview에 설명을 워낙 잘해주셔서 이해하긴 했는데, 코드만 보곤 어떤 조건으로 필터링되는거지? 싶었어요.

따로 이 부분을 private method로 뺀 후, 적절한 네이밍을 짓는 것도 괜찮겠네요. (근데 기가막힌 네이밍 짓기가 좀 어려울 거 같긴 해요)

Copy link
Contributor

Choose a reason for hiding this comment

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

케이님 리뷰 좋은데, 저는 여기서는 너무 많은 private 메서드는 지양하는게 좋기도 한 것 같아요.
이미 CafeService가 너무 무거워서.. UseCase layer를 하나 더 만드는것도 좋아보였어요 ㅎㅎ

Copy link
Contributor

Choose a reason for hiding this comment

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

아 그리고 filter를 두개 쓰는 방안도 있을 것 같은데, 크리티컬 하고 크진 않지만 성능 상 테스트 해보면 지금이 더 좋다고 합니다~

.collect(Collectors.toList());
if (currentOwnedCafeImages.size() + requestCafeImages.size() > CAFE_IMAGES_PER_MEMBER_LIMIT_COUNTS) {
throw new ExceedCageImagesTotalCountsException();
Expand Down