From 9f6833b1aa36283eec92e7cd7d1de2aca1305ec4 Mon Sep 17 00:00:00 2001 From: Gyoungmin Kim Date: Sun, 28 Jul 2024 14:16:04 +0900 Subject: [PATCH] refactor: add hasOwnerMemberId in photo entity --- .../src/main/java/kr/mafoo/photo/domain/PhotoEntity.java | 4 ++++ .../src/main/java/kr/mafoo/photo/service/PhotoService.java | 6 +----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/photo-service/src/main/java/kr/mafoo/photo/domain/PhotoEntity.java b/photo-service/src/main/java/kr/mafoo/photo/domain/PhotoEntity.java index dd908ce..6785e82 100644 --- a/photo-service/src/main/java/kr/mafoo/photo/domain/PhotoEntity.java +++ b/photo-service/src/main/java/kr/mafoo/photo/domain/PhotoEntity.java @@ -62,6 +62,10 @@ public String getId() { return photoId; } + public Boolean hasOwnerMemberId() { + return this.getOwnerMemberId() != null; + } + public PhotoEntity updateOwnerMemberId(String ownerMemberId) { this.ownerMemberId = ownerMemberId; return this; 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 1fe2f14..aa20342 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 @@ -69,7 +69,7 @@ public Mono updatePhotoAlbumId(String photoId, String albumId, Stri .switchIfEmpty(Mono.error(new PhotoNotFoundException())) .flatMap(photoEntity -> { - if (!hasOwnerId(photoEntity)) { + if (!photoEntity.hasOwnerMemberId()) { photoRepository.save(photoEntity.updateOwnerMemberId(requestMemberId)); } @@ -94,8 +94,4 @@ public Mono updatePhotoAlbumId(String photoId, String albumId, Stri }); } - private Boolean hasOwnerId(PhotoEntity photoEntity) { - return photoEntity.getOwnerMemberId() != null; - } - }