Skip to content

Commit

Permalink
refactor: add hasOwnerMemberId in photo service
Browse files Browse the repository at this point in the history
  • Loading branch information
gmkim20713 committed Jul 27, 2024
1 parent a222963 commit b54b3f4
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -66,7 +68,8 @@ public Mono<PhotoEntity> 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));
}

Expand All @@ -91,4 +94,8 @@ public Mono<PhotoEntity> updatePhotoAlbumId(String photoId, String albumId, Stri
});
}

private Boolean hasOwnerId(PhotoEntity photoEntity) {
return photoEntity.getOwnerMemberId() != null;
}

}

0 comments on commit b54b3f4

Please sign in to comment.