From 42e19233457de5a120707b1819eddc9947cada16 Mon Sep 17 00:00:00 2001 From: BaeJunho Date: Thu, 3 Oct 2024 20:14:46 +0900 Subject: [PATCH 1/6] =?UTF-8?q?[refactor]=20API=20=EB=AA=85=EC=84=B8=20?= =?UTF-8?q?=EC=9D=B8=ED=84=B0=ED=8E=98=EC=9D=B4=EC=8A=A4=EC=97=90=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1=ED=95=98=EA=B3=A0=20=EA=B5=AC=ED=98=84?= =?UTF-8?q?=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Controller를 구현체로 Interface를 만들어 명세를 작성하는 스타일 채택 --- .../video/presentation/VideoController.java | 9 +----- .../presentation/VideoControllerApiSpec.java | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 src/main/java/team7/inplace/video/presentation/VideoControllerApiSpec.java diff --git a/src/main/java/team7/inplace/video/presentation/VideoController.java b/src/main/java/team7/inplace/video/presentation/VideoController.java index 03ee1439..cb8656af 100644 --- a/src/main/java/team7/inplace/video/presentation/VideoController.java +++ b/src/main/java/team7/inplace/video/presentation/VideoController.java @@ -1,6 +1,5 @@ package team7.inplace.video.presentation; -import io.swagger.v3.oas.annotations.Operation; import jakarta.servlet.http.HttpServletRequest; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.PageRequest; @@ -19,15 +18,11 @@ @RestController @RequiredArgsConstructor @RequestMapping("/videos") -public class VideoController { +public class VideoController implements VideoControllerApiSpec{ private final VideoService videoService; // 토큰 필요 메서드 @GetMapping() - @Operation( - summary = "내 인플루언서가 방문한 or 내 주변 그곳 ", - description = "토큰의 유무에 따라 다른 동작을 수행합니다." - ) public ResponseEntity> readVideos( HttpServletRequest request, @RequestParam(name = "influencer", required = false) List influencers, @@ -63,7 +58,6 @@ private ResponseEntity> readBySurround(VideoSearchParams sea } @GetMapping("/new") - @Operation(summary = "새로 등록된 그 곳", description = "id를 기준으로 내림차순 정렬한 Video 정보를 조회합니다.") public ResponseEntity> readByNew() { List videoInfos = videoService.findAllDesc(); List videoResponses = videoInfos.stream().map(VideoResponse::from).toList(); @@ -72,7 +66,6 @@ public ResponseEntity> readByNew() { // 조회수 반환 기능 개발 시 개발 @GetMapping("/cool") - @Operation(summary = "쿨한 그 곳", description = "조회수를 기준으로 내림차순 정렬한 Video 정보를 조회합니다.") public ResponseEntity> readByCool() { List videoResponses = new ArrayList<>(); return new ResponseEntity<>(videoResponses, HttpStatus.OK); diff --git a/src/main/java/team7/inplace/video/presentation/VideoControllerApiSpec.java b/src/main/java/team7/inplace/video/presentation/VideoControllerApiSpec.java new file mode 100644 index 00000000..d76b276c --- /dev/null +++ b/src/main/java/team7/inplace/video/presentation/VideoControllerApiSpec.java @@ -0,0 +1,32 @@ +package team7.inplace.video.presentation; + +import io.swagger.v3.oas.annotations.Operation; +import jakarta.servlet.http.HttpServletRequest; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestParam; +import team7.inplace.video.presentation.dto.VideoResponse; +import team7.inplace.video.presentation.dto.VideoSearchParams; + +import java.util.List; + + +public interface VideoControllerApiSpec { + @Operation( + summary = "내 인플루언서가 방문한 or 내 주변 그곳 ", + description = "토큰의 유무에 따라 다른 동작을 수행합니다." + ) + public ResponseEntity> readVideos( + HttpServletRequest request, + @RequestParam(name = "influencer", required = false) List influencers, + @ModelAttribute VideoSearchParams searchParams, + @RequestParam(defaultValue = "0", required = false) int page, + @RequestParam(defaultValue = "10", required = false) int size + ); + + @Operation(summary = "새로 등록된 그 곳", description = "id를 기준으로 내림차순 정렬한 Video 정보를 조회합니다.") + public ResponseEntity> readByNew(); + + @Operation(summary = "쿨한 그 곳", description = "조회수를 기준으로 내림차순 정렬한 Video 정보를 조회합니다.") + public ResponseEntity> readByCool(); +} From 5dbf2135f31ac0b010412a393ef02796cddee392 Mon Sep 17 00:00:00 2001 From: BaeJunho Date: Thu, 3 Oct 2024 20:15:03 +0900 Subject: [PATCH 2/6] =?UTF-8?q?[refactor]=20=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EB=AA=85=20=EC=BB=A8=EB=B2=A4=EC=85=98=EC=97=90=20=EB=A7=9E?= =?UTF-8?q?=EA=B2=8C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../video/{service => application}/VideoServiceTest.java | 3 +-- .../video/{repository => persistence}/VideoRepositoryTest.java | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) rename src/test/java/team7/inplace/video/{service => application}/VideoServiceTest.java (97%) rename src/test/java/team7/inplace/video/{repository => persistence}/VideoRepositoryTest.java (97%) diff --git a/src/test/java/team7/inplace/video/service/VideoServiceTest.java b/src/test/java/team7/inplace/video/application/VideoServiceTest.java similarity index 97% rename from src/test/java/team7/inplace/video/service/VideoServiceTest.java rename to src/test/java/team7/inplace/video/application/VideoServiceTest.java index bd13a36f..112176ad 100644 --- a/src/test/java/team7/inplace/video/service/VideoServiceTest.java +++ b/src/test/java/team7/inplace/video/application/VideoServiceTest.java @@ -1,4 +1,4 @@ -package team7.inplace.video.service; +package team7.inplace.video.application; import static org.mockito.BDDMockito.given; @@ -16,7 +16,6 @@ import team7.inplace.influencer.domain.Influencer; import team7.inplace.influencer.persistence.InfluencerRepository; import team7.inplace.place.domain.*; -import team7.inplace.video.application.VideoService; import team7.inplace.video.application.dto.VideoInfo; import team7.inplace.video.domain.Video; import team7.inplace.video.persistence.VideoRepository; diff --git a/src/test/java/team7/inplace/video/repository/VideoRepositoryTest.java b/src/test/java/team7/inplace/video/persistence/VideoRepositoryTest.java similarity index 97% rename from src/test/java/team7/inplace/video/repository/VideoRepositoryTest.java rename to src/test/java/team7/inplace/video/persistence/VideoRepositoryTest.java index b9fefb0d..daddc188 100644 --- a/src/test/java/team7/inplace/video/repository/VideoRepositoryTest.java +++ b/src/test/java/team7/inplace/video/persistence/VideoRepositoryTest.java @@ -1,4 +1,4 @@ -package team7.inplace.video.repository; +package team7.inplace.video.persistence; import jakarta.persistence.EntityManager; import jakarta.persistence.PersistenceContext; @@ -15,7 +15,6 @@ import team7.inplace.influencer.domain.Influencer; import team7.inplace.place.domain.*; import team7.inplace.video.domain.Video; -import team7.inplace.video.persistence.VideoRepository; @DataJpaTest @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) // 각 메서드 실행마다 이전 결과 초기화 From 049c471d13610406c91c4c4e6e0f359593744c42 Mon Sep 17 00:00:00 2001 From: BaeJunho Date: Thu, 3 Oct 2024 20:54:37 +0900 Subject: [PATCH 3/6] =?UTF-8?q?[refactor]=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EC=BB=A8=EB=B2=A4=EC=85=98=EC=97=90=20?= =?UTF-8?q?=EB=A7=9E=EA=B2=8C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/team7/inplace/video/application/VideoService.java | 6 +++--- .../team7/inplace/video/presentation/VideoController.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/team7/inplace/video/application/VideoService.java b/src/main/java/team7/inplace/video/application/VideoService.java index 24a566ce..3587fbd4 100644 --- a/src/main/java/team7/inplace/video/application/VideoService.java +++ b/src/main/java/team7/inplace/video/application/VideoService.java @@ -24,7 +24,7 @@ public class VideoService { private final InfluencerRepository influencerRepository; private final PlaceRepository placeRepository; - public List findByInfluencer(List influencers) { + public List getByVideosInfluencer(List influencers) { // 인플루언서 정보 처리 List influencerIds = influencerRepository.findByNameIn(influencers).stream() .map(Influencer::getId) @@ -37,7 +37,7 @@ public List findByInfluencer(List influencers) { return videoToInfo(savedVideos); } - public List findAllDesc() { + public List getAllVideosDesc() { // id를 기준으로 내림차순 정렬하여 비디오 정보 불러오기 List