From 6059af30e4fdd95025731a9620574c080ff32f28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=8F=99=EC=B0=AC?= <129833370+dongchandev@users.noreply.github.com> Date: Tue, 18 Jun 2024 18:19:54 +0900 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20get=20valid=20night=20study=20?= =?UTF-8?q?=ED=95=99,=EB=B0=98,=EB=B2=88=ED=98=B8=EB=A1=9C=20=EC=A0=95?= =?UTF-8?q?=EB=A0=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/usecase/MemberCommandUseCase.java | 2 +- .../b1nd/dodamapi/upload/UploadController.java | 2 +- .../wakeupsong/usecase/WakeupSongUseCase.java | 16 +++++++++------- .../repository/NightStudyRepository.java | 4 +++- .../wakeupsong/application/VideoClient.java | 4 +++- .../dodaminfra/api/youtube/YoutubeClient.java | 6 ++++-- 6 files changed, 21 insertions(+), 13 deletions(-) diff --git a/dodam-api/src/main/java/b1nd/dodamapi/member/usecase/MemberCommandUseCase.java b/dodam-api/src/main/java/b1nd/dodamapi/member/usecase/MemberCommandUseCase.java index aa970eca..9db1459b 100644 --- a/dodam-api/src/main/java/b1nd/dodamapi/member/usecase/MemberCommandUseCase.java +++ b/dodam-api/src/main/java/b1nd/dodamapi/member/usecase/MemberCommandUseCase.java @@ -126,7 +126,7 @@ public Response updateMemberInfo(UpdateMemberInfoReq req) { Member member = service.getMemberFromSession(); member.updateInfo(req.name(), req.email(), req.phone(), req.profileImage()); - service.save(member); +// service.save(member); return Response.noContent("내 정보 수정 성공"); } diff --git a/dodam-api/src/main/java/b1nd/dodamapi/upload/UploadController.java b/dodam-api/src/main/java/b1nd/dodamapi/upload/UploadController.java index e575f581..4058920c 100644 --- a/dodam-api/src/main/java/b1nd/dodamapi/upload/UploadController.java +++ b/dodam-api/src/main/java/b1nd/dodamapi/upload/UploadController.java @@ -12,7 +12,7 @@ @RestController @RequestMapping("/upload") @RequiredArgsConstructor -public class UploadController { +public class UploadController { private final UploadService uploadService; diff --git a/dodam-api/src/main/java/b1nd/dodamapi/wakeupsong/usecase/WakeupSongUseCase.java b/dodam-api/src/main/java/b1nd/dodamapi/wakeupsong/usecase/WakeupSongUseCase.java index 17df1c14..7d6fac31 100644 --- a/dodam-api/src/main/java/b1nd/dodamapi/wakeupsong/usecase/WakeupSongUseCase.java +++ b/dodam-api/src/main/java/b1nd/dodamapi/wakeupsong/usecase/WakeupSongUseCase.java @@ -62,15 +62,17 @@ public ResponseData> getMyWakeupSong(){ @Transactional(rollbackFor = Exception.class) public CompletableFuture createWakeupSong(String videoUrl) { Member member = verifyAlreadyAppliedFromSession(); - return CompletableFuture.supplyAsync(() -> { - String videoId = YoutubeApiUtil.getVideoId(videoUrl); - YoutubeApiRes.Snippet snippet = videoClient.getVideo(videoId).getItems().get(0).getSnippet(); - checkValidVideoType(snippet.getTitle()); - buildAndSaveWakeupSong(snippet, videoId,videoUrl,member); - return Response.created("기상송 신청 성공"); - }).exceptionally(this::handleExceptionOnCreateWakeupSong); + String videoId = YoutubeApiUtil.getVideoId(videoUrl); + return videoClient.getVideo(videoId) + .thenApply(videoResponse -> { + YoutubeApiRes.Snippet snippet = videoResponse.getItems().get(0).getSnippet(); + checkValidVideoType(snippet.getTitle()); + buildAndSaveWakeupSong(snippet, videoId, videoUrl, member); + return Response.created("기상송 신청 성공"); + }).exceptionally(this::handleExceptionOnCreateWakeupSong); } + @Transactional(rollbackFor = Exception.class) public CompletableFuture createWakeupSongByYoutubeSearch(ApplyWakeupSongBySearchReq req){ Member member = verifyAlreadyAppliedFromSession(); diff --git a/dodam-core/src/main/java/b1nd/dodamcore/nightstudy/repository/NightStudyRepository.java b/dodam-core/src/main/java/b1nd/dodamcore/nightstudy/repository/NightStudyRepository.java index 998ba5e1..bbb3ec8f 100644 --- a/dodam-core/src/main/java/b1nd/dodamcore/nightstudy/repository/NightStudyRepository.java +++ b/dodam-core/src/main/java/b1nd/dodamcore/nightstudy/repository/NightStudyRepository.java @@ -40,7 +40,9 @@ List findValidStudyByStudentAndDate(@Param("student") Student studen List findByStatus(NightStudyStatus status); @EntityGraph(attributePaths = {"student.member"}) - @Query("select n from NightStudy n where n.endAt >= :now and n.startAt <= :now and n.status = :status") + @Query("select n from NightStudy n join n.student s join s.member m " + + "where n.endAt >= :now and n.startAt <= :now and n.status = :status " + + "order by n.student.grade, n.student.room, n.student.number") List findAllowedStudyByDate(@Param("now") LocalDate now, @Param("status") NightStudyStatus status); } \ No newline at end of file diff --git a/dodam-core/src/main/java/b1nd/dodamcore/wakeupsong/application/VideoClient.java b/dodam-core/src/main/java/b1nd/dodamcore/wakeupsong/application/VideoClient.java index 48e13743..f99244c5 100644 --- a/dodam-core/src/main/java/b1nd/dodamcore/wakeupsong/application/VideoClient.java +++ b/dodam-core/src/main/java/b1nd/dodamcore/wakeupsong/application/VideoClient.java @@ -2,9 +2,11 @@ import b1nd.dodamcore.wakeupsong.application.dto.res.YoutubeApiRes; +import java.util.concurrent.CompletableFuture; + public interface VideoClient { - YoutubeApiRes.Video getVideo(String videoId); + CompletableFuture getVideo(String videoId); YoutubeApiRes.Search searchVideoByKeyword(String keyword, int size); } diff --git a/dodam-infra/src/main/java/b1nd/dodaminfra/api/youtube/YoutubeClient.java b/dodam-infra/src/main/java/b1nd/dodaminfra/api/youtube/YoutubeClient.java index 699f6f2c..3ea3f7a6 100644 --- a/dodam-infra/src/main/java/b1nd/dodaminfra/api/youtube/YoutubeClient.java +++ b/dodam-infra/src/main/java/b1nd/dodaminfra/api/youtube/YoutubeClient.java @@ -7,6 +7,8 @@ import org.springframework.stereotype.Component; import org.springframework.web.util.UriComponentsBuilder; +import java.util.concurrent.CompletableFuture; + @Component @RequiredArgsConstructor public class YoutubeClient implements VideoClient { @@ -15,12 +17,12 @@ public class YoutubeClient implements VideoClient { private final WebClientSupport webClientSupport; @Override - public YoutubeApiRes.Video getVideo(String videoId) { + public CompletableFuture getVideo(String videoId) { return webClientSupport.get( UriComponentsBuilder.fromUriString(youtubeProperties.url().getVideo()) .build(youtubeProperties.getApiKey(), videoId).toString(), YoutubeApiRes.Video.class - ).block(); + ).toFuture(); } @Override From 0148609f60b0d7a12452b8ee5638af7410d677f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=8F=99=EC=B0=AC?= <129833370+dongchandev@users.noreply.github.com> Date: Tue, 18 Jun 2024 18:23:37 +0900 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=EC=9C=A0=ED=9A=A8=ED=95=9C=20?= =?UTF-8?q?=EC=99=B8=EB=B0=95=20=ED=95=99,=EB=B0=98,=EB=B2=88=ED=98=B8?= =?UTF-8?q?=EB=A1=9C=20=EC=A0=95=EB=A0=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../outsleeping/repository/OutSleepingRepository.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dodam-core/src/main/java/b1nd/dodamcore/outsleeping/repository/OutSleepingRepository.java b/dodam-core/src/main/java/b1nd/dodamcore/outsleeping/repository/OutSleepingRepository.java index d79a330d..7ec781b7 100644 --- a/dodam-core/src/main/java/b1nd/dodamcore/outsleeping/repository/OutSleepingRepository.java +++ b/dodam-core/src/main/java/b1nd/dodamcore/outsleeping/repository/OutSleepingRepository.java @@ -21,7 +21,8 @@ default OutSleeping getById(Long id) { } @EntityGraph(attributePaths = {"student.member"}) - @Query("select o from OutSleeping o where :date between o.startAt and o.endAt") + @Query("select o from OutSleeping o where :date between o.startAt and o.endAt " + + "order by o.student.grade, o.student.room, o.student.number") List findByDate(@Param("date") LocalDate date); @EntityGraph(attributePaths = {"student.member"}) From 673552ab757d9b58f8f7c7f060b06d1206b6e1d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=8F=99=EC=B0=AC?= <129833370+dongchandev@users.noreply.github.com> Date: Wed, 19 Jun 2024 17:39:19 +0900 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20=EC=9E=98=EB=AA=BB=EB=90=9C=20?= =?UTF-8?q?=EC=BB=A4=EB=B0=8B=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wakeupsong/usecase/WakeupSongUseCase.java | 16 +++++++--------- .../wakeupsong/application/VideoClient.java | 2 +- .../dodaminfra/api/youtube/YoutubeClient.java | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/dodam-api/src/main/java/b1nd/dodamapi/wakeupsong/usecase/WakeupSongUseCase.java b/dodam-api/src/main/java/b1nd/dodamapi/wakeupsong/usecase/WakeupSongUseCase.java index 7d6fac31..17df1c14 100644 --- a/dodam-api/src/main/java/b1nd/dodamapi/wakeupsong/usecase/WakeupSongUseCase.java +++ b/dodam-api/src/main/java/b1nd/dodamapi/wakeupsong/usecase/WakeupSongUseCase.java @@ -62,17 +62,15 @@ public ResponseData> getMyWakeupSong(){ @Transactional(rollbackFor = Exception.class) public CompletableFuture createWakeupSong(String videoUrl) { Member member = verifyAlreadyAppliedFromSession(); - String videoId = YoutubeApiUtil.getVideoId(videoUrl); - return videoClient.getVideo(videoId) - .thenApply(videoResponse -> { - YoutubeApiRes.Snippet snippet = videoResponse.getItems().get(0).getSnippet(); - checkValidVideoType(snippet.getTitle()); - buildAndSaveWakeupSong(snippet, videoId, videoUrl, member); - return Response.created("기상송 신청 성공"); - }).exceptionally(this::handleExceptionOnCreateWakeupSong); + return CompletableFuture.supplyAsync(() -> { + String videoId = YoutubeApiUtil.getVideoId(videoUrl); + YoutubeApiRes.Snippet snippet = videoClient.getVideo(videoId).getItems().get(0).getSnippet(); + checkValidVideoType(snippet.getTitle()); + buildAndSaveWakeupSong(snippet, videoId,videoUrl,member); + return Response.created("기상송 신청 성공"); + }).exceptionally(this::handleExceptionOnCreateWakeupSong); } - @Transactional(rollbackFor = Exception.class) public CompletableFuture createWakeupSongByYoutubeSearch(ApplyWakeupSongBySearchReq req){ Member member = verifyAlreadyAppliedFromSession(); diff --git a/dodam-core/src/main/java/b1nd/dodamcore/wakeupsong/application/VideoClient.java b/dodam-core/src/main/java/b1nd/dodamcore/wakeupsong/application/VideoClient.java index f99244c5..020cba66 100644 --- a/dodam-core/src/main/java/b1nd/dodamcore/wakeupsong/application/VideoClient.java +++ b/dodam-core/src/main/java/b1nd/dodamcore/wakeupsong/application/VideoClient.java @@ -6,7 +6,7 @@ public interface VideoClient { - CompletableFuture getVideo(String videoId); + YoutubeApiRes.Video getVideo(String videoId); YoutubeApiRes.Search searchVideoByKeyword(String keyword, int size); } diff --git a/dodam-infra/src/main/java/b1nd/dodaminfra/api/youtube/YoutubeClient.java b/dodam-infra/src/main/java/b1nd/dodaminfra/api/youtube/YoutubeClient.java index 3ea3f7a6..43dfc164 100644 --- a/dodam-infra/src/main/java/b1nd/dodaminfra/api/youtube/YoutubeClient.java +++ b/dodam-infra/src/main/java/b1nd/dodaminfra/api/youtube/YoutubeClient.java @@ -17,12 +17,12 @@ public class YoutubeClient implements VideoClient { private final WebClientSupport webClientSupport; @Override - public CompletableFuture getVideo(String videoId) { + public YoutubeApiRes.Video getVideo(String videoId) { return webClientSupport.get( UriComponentsBuilder.fromUriString(youtubeProperties.url().getVideo()) .build(youtubeProperties.getApiKey(), videoId).toString(), YoutubeApiRes.Video.class - ).toFuture(); + ).block(); } @Override From 984425f18a80a6930da42e46a105472a49a2aedc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=8F=99=EC=B0=AC?= <129833370+dongchandev@users.noreply.github.com> Date: Wed, 19 Jun 2024 17:42:35 +0900 Subject: [PATCH 4/4] chore: commit rollback --- .../wakeupsong/usecase/WakeupSongUseCase.java | 17 ++++++++++------- .../wakeupsong/application/VideoClient.java | 2 +- .../dodaminfra/api/youtube/YoutubeClient.java | 4 ++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/dodam-api/src/main/java/b1nd/dodamapi/wakeupsong/usecase/WakeupSongUseCase.java b/dodam-api/src/main/java/b1nd/dodamapi/wakeupsong/usecase/WakeupSongUseCase.java index 17df1c14..7f43ed85 100644 --- a/dodam-api/src/main/java/b1nd/dodamapi/wakeupsong/usecase/WakeupSongUseCase.java +++ b/dodam-api/src/main/java/b1nd/dodamapi/wakeupsong/usecase/WakeupSongUseCase.java @@ -62,15 +62,18 @@ public ResponseData> getMyWakeupSong(){ @Transactional(rollbackFor = Exception.class) public CompletableFuture createWakeupSong(String videoUrl) { Member member = verifyAlreadyAppliedFromSession(); - return CompletableFuture.supplyAsync(() -> { - String videoId = YoutubeApiUtil.getVideoId(videoUrl); - YoutubeApiRes.Snippet snippet = videoClient.getVideo(videoId).getItems().get(0).getSnippet(); - checkValidVideoType(snippet.getTitle()); - buildAndSaveWakeupSong(snippet, videoId,videoUrl,member); - return Response.created("기상송 신청 성공"); - }).exceptionally(this::handleExceptionOnCreateWakeupSong); + String videoId = YoutubeApiUtil.getVideoId(videoUrl); + + return videoClient.getVideo(videoId) + .thenApply(videoResponse -> { + YoutubeApiRes.Snippet snippet = videoResponse.getItems().get(0).getSnippet(); + checkValidVideoType(snippet.getTitle()); + buildAndSaveWakeupSong(snippet, videoId, videoUrl, member); + return Response.created("기상송 신청 성공"); + }).exceptionally(this::handleExceptionOnCreateWakeupSong); } + @Transactional(rollbackFor = Exception.class) public CompletableFuture createWakeupSongByYoutubeSearch(ApplyWakeupSongBySearchReq req){ Member member = verifyAlreadyAppliedFromSession(); diff --git a/dodam-core/src/main/java/b1nd/dodamcore/wakeupsong/application/VideoClient.java b/dodam-core/src/main/java/b1nd/dodamcore/wakeupsong/application/VideoClient.java index 020cba66..f99244c5 100644 --- a/dodam-core/src/main/java/b1nd/dodamcore/wakeupsong/application/VideoClient.java +++ b/dodam-core/src/main/java/b1nd/dodamcore/wakeupsong/application/VideoClient.java @@ -6,7 +6,7 @@ public interface VideoClient { - YoutubeApiRes.Video getVideo(String videoId); + CompletableFuture getVideo(String videoId); YoutubeApiRes.Search searchVideoByKeyword(String keyword, int size); } diff --git a/dodam-infra/src/main/java/b1nd/dodaminfra/api/youtube/YoutubeClient.java b/dodam-infra/src/main/java/b1nd/dodaminfra/api/youtube/YoutubeClient.java index 43dfc164..3ea3f7a6 100644 --- a/dodam-infra/src/main/java/b1nd/dodaminfra/api/youtube/YoutubeClient.java +++ b/dodam-infra/src/main/java/b1nd/dodaminfra/api/youtube/YoutubeClient.java @@ -17,12 +17,12 @@ public class YoutubeClient implements VideoClient { private final WebClientSupport webClientSupport; @Override - public YoutubeApiRes.Video getVideo(String videoId) { + public CompletableFuture getVideo(String videoId) { return webClientSupport.get( UriComponentsBuilder.fromUriString(youtubeProperties.url().getVideo()) .build(youtubeProperties.getApiKey(), videoId).toString(), YoutubeApiRes.Video.class - ).block(); + ).toFuture(); } @Override