From 4210ea382ab87d29255e9a635466dffb1ebf5bdc Mon Sep 17 00:00:00 2001 From: rumos Date: Thu, 5 Sep 2024 19:03:04 +0900 Subject: [PATCH] =?UTF-8?q?[test]=20photo=5Frequest=20=ED=85=8C=EC=9D=B4?= =?UTF-8?q?=EB=B8=94=EC=97=90=20=EB=B9=84=EA=B4=80=EC=A0=81=20=EB=9D=BD?= =?UTF-8?q?=EC=9D=84=20=EC=A0=81=EC=9A=A9=ED=95=B4=20=EB=8F=99=EC=8B=9C?= =?UTF-8?q?=EC=84=B1=20=EB=AC=B8=EC=A0=9C=20=ED=95=B4=EA=B2=B0=ED=95=98?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../puangbe/photo/entity/PhotoRequest.java | 12 ---------- .../repository/PhotoRequestRepository.java | 3 +++ .../photo/service/PhotoServiceImpl.java | 24 +++++++------------ .../service/PhotoRequestServiceImpl.java | 8 +------ 4 files changed, 13 insertions(+), 34 deletions(-) diff --git a/src/main/java/gdsc/cau/puangbe/photo/entity/PhotoRequest.java b/src/main/java/gdsc/cau/puangbe/photo/entity/PhotoRequest.java index 13db085..c46ebca 100644 --- a/src/main/java/gdsc/cau/puangbe/photo/entity/PhotoRequest.java +++ b/src/main/java/gdsc/cau/puangbe/photo/entity/PhotoRequest.java @@ -46,9 +46,6 @@ public class PhotoRequest { @OneToMany(mappedBy = "request", cascade = {CascadeType.PERSIST, CascadeType.REMOVE}) private List photoUrls = new ArrayList<>(); - @Version - private Long version; - @Builder public PhotoRequest(User user, Gender gender, List urls, String email) { this.user = user; @@ -69,13 +66,4 @@ public void modifyEmail(String email) { this.email = email; this.updateDate = LocalDateTime.now(); } - - @Override - public String toString() { - return "PhotoRequest{" + - "id=" + id + - ", email='" + email + '\'' + - ", version=" + version + - '}'; - } } diff --git a/src/main/java/gdsc/cau/puangbe/photo/repository/PhotoRequestRepository.java b/src/main/java/gdsc/cau/puangbe/photo/repository/PhotoRequestRepository.java index 07d1197..bf00b71 100644 --- a/src/main/java/gdsc/cau/puangbe/photo/repository/PhotoRequestRepository.java +++ b/src/main/java/gdsc/cau/puangbe/photo/repository/PhotoRequestRepository.java @@ -12,8 +12,11 @@ @Repository public interface PhotoRequestRepository extends JpaRepository { + + @Lock(LockModeType.PESSIMISTIC_WRITE) Optional findById(Long photoRequestId); // 특정 유저의 최근에 만들어진 PhotoRequest 조회 + @Lock(LockModeType.PESSIMISTIC_WRITE) Optional findTopByUserIdOrderByCreateDateDesc(Long photoRequestId); } diff --git a/src/main/java/gdsc/cau/puangbe/photo/service/PhotoServiceImpl.java b/src/main/java/gdsc/cau/puangbe/photo/service/PhotoServiceImpl.java index 9e4d178..6909a4d 100644 --- a/src/main/java/gdsc/cau/puangbe/photo/service/PhotoServiceImpl.java +++ b/src/main/java/gdsc/cau/puangbe/photo/service/PhotoServiceImpl.java @@ -42,12 +42,6 @@ public class PhotoServiceImpl implements PhotoService { // 완성된 요청 id 및 imageUrl을 받아 저장 @Override @Transactional - @Lock(LockModeType.OPTIMISTIC) - @Retryable( - retryFor = {ObjectOptimisticLockingFailureException.class}, - maxAttempts = 1000, - backoff = @Backoff(100) - ) public void uploadPhoto(Long photoRequestId, String imageUrl) { // 예외처리 PhotoRequest photoRequest = photoRequestRepository.findById(photoRequestId) @@ -65,18 +59,18 @@ public void uploadPhoto(Long photoRequestId, String imageUrl) { photoResult.update(imageUrl); photoResultRepository.save(photoResult); - log.info("uploadPhoto - PhotoRequest version: {}", photoRequest.getVersion()); + log.info("upload photo"); // 이메일 발송 - EmailInfo emailInfo = EmailInfo.builder() - .email(photoRequest.getEmail()) - .photoUrl(imageUrl) - .name(user.getUserName()) - .framePageUrl("https://www.google.com/") // TODO : 프론트 분들 링크 관련 답변 오면 프레임 페이지 링크 관련 수정 - .build(); - - sendEmail(emailInfo); +// EmailInfo emailInfo = EmailInfo.builder() +// .email(photoRequest.getEmail()) +// .photoUrl(imageUrl) +// .name(user.getUserName()) +// .framePageUrl("https://www.google.com/") // TODO : 프론트 분들 링크 관련 답변 오면 프레임 페이지 링크 관련 수정 +// .build(); +// +// sendEmail(emailInfo); } // 특정 요청의 imageUrl 조회 diff --git a/src/main/java/gdsc/cau/puangbe/photorequest/service/PhotoRequestServiceImpl.java b/src/main/java/gdsc/cau/puangbe/photorequest/service/PhotoRequestServiceImpl.java index 63a7092..d8eb6c3 100644 --- a/src/main/java/gdsc/cau/puangbe/photorequest/service/PhotoRequestServiceImpl.java +++ b/src/main/java/gdsc/cau/puangbe/photorequest/service/PhotoRequestServiceImpl.java @@ -131,12 +131,6 @@ public String getRequestStatus(Long userId){ @Override @Transactional - @Lock(LockModeType.OPTIMISTIC) - @Retryable( - retryFor = {ObjectOptimisticLockingFailureException.class}, - maxAttempts = 1000, - backoff = @Backoff(100) - ) public Long updateEmail(Long userId, String email) { // 가장 최근의 PhotoRequest 조회 @@ -146,7 +140,7 @@ public Long updateEmail(Long userId, String email) { photoRequest.modifyEmail(email); photoRequestRepository.save(photoRequest); - log.info("updateEmail - PhotoRequest version: {}", photoRequest.getVersion()); + log.info("update email"); return photoRequest.getId(); }