Skip to content

Commit

Permalink
feat: 부가 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
CChuYong committed Dec 12, 2024
1 parent 04bf4e3 commit 5a0aa60
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -94,10 +95,12 @@ public Mono<AlbumEntity> addAlbum(String albumName, String albumType, String req

@Transactional
public Mono<AlbumEntity> 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())
Expand All @@ -108,12 +111,13 @@ public Mono<AlbumEntity> 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
Expand Down

0 comments on commit 5a0aa60

Please sign in to comment.