From 46ceedd4ddf1cea4d887ae9efb08561f0c514ba0 Mon Sep 17 00:00:00 2001 From: BaeJunho Date: Sat, 21 Sep 2024 15:36:11 +0900 Subject: [PATCH 01/17] =?UTF-8?q?style=20:=20=EC=BB=A8=EB=B2=A4=EC=85=98?= =?UTF-8?q?=EC=97=90=20=EB=A7=9E=EA=B2=8C=20=EB=8F=84=EB=A9=94=EC=9D=B8?= =?UTF-8?q?=EB=B3=84=20=ED=8C=A8=ED=82=A4=EC=A7=80=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 더미 데이터여서 그냥 만들었었는데, 피드백에 따라 변경하기로 결정 --- .../inplace/{video => influencer}/entity/Influencer.java | 2 +- .../repository/InfluencerRepository.java | 4 ++-- .../inplace/{video/DTO => place/dto}/PlaceForVideo.java | 2 +- .../java/team7/inplace/{video => place}/entity/Place.java | 2 +- src/main/java/team7/inplace/video/DTO/VideoData.java | 2 ++ src/main/java/team7/inplace/video/DTO/VideoResponse.java | 2 ++ src/main/java/team7/inplace/video/entity/Video.java | 2 ++ src/main/java/team7/inplace/video/service/VideoService.java | 6 +++--- 8 files changed, 14 insertions(+), 8 deletions(-) rename src/main/java/team7/inplace/{video => influencer}/entity/Influencer.java (90%) rename src/main/java/team7/inplace/{video => influencer}/repository/InfluencerRepository.java (77%) rename src/main/java/team7/inplace/{video/DTO => place/dto}/PlaceForVideo.java (66%) rename src/main/java/team7/inplace/{video => place}/entity/Place.java (89%) diff --git a/src/main/java/team7/inplace/video/entity/Influencer.java b/src/main/java/team7/inplace/influencer/entity/Influencer.java similarity index 90% rename from src/main/java/team7/inplace/video/entity/Influencer.java rename to src/main/java/team7/inplace/influencer/entity/Influencer.java index 0cc69f8d..27019109 100644 --- a/src/main/java/team7/inplace/video/entity/Influencer.java +++ b/src/main/java/team7/inplace/influencer/entity/Influencer.java @@ -1,4 +1,4 @@ -package team7.inplace.video.entity; +package team7.inplace.influencer.entity; import jakarta.persistence.Column; import jakarta.persistence.Entity; diff --git a/src/main/java/team7/inplace/video/repository/InfluencerRepository.java b/src/main/java/team7/inplace/influencer/repository/InfluencerRepository.java similarity index 77% rename from src/main/java/team7/inplace/video/repository/InfluencerRepository.java rename to src/main/java/team7/inplace/influencer/repository/InfluencerRepository.java index 7d7d12f6..f3a9a4a6 100644 --- a/src/main/java/team7/inplace/video/repository/InfluencerRepository.java +++ b/src/main/java/team7/inplace/influencer/repository/InfluencerRepository.java @@ -1,7 +1,7 @@ -package team7.inplace.video.repository; +package team7.inplace.influencer.repository; import org.springframework.data.jpa.repository.JpaRepository; -import team7.inplace.video.entity.Influencer; +import team7.inplace.influencer.entity.Influencer; import java.util.List; diff --git a/src/main/java/team7/inplace/video/DTO/PlaceForVideo.java b/src/main/java/team7/inplace/place/dto/PlaceForVideo.java similarity index 66% rename from src/main/java/team7/inplace/video/DTO/PlaceForVideo.java rename to src/main/java/team7/inplace/place/dto/PlaceForVideo.java index 9ab2c42a..42231d0f 100644 --- a/src/main/java/team7/inplace/video/DTO/PlaceForVideo.java +++ b/src/main/java/team7/inplace/place/dto/PlaceForVideo.java @@ -1,4 +1,4 @@ -package team7.inplace.video.DTO; +package team7.inplace.place.dto; public record PlaceForVideo(Long placeId, String placeName) { } diff --git a/src/main/java/team7/inplace/video/entity/Place.java b/src/main/java/team7/inplace/place/entity/Place.java similarity index 89% rename from src/main/java/team7/inplace/video/entity/Place.java rename to src/main/java/team7/inplace/place/entity/Place.java index cce24170..fc453293 100644 --- a/src/main/java/team7/inplace/video/entity/Place.java +++ b/src/main/java/team7/inplace/place/entity/Place.java @@ -1,4 +1,4 @@ -package team7.inplace.video.entity; +package team7.inplace.place.entity; import jakarta.persistence.Column; import jakarta.persistence.Entity; diff --git a/src/main/java/team7/inplace/video/DTO/VideoData.java b/src/main/java/team7/inplace/video/DTO/VideoData.java index c371c49d..151aa713 100644 --- a/src/main/java/team7/inplace/video/DTO/VideoData.java +++ b/src/main/java/team7/inplace/video/DTO/VideoData.java @@ -1,4 +1,6 @@ package team7.inplace.video.DTO; +import team7.inplace.place.dto.PlaceForVideo; + public record VideoData(Long videoId, String videoAlias, String videoUrl, PlaceForVideo place) { } diff --git a/src/main/java/team7/inplace/video/DTO/VideoResponse.java b/src/main/java/team7/inplace/video/DTO/VideoResponse.java index 0ce3f9b8..224234d4 100644 --- a/src/main/java/team7/inplace/video/DTO/VideoResponse.java +++ b/src/main/java/team7/inplace/video/DTO/VideoResponse.java @@ -1,5 +1,7 @@ package team7.inplace.video.DTO; +import team7.inplace.place.dto.PlaceForVideo; + public record VideoResponse(Long videoId, String videoAlias, String videoUrl, PlaceForVideo place) { public VideoResponse(VideoData videoData) { this(videoData.videoId(), videoData.videoAlias(), videoData.videoUrl(), videoData.place()); diff --git a/src/main/java/team7/inplace/video/entity/Video.java b/src/main/java/team7/inplace/video/entity/Video.java index da5fafd0..ef442d4b 100644 --- a/src/main/java/team7/inplace/video/entity/Video.java +++ b/src/main/java/team7/inplace/video/entity/Video.java @@ -3,6 +3,8 @@ import jakarta.persistence.*; import lombok.Getter; import lombok.NoArgsConstructor; +import team7.inplace.influencer.entity.Influencer; +import team7.inplace.place.entity.Place; @Entity @Getter diff --git a/src/main/java/team7/inplace/video/service/VideoService.java b/src/main/java/team7/inplace/video/service/VideoService.java index 2b257286..8f848805 100644 --- a/src/main/java/team7/inplace/video/service/VideoService.java +++ b/src/main/java/team7/inplace/video/service/VideoService.java @@ -1,11 +1,11 @@ package team7.inplace.video.service; import org.springframework.stereotype.Service; -import team7.inplace.video.DTO.PlaceForVideo; +import team7.inplace.place.dto.PlaceForVideo; import team7.inplace.video.DTO.VideoData; -import team7.inplace.video.entity.Influencer; +import team7.inplace.influencer.entity.Influencer; import team7.inplace.video.entity.Video; -import team7.inplace.video.repository.InfluencerRepository; +import team7.inplace.influencer.repository.InfluencerRepository; import team7.inplace.video.repository.VideoRepository; import java.util.ArrayList; From 3360ca7875bb268e9168275268ccf818487787e4 Mon Sep 17 00:00:00 2001 From: BaeJunho Date: Sat, 21 Sep 2024 15:37:00 +0900 Subject: [PATCH 02/17] =?UTF-8?q?style=20:=20=EC=BB=A8=EB=B2=A4=EC=85=98?= =?UTF-8?q?=EC=97=90=20=EB=A7=9E=EA=B2=8C=20=ED=8C=A8=ED=82=A4=EC=A7=80?= =?UTF-8?q?=EB=AA=85=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/controller/VideoController.java | 5 ++--- .../java/team7/inplace/video/{DTO => dto}/VideoData.java | 2 +- .../java/team7/inplace/video/{DTO => dto}/VideoResponse.java | 2 +- src/main/java/team7/inplace/video/service/VideoService.java | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) rename src/main/java/team7/inplace/video/{DTO => dto}/VideoData.java (81%) rename src/main/java/team7/inplace/video/{DTO => dto}/VideoResponse.java (90%) diff --git a/src/main/java/team7/inplace/video/controller/VideoController.java b/src/main/java/team7/inplace/video/controller/VideoController.java index 7522e5cd..a9b547f5 100644 --- a/src/main/java/team7/inplace/video/controller/VideoController.java +++ b/src/main/java/team7/inplace/video/controller/VideoController.java @@ -5,12 +5,11 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import team7.inplace.video.DTO.VideoData; -import team7.inplace.video.DTO.VideoResponse; +import team7.inplace.video.dto.VideoData; +import team7.inplace.video.dto.VideoResponse; import team7.inplace.video.service.VideoService; import java.util.List; -import java.util.stream.Collectors; @RestController public class VideoController { diff --git a/src/main/java/team7/inplace/video/DTO/VideoData.java b/src/main/java/team7/inplace/video/dto/VideoData.java similarity index 81% rename from src/main/java/team7/inplace/video/DTO/VideoData.java rename to src/main/java/team7/inplace/video/dto/VideoData.java index 151aa713..c0fded0e 100644 --- a/src/main/java/team7/inplace/video/DTO/VideoData.java +++ b/src/main/java/team7/inplace/video/dto/VideoData.java @@ -1,4 +1,4 @@ -package team7.inplace.video.DTO; +package team7.inplace.video.dto; import team7.inplace.place.dto.PlaceForVideo; diff --git a/src/main/java/team7/inplace/video/DTO/VideoResponse.java b/src/main/java/team7/inplace/video/dto/VideoResponse.java similarity index 90% rename from src/main/java/team7/inplace/video/DTO/VideoResponse.java rename to src/main/java/team7/inplace/video/dto/VideoResponse.java index 224234d4..ae4274bd 100644 --- a/src/main/java/team7/inplace/video/DTO/VideoResponse.java +++ b/src/main/java/team7/inplace/video/dto/VideoResponse.java @@ -1,4 +1,4 @@ -package team7.inplace.video.DTO; +package team7.inplace.video.dto; import team7.inplace.place.dto.PlaceForVideo; diff --git a/src/main/java/team7/inplace/video/service/VideoService.java b/src/main/java/team7/inplace/video/service/VideoService.java index 8f848805..f44a0c9c 100644 --- a/src/main/java/team7/inplace/video/service/VideoService.java +++ b/src/main/java/team7/inplace/video/service/VideoService.java @@ -2,7 +2,7 @@ import org.springframework.stereotype.Service; import team7.inplace.place.dto.PlaceForVideo; -import team7.inplace.video.DTO.VideoData; +import team7.inplace.video.dto.VideoData; import team7.inplace.influencer.entity.Influencer; import team7.inplace.video.entity.Video; import team7.inplace.influencer.repository.InfluencerRepository; From 4ae605200f06900abb3885254d358132ff6569e9 Mon Sep 17 00:00:00 2001 From: BaeJunho Date: Sat, 21 Sep 2024 15:41:37 +0900 Subject: [PATCH 03/17] =?UTF-8?q?style=20:=20=EC=83=9D=EC=84=B1=EC=9E=90?= =?UTF-8?q?=20lombok=EC=9C=BC=EB=A1=9C=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/influencer/entity/Influencer.java | 7 +++---- src/main/java/team7/inplace/place/entity/Place.java | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/team7/inplace/influencer/entity/Influencer.java b/src/main/java/team7/inplace/influencer/entity/Influencer.java index 27019109..59b399ef 100644 --- a/src/main/java/team7/inplace/influencer/entity/Influencer.java +++ b/src/main/java/team7/inplace/influencer/entity/Influencer.java @@ -3,10 +3,13 @@ import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.Id; +import lombok.AccessLevel; import lombok.Getter; +import lombok.NoArgsConstructor; @Entity @Getter +@NoArgsConstructor(access= AccessLevel.PROTECTED) public class Influencer { /* * 더미 데이터 입니다 !!! @@ -19,8 +22,4 @@ public class Influencer { private String job; @Column private String imgUrl; - - protected Influencer() { - - } } diff --git a/src/main/java/team7/inplace/place/entity/Place.java b/src/main/java/team7/inplace/place/entity/Place.java index fc453293..d9fd69ed 100644 --- a/src/main/java/team7/inplace/place/entity/Place.java +++ b/src/main/java/team7/inplace/place/entity/Place.java @@ -3,10 +3,13 @@ import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.Id; +import lombok.AccessLevel; import lombok.Getter; +import lombok.NoArgsConstructor; @Entity @Getter +@NoArgsConstructor(access= AccessLevel.PROTECTED) public class Place { /* * 더미 데이터 입니다 !!! @@ -15,8 +18,4 @@ public class Place { private Long id; @Column private String name; - - protected Place(){ - - } } From cdac49b1ab93e50ec413a33aba7eda379e86aa63 Mon Sep 17 00:00:00 2001 From: BaeJunho Date: Sat, 21 Sep 2024 15:59:31 +0900 Subject: [PATCH 04/17] =?UTF-8?q?style=20:=20=EC=83=9D=EC=84=B1=EC=9E=90?= =?UTF-8?q?=20lombok=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team7/inplace/video/controller/VideoController.java | 8 +++----- .../java/team7/inplace/video/service/VideoService.java | 7 ++----- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/main/java/team7/inplace/video/controller/VideoController.java b/src/main/java/team7/inplace/video/controller/VideoController.java index a9b547f5..ae8cb2d4 100644 --- a/src/main/java/team7/inplace/video/controller/VideoController.java +++ b/src/main/java/team7/inplace/video/controller/VideoController.java @@ -1,5 +1,6 @@ package team7.inplace.video.controller; +import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; @@ -12,15 +13,12 @@ import java.util.List; @RestController +@RequiredArgsConstructor public class VideoController { private final VideoService videoService; - public VideoController(VideoService videoService) { - this.videoService = videoService; - } - // 내 인플루언서가 방문한 그 곳 - @GetMapping("video") + @GetMapping("/video") public ResponseEntity> readByInfluencer( @RequestParam(name="influencer", required = false) List influencers ){ diff --git a/src/main/java/team7/inplace/video/service/VideoService.java b/src/main/java/team7/inplace/video/service/VideoService.java index f44a0c9c..6e84646b 100644 --- a/src/main/java/team7/inplace/video/service/VideoService.java +++ b/src/main/java/team7/inplace/video/service/VideoService.java @@ -1,5 +1,6 @@ package team7.inplace.video.service; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import team7.inplace.place.dto.PlaceForVideo; import team7.inplace.video.dto.VideoData; @@ -12,15 +13,11 @@ import java.util.List; @Service +@RequiredArgsConstructor public class VideoService { private final VideoRepository videoRepository; private final InfluencerRepository influencerRepository; - public VideoService(VideoRepository videoRepository, InfluencerRepository influencerRepository) { - this.videoRepository = videoRepository; - this.influencerRepository = influencerRepository; - } - public List findByInfluencer(List influencers){ // 변수명 변경 가능 List returnValue = new ArrayList<>(); From 5e97e5e6ac88724febd523e4e51ca2609378de87 Mon Sep 17 00:00:00 2001 From: BaeJunho Date: Sat, 21 Sep 2024 15:59:51 +0900 Subject: [PATCH 05/17] =?UTF-8?q?chore=20:=20=EC=A3=BC=EC=84=9D=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20(=20=ED=81=B4=EB=9E=98=EC=8A=A4=20?= =?UTF-8?q?=EC=84=A4=EB=AA=85=20)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team7/inplace/video/dto/VideoData.java | 1 + src/main/java/team7/inplace/video/dto/VideoResponse.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/team7/inplace/video/dto/VideoData.java b/src/main/java/team7/inplace/video/dto/VideoData.java index c0fded0e..688d08b0 100644 --- a/src/main/java/team7/inplace/video/dto/VideoData.java +++ b/src/main/java/team7/inplace/video/dto/VideoData.java @@ -2,5 +2,6 @@ import team7.inplace.place.dto.PlaceForVideo; +// Video 도메인의 Controller와 Service 사이의 정보 전달을 담당하는 클래스 ( Service Return ) public record VideoData(Long videoId, String videoAlias, String videoUrl, PlaceForVideo place) { } diff --git a/src/main/java/team7/inplace/video/dto/VideoResponse.java b/src/main/java/team7/inplace/video/dto/VideoResponse.java index ae4274bd..e1a12ebf 100644 --- a/src/main/java/team7/inplace/video/dto/VideoResponse.java +++ b/src/main/java/team7/inplace/video/dto/VideoResponse.java @@ -2,6 +2,7 @@ import team7.inplace.place.dto.PlaceForVideo; +// Video 엔티티의 Controller Response 정보 전달을 담당하는 클래스 public record VideoResponse(Long videoId, String videoAlias, String videoUrl, PlaceForVideo place) { public VideoResponse(VideoData videoData) { this(videoData.videoId(), videoData.videoAlias(), videoData.videoUrl(), videoData.place()); From 8e9e4ba9101a038b3475022f0f29e8dbbb399ac1 Mon Sep 17 00:00:00 2001 From: BaeJunho Date: Sat, 21 Sep 2024 17:13:47 +0900 Subject: [PATCH 06/17] =?UTF-8?q?refactor=20:=20Pull=20=EC=9D=B4=ED=9B=84?= =?UTF-8?q?=EC=97=90=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8D=98=20=EB=8D=94?= =?UTF-8?q?=EB=AF=B8=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team7/inplace/place/entity/Place.java | 21 ------------------- 1 file changed, 21 deletions(-) delete mode 100644 src/main/java/team7/inplace/place/entity/Place.java diff --git a/src/main/java/team7/inplace/place/entity/Place.java b/src/main/java/team7/inplace/place/entity/Place.java deleted file mode 100644 index d9fd69ed..00000000 --- a/src/main/java/team7/inplace/place/entity/Place.java +++ /dev/null @@ -1,21 +0,0 @@ -package team7.inplace.place.entity; - -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.Id; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Entity -@Getter -@NoArgsConstructor(access= AccessLevel.PROTECTED) -public class Place { - /* - * 더미 데이터 입니다 !!! - */ - @Id - private Long id; - @Column - private String name; -} From 96586849403a8e9d4931274821fc616cf50dd81c Mon Sep 17 00:00:00 2001 From: BaeJunho Date: Sat, 21 Sep 2024 17:14:11 +0900 Subject: [PATCH 07/17] =?UTF-8?q?refactor=20:=20Pull=20=EC=9D=B4=ED=9B=84?= =?UTF-8?q?=EC=97=90=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8D=98=20=EB=8D=94?= =?UTF-8?q?=EB=AF=B8=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EB=B6=80=EB=B6=84?= =?UTF-8?q?=EC=9D=84=20=EC=8B=A4=EC=A0=9C=20=EA=B0=92=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=8C=80=EC=B2=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team7/inplace/video/entity/Video.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/team7/inplace/video/entity/Video.java b/src/main/java/team7/inplace/video/entity/Video.java index ef442d4b..c57cee7f 100644 --- a/src/main/java/team7/inplace/video/entity/Video.java +++ b/src/main/java/team7/inplace/video/entity/Video.java @@ -4,7 +4,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; import team7.inplace.influencer.entity.Influencer; -import team7.inplace.place.entity.Place; +import team7.inplace.place.domain.Place; @Entity @Getter @@ -13,12 +13,12 @@ public class Video { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @Column(name="video_url") + @Column(name="video_url", nullable = false, columnDefinition = "TEXT") private String videoUrl; @ManyToOne - @JoinColumn(name = "influencer_id") + @JoinColumn(name = "influencer_id", nullable = false) private Influencer influencer; @ManyToOne - @JoinColumn(name = "place_id") + @JoinColumn(name = "place_id", nullable = false) private Place place; } From 3cce3033f272b79d6cb586b43bece3f1227fb132 Mon Sep 17 00:00:00 2001 From: BaeJunho Date: Sat, 21 Sep 2024 17:15:12 +0900 Subject: [PATCH 08/17] =?UTF-8?q?feat=20:=20videoAlias=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=EB=A5=BC=20=EB=9E=9C=EB=8D=A4=ED=95=98=EA=B2=8C=20?= =?UTF-8?q?=EB=A7=A4=ED=95=91=ED=95=B4=EC=A3=BC=EB=8A=94=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 해당 기능 최초 구현, 구현 방식이나 데이터의 추가가 개선되어야 할 것 같다 --- .../inplace/video/service/VideoService.java | 45 +++++++++++++++++-- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/src/main/java/team7/inplace/video/service/VideoService.java b/src/main/java/team7/inplace/video/service/VideoService.java index 6e84646b..c853294d 100644 --- a/src/main/java/team7/inplace/video/service/VideoService.java +++ b/src/main/java/team7/inplace/video/service/VideoService.java @@ -2,6 +2,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import team7.inplace.place.domain.Category; import team7.inplace.place.dto.PlaceForVideo; import team7.inplace.video.dto.VideoData; import team7.inplace.influencer.entity.Influencer; @@ -9,15 +10,42 @@ import team7.inplace.influencer.repository.InfluencerRepository; import team7.inplace.video.repository.VideoRepository; -import java.util.ArrayList; -import java.util.List; +import java.util.*; @Service @RequiredArgsConstructor public class VideoService { + private static Map> template = new HashMap<>(); private final VideoRepository videoRepository; private final InfluencerRepository influencerRepository; + // 더 나은 로직이 존재하면 건의 부탁합니다 + static { + template.put(Category.CAFE, Arrays.asList( + "이(가) 방문한 카페에서 따뜻한 커피를 즐겨보세요!", + "이(가) 방문했던 카페에서 여유로운 시간을 보내보세요!", + "이(가) 추천하는 사진 명소 예쁜 카페에 방문해보세요!" + )); + + template.put(Category.WESTERN, Arrays.asList( + "이(가) 추천! 맛있는 서양 음식을 즐길 수 있는 곳!", + "이(가) 추천하는 고급스러운 서양 요리를 맛볼 수 있습니다.", + "이(가) 극찬! 서양식 디저트를 꼭 한 번 시도해보세요!" + )); + + template.put(Category.JAPANESE, Arrays.asList( + "피셜, 현지와 다름없는 정통 일본 요리 레스토랑.", + "이(가) 추천하는 맛있는 일본 초밥과 라멘을 즐겨보세요.", + "이(가) 극찬! 일본 요리의 정수를 느껴보세요." + )); + + template.put(Category.KOREAN, Arrays.asList( + "이(가) 전통 한식을 맛볼 수 있는 한식당입니다.", + "이(가) 추천하는 가게에서 정성스럽게 준비된 한식으로 든든한 한 끼를!", + "이(가) 극찬! 한식의 깊은 맛을 느껴보세요." + )); + } + public List findByInfluencer(List influencers){ // 변수명 변경 가능 List returnValue = new ArrayList<>(); @@ -33,10 +61,19 @@ public List findByInfluencer(List influencers){ // DTO 형식에 맞게 대입 for (Video savedVideo : savedVideos) { - PlaceForVideo placeForVideo = new PlaceForVideo(savedVideo.getPlace().getId(), savedVideo.getPlace().getName()); - returnValue.add(new VideoData(savedVideo.getId(), " ", savedVideo.getVideoUrl(), placeForVideo)); + PlaceForVideo placeForVideo = new PlaceForVideo(savedVideo.getPlace().getPlaceId(), savedVideo.getPlace().getName()); + String alias = makeAlias(savedVideo.getInfluencer().getName(), savedVideo.getPlace().getCategory()); + returnValue.add(new VideoData(savedVideo.getId(), alias, savedVideo.getVideoUrl(), placeForVideo)); } return returnValue; } + + private String makeAlias(String influencerName, Category category){ + List syntax = template.get(category); + + Random random = new Random(); + int randomNumber = random.nextInt(syntax.size()); + return influencerName + " " + syntax.get(randomNumber); + } } From 9d6f36d1d771a988917c90f5a7c52280099a9321 Mon Sep 17 00:00:00 2001 From: BaeJunho Date: Sun, 22 Sep 2024 16:43:50 +0900 Subject: [PATCH 09/17] =?UTF-8?q?style=20:=20=EB=B3=80=EC=88=98=20?= =?UTF-8?q?=EC=84=A0=EC=96=B8=20=EC=8B=9C=EC=A0=90=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 사용 지점과 최대한 가깝게 변수 선언 시점을 변경 --- src/main/java/team7/inplace/video/service/VideoService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/team7/inplace/video/service/VideoService.java b/src/main/java/team7/inplace/video/service/VideoService.java index c853294d..58747a30 100644 --- a/src/main/java/team7/inplace/video/service/VideoService.java +++ b/src/main/java/team7/inplace/video/service/VideoService.java @@ -47,9 +47,6 @@ public class VideoService { } public List findByInfluencer(List influencers){ - // 변수명 변경 가능 - List returnValue = new ArrayList<>(); - // 인플루언서 정보 처리 List savedInfluencers = influencerRepository.findByNameIn(influencers); List influencerIds = savedInfluencers.stream() @@ -59,6 +56,9 @@ public List findByInfluencer(List influencers){ // 인플루언서 정보로 필터링한 비디오 정보 불러오기 List