diff --git a/photo-service/src/main/java/kr/mafoo/photo/service/PhotoService.java b/photo-service/src/main/java/kr/mafoo/photo/service/PhotoService.java index be3d734..1fe2f14 100644 --- a/photo-service/src/main/java/kr/mafoo/photo/service/PhotoService.java +++ b/photo-service/src/main/java/kr/mafoo/photo/service/PhotoService.java @@ -7,10 +7,12 @@ import kr.mafoo.photo.repository.PhotoRepository; import kr.mafoo.photo.util.IdGenerator; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; +@Slf4j @RequiredArgsConstructor @Service public class PhotoService { @@ -66,7 +68,8 @@ public Mono updatePhotoAlbumId(String photoId, String albumId, Stri .findById(photoId) .switchIfEmpty(Mono.error(new PhotoNotFoundException())) .flatMap(photoEntity -> { - if (photoEntity.getOwnerMemberId() == null) { + + if (!hasOwnerId(photoEntity)) { photoRepository.save(photoEntity.updateOwnerMemberId(requestMemberId)); } @@ -91,4 +94,8 @@ public Mono updatePhotoAlbumId(String photoId, String albumId, Stri }); } + private Boolean hasOwnerId(PhotoEntity photoEntity) { + return photoEntity.getOwnerMemberId() != null; + } + }