From 5a0aa601303a2bbaec3c13901c7684c623b6cd0a Mon Sep 17 00:00:00 2001 From: ChuYong Date: Thu, 12 Dec 2024 23:27:47 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=B6=80=EA=B0=80=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/kr/mafoo/photo/service/AlbumService.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/photo-service/src/main/java/kr/mafoo/photo/service/AlbumService.java b/photo-service/src/main/java/kr/mafoo/photo/service/AlbumService.java index 5a770b3..42cce97 100644 --- a/photo-service/src/main/java/kr/mafoo/photo/service/AlbumService.java +++ b/photo-service/src/main/java/kr/mafoo/photo/service/AlbumService.java @@ -6,6 +6,7 @@ import java.util.Comparator; import java.util.Optional; +import java.util.concurrent.atomic.AtomicInteger; import kr.mafoo.photo.domain.AlbumEntity; import kr.mafoo.photo.domain.enums.AlbumType; @@ -94,10 +95,12 @@ public Mono addAlbum(String albumName, String albumType, String req @Transactional public Mono addSumoneAlbum(String albumName, String albumType, String requestMemberId, String inviteCode) { + AtomicInteger displayIndex = new AtomicInteger(0); return albumCommand .addAlbum(albumName, albumType, requestMemberId, null) .flatMap(album -> sumoneEventMappingRepository .findByInviteCode(inviteCode) + .switchIfEmpty(Mono.error(new AlbumNotFoundException())) .flatMap(sumoneEventMappingEntity -> sumoneEventMappingRepository.delete(sumoneEventMappingEntity).then(Mono.just(sumoneEventMappingEntity))) .map(entity -> "SUMONE_" + entity.getId()) @@ -108,12 +111,13 @@ public Mono addSumoneAlbum(String albumName, String albumType, Stri photo.getPhotoUrl(), BrandType.EXTERNAL, album.getAlbumId(), - 0, + displayIndex.getAndIncrement(), requestMemberId ) ) ) - .then(Mono.just(album))); + .then(Mono.just(album))) + .flatMap(album -> albumCommand.increaseAlbumPhotoCount(album, displayIndex.get())); } @Transactional