diff --git a/src/main/java/mocacong/server/exception/badrequest/ExceedCageImagesTotalCountsException.java b/src/main/java/mocacong/server/exception/badrequest/ExceedCageImagesTotalCountsException.java index b8423939..0510a098 100644 --- a/src/main/java/mocacong/server/exception/badrequest/ExceedCageImagesTotalCountsException.java +++ b/src/main/java/mocacong/server/exception/badrequest/ExceedCageImagesTotalCountsException.java @@ -2,6 +2,6 @@ public class ExceedCageImagesTotalCountsException extends BadRequestException{ public ExceedCageImagesTotalCountsException() { - super("카페 이미지는 3개 이상 등록하실 수 없습니다.", 2008); + super("카페 이미지는 4개 이상 등록하실 수 없습니다.", 2008); } } diff --git a/src/main/java/mocacong/server/service/CafeService.java b/src/main/java/mocacong/server/service/CafeService.java index c6bb9778..4727e2c7 100644 --- a/src/main/java/mocacong/server/service/CafeService.java +++ b/src/main/java/mocacong/server/service/CafeService.java @@ -350,13 +350,17 @@ public CafeImagesSaveResponse saveCafeImage(Long memberId, String mapId, List requestCafeImages) { List currentOwnedCafeImages = cafe.getCafeImages() .stream() - .filter(cafeImage -> cafeImage.isOwned(member)) + .filter(cafeImage -> isOwnedAndUsed(cafeImage, member)) .collect(Collectors.toList()); if (currentOwnedCafeImages.size() + requestCafeImages.size() > CAFE_IMAGES_PER_MEMBER_LIMIT_COUNTS) { throw new ExceedCageImagesTotalCountsException(); } } + private boolean isOwnedAndUsed(CafeImage cafeImage, Member member) { + return cafeImage.isOwned(member) && cafeImage.getIsUsed(); + } + @Transactional(readOnly = true) public CafeImagesResponse findCafeImages(Long memberId, String mapId, Integer page, int count) { Cafe cafe = cafeRepository.findByMapId(mapId)