Skip to content

Commit

Permalink
feat: add transactional to photo
Browse files Browse the repository at this point in the history
  • Loading branch information
CChuYong committed Jul 24, 2024
1 parent 820fd84 commit af85ae5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import kr.mafoo.photo.util.IdGenerator;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

Expand All @@ -15,6 +16,7 @@
public class AlbumService {
private final AlbumRepository albumRepository;

@Transactional
public Mono<AlbumEntity> createNewAlbum(String ownerMemberId, String albumName, AlbumType albumType) {
AlbumEntity albumEntity = AlbumEntity.newAlbum(IdGenerator.generate(), albumName, albumType, ownerMemberId);
return albumRepository.save(albumEntity);
Expand All @@ -38,6 +40,7 @@ public Mono<AlbumEntity> findByAlbumId(String albumId, String requestMemberId) {
});
}

@Transactional
public Mono<Void> deleteAlbumById(String albumId, String requestMemberId) {
return albumRepository
.findById(albumId)
Expand All @@ -52,6 +55,7 @@ public Mono<Void> deleteAlbumById(String albumId, String requestMemberId) {
});
}

@Transactional
public Mono<AlbumEntity> updateAlbumName(String albumId, String albumName, String requestMemberId) {
return albumRepository
.findById(albumId)
Expand All @@ -66,6 +70,7 @@ public Mono<AlbumEntity> updateAlbumName(String albumId, String albumName, Strin
});
}

@Transactional
public Mono<AlbumEntity> updateAlbumType(String albumId, AlbumType albumType, String requestMemberId) {
return albumRepository
.findById(albumId)
Expand All @@ -80,6 +85,7 @@ public Mono<AlbumEntity> updateAlbumType(String albumId, AlbumType albumType, St
});
}

@Transactional
public Mono<Void> increaseAlbumPhotoCount(String albumId, String requestMemberId) {
return albumRepository
.findById(albumId)
Expand All @@ -94,6 +100,7 @@ public Mono<Void> increaseAlbumPhotoCount(String albumId, String requestMemberId
});
}

@Transactional
public Mono<Void> decreaseAlbumPhotoCount(String albumId, String requestMemberId) {

if (albumId == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import kr.mafoo.photo.util.IdGenerator;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

Expand All @@ -21,6 +22,7 @@ public class PhotoService {
private final QrService qrService;
private final ObjectStorageService objectStorageService;

@Transactional
public Mono<PhotoEntity> createNewPhoto(String qrUrl, String requestMemberId) {
return qrService
.getFileFromQrUrl(qrUrl)
Expand All @@ -46,6 +48,7 @@ public Flux<PhotoEntity> findAllByAlbumId(String albumId, String requestMemberId
});
}

@Transactional
public Mono<Void> deletePhotoById(String photoId, String requestMemberId) {
return photoRepository
.findById(photoId)
Expand All @@ -61,6 +64,7 @@ public Mono<Void> deletePhotoById(String photoId, String requestMemberId) {
});
}

@Transactional
public Mono<PhotoEntity> updatePhotoAlbumId(String photoId, String albumId, String requestMemberId) {
return photoRepository
.findById(photoId)
Expand Down

0 comments on commit af85ae5

Please sign in to comment.