Skip to content

Commit

Permalink
feat : add photo entity ownerMemberId checkout and setting logic if null
Browse files Browse the repository at this point in the history
  • Loading branch information
gmkim20713 committed Jul 27, 2024
1 parent 4b20ec0 commit a222963
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public Flux<PhotoEntity> findAllByAlbumId(String albumId, String requestMemberId
.findById(albumId)
.switchIfEmpty(Mono.error(new AlbumNotFoundException()))
.flatMapMany(albumEntity -> {
if(!albumEntity.getOwnerMemberId().equals(requestMemberId)) {
if (!albumEntity.getOwnerMemberId().equals(requestMemberId)) {
// 내 앨범이 아니면 그냥 없는 앨범 처리
return Mono.error(new AlbumNotFoundException());
} else {
Expand All @@ -51,7 +51,7 @@ public Mono<Void> deletePhotoById(String photoId, String requestMemberId) {
.findById(photoId)
.switchIfEmpty(Mono.error(new PhotoNotFoundException()))
.flatMap(photoEntity -> {
if(!photoEntity.getOwnerMemberId().equals(requestMemberId)) {
if (!photoEntity.getOwnerMemberId().equals(requestMemberId)) {
// 내 사진이 아니면 그냥 없는 사진 처리
return Mono.error(new PhotoNotFoundException());
} else {
Expand All @@ -66,15 +66,19 @@ public Mono<PhotoEntity> updatePhotoAlbumId(String photoId, String albumId, Stri
.findById(photoId)
.switchIfEmpty(Mono.error(new PhotoNotFoundException()))
.flatMap(photoEntity -> {
if(!photoEntity.getOwnerMemberId().equals(requestMemberId)) {
if (photoEntity.getOwnerMemberId() == null) {
photoRepository.save(photoEntity.updateOwnerMemberId(requestMemberId));
}

if (!photoEntity.getOwnerMemberId().equals(requestMemberId)) {
// 내 사진이 아니면 그냥 없는 사진 처리
return Mono.error(new PhotoNotFoundException());
} else {
return albumRepository
.findById(albumId)
.switchIfEmpty(Mono.error(new AlbumNotFoundException()))
.flatMap(albumEntity -> {
if(!albumEntity.getOwnerMemberId().equals(requestMemberId)) {
if (!albumEntity.getOwnerMemberId().equals(requestMemberId)) {
// 내 앨범이 아니면 그냥 없는 앨범 처리
return Mono.error(new AlbumNotFoundException());
} else {
Expand Down

0 comments on commit a222963

Please sign in to comment.