From 820fd84452557aedc9e7235b95e47e809773eecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=A1=EC=98=81=EB=AF=BC?= Date: Wed, 24 Jul 2024 14:32:10 +0900 Subject: [PATCH 1/2] feat: add transactional to member --- .../src/main/java/kr/mafoo/user/service/AuthService.java | 4 ++++ .../src/main/java/kr/mafoo/user/service/MemberService.java | 2 ++ 2 files changed, 6 insertions(+) diff --git a/user-service/src/main/java/kr/mafoo/user/service/AuthService.java b/user-service/src/main/java/kr/mafoo/user/service/AuthService.java index 4ace3f6..9a2ce2f 100644 --- a/user-service/src/main/java/kr/mafoo/user/service/AuthService.java +++ b/user-service/src/main/java/kr/mafoo/user/service/AuthService.java @@ -20,6 +20,7 @@ import kr.mafoo.user.util.NicknameGenerator; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; @@ -41,6 +42,7 @@ public class AuthService { private final ObjectMapper objectMapper; + @Transactional public Mono loginWithKakao(String code) { return getKakaoTokenWithCode(code) .flatMap(this::getUserInfoWithKakaoToken) @@ -52,6 +54,7 @@ public Mono loginWithKakao(String code) { )); } + @Transactional public Mono loginWithApple(String identityToken) { return getApplePublicKeys() .flatMap(keyObj -> getUserInfoWithAppleAccessToken(keyObj.keys(), identityToken)) @@ -63,6 +66,7 @@ public Mono loginWithApple(String identityToken) { )); } + @Transactional public Mono loginWithRefreshToken(String refreshToken){ return Mono .fromCallable(() -> jwtTokenService.extractUserIdFromRefreshToken(refreshToken)) diff --git a/user-service/src/main/java/kr/mafoo/user/service/MemberService.java b/user-service/src/main/java/kr/mafoo/user/service/MemberService.java index 9db3bd7..c157994 100644 --- a/user-service/src/main/java/kr/mafoo/user/service/MemberService.java +++ b/user-service/src/main/java/kr/mafoo/user/service/MemberService.java @@ -6,6 +6,7 @@ import kr.mafoo.user.util.IdGenerator; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import reactor.core.publisher.Mono; @RequiredArgsConstructor @@ -23,6 +24,7 @@ public Mono getMemberByMemberId(String memberId) { .switchIfEmpty(Mono.error(new MemberNotFoundException())); } + @Transactional public Mono createNewMember(String username, String profileImageUrl) { MemberEntity memberEntity = MemberEntity.newMember(IdGenerator.generate(), username, profileImageUrl); return memberRepository.save(memberEntity); From af85ae593d86c6be1d26a608620e7dce180d99a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=A1=EC=98=81=EB=AF=BC?= Date: Wed, 24 Jul 2024 14:32:59 +0900 Subject: [PATCH 2/2] feat: add transactional to photo --- .../src/main/java/kr/mafoo/photo/service/AlbumService.java | 7 +++++++ .../src/main/java/kr/mafoo/photo/service/PhotoService.java | 4 ++++ 2 files changed, 11 insertions(+) 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 a681ab1..87fb4cc 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 @@ -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; @@ -15,6 +16,7 @@ public class AlbumService { private final AlbumRepository albumRepository; + @Transactional public Mono createNewAlbum(String ownerMemberId, String albumName, AlbumType albumType) { AlbumEntity albumEntity = AlbumEntity.newAlbum(IdGenerator.generate(), albumName, albumType, ownerMemberId); return albumRepository.save(albumEntity); @@ -38,6 +40,7 @@ public Mono findByAlbumId(String albumId, String requestMemberId) { }); } + @Transactional public Mono deleteAlbumById(String albumId, String requestMemberId) { return albumRepository .findById(albumId) @@ -52,6 +55,7 @@ public Mono deleteAlbumById(String albumId, String requestMemberId) { }); } + @Transactional public Mono updateAlbumName(String albumId, String albumName, String requestMemberId) { return albumRepository .findById(albumId) @@ -66,6 +70,7 @@ public Mono updateAlbumName(String albumId, String albumName, Strin }); } + @Transactional public Mono updateAlbumType(String albumId, AlbumType albumType, String requestMemberId) { return albumRepository .findById(albumId) @@ -80,6 +85,7 @@ public Mono updateAlbumType(String albumId, AlbumType albumType, St }); } + @Transactional public Mono increaseAlbumPhotoCount(String albumId, String requestMemberId) { return albumRepository .findById(albumId) @@ -94,6 +100,7 @@ public Mono increaseAlbumPhotoCount(String albumId, String requestMemberId }); } + @Transactional public Mono decreaseAlbumPhotoCount(String albumId, String requestMemberId) { if (albumId == null) { 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 39fcdb0..efb2c5a 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 @@ -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; @@ -21,6 +22,7 @@ public class PhotoService { private final QrService qrService; private final ObjectStorageService objectStorageService; + @Transactional public Mono createNewPhoto(String qrUrl, String requestMemberId) { return qrService .getFileFromQrUrl(qrUrl) @@ -46,6 +48,7 @@ public Flux findAllByAlbumId(String albumId, String requestMemberId }); } + @Transactional public Mono deletePhotoById(String photoId, String requestMemberId) { return photoRepository .findById(photoId) @@ -61,6 +64,7 @@ public Mono deletePhotoById(String photoId, String requestMemberId) { }); } + @Transactional public Mono updatePhotoAlbumId(String photoId, String albumId, String requestMemberId) { return photoRepository .findById(photoId)