diff --git a/src/main/java/team7/inplace/influencer/entity/Influencer.java b/src/main/java/team7/inplace/influencer/entity/Influencer.java new file mode 100644 index 00000000..9dde5592 --- /dev/null +++ b/src/main/java/team7/inplace/influencer/entity/Influencer.java @@ -0,0 +1,26 @@ +package team7.inplace.influencer.entity; + +import jakarta.persistence.*; +import lombok.*; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@RequiredArgsConstructor // 테스팅을 위한 부분 추가, 협의 하에 다른 방식 채택 가능 +public class Influencer { + /* + * 더미 데이터 입니다 !!! + */ + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + @Column + @NonNull + private String name; + @Column + @NonNull + private String job; + @Column + @NonNull + private String imgUrl; +} 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/place/dto/PlaceForVideo.java b/src/main/java/team7/inplace/place/dto/PlaceForVideo.java new file mode 100644 index 00000000..4469cf8e --- /dev/null +++ b/src/main/java/team7/inplace/place/dto/PlaceForVideo.java @@ -0,0 +1,13 @@ +package team7.inplace.place.dto; + +public record PlaceForVideo( + Long placeId, + String placeName +) { + public static PlaceForVideo of(Long placeId, String placeName) { + return new PlaceForVideo( + placeId, + placeName + ); + } +} diff --git a/src/main/java/team7/inplace/video/DTO/PlaceForVideo.java b/src/main/java/team7/inplace/video/DTO/PlaceForVideo.java deleted file mode 100644 index 9ab2c42a..00000000 --- a/src/main/java/team7/inplace/video/DTO/PlaceForVideo.java +++ /dev/null @@ -1,4 +0,0 @@ -package team7.inplace.video.DTO; - -public record PlaceForVideo(Long placeId, String placeName) { -} diff --git a/src/main/java/team7/inplace/video/DTO/VideoData.java b/src/main/java/team7/inplace/video/DTO/VideoData.java deleted file mode 100644 index c371c49d..00000000 --- a/src/main/java/team7/inplace/video/DTO/VideoData.java +++ /dev/null @@ -1,4 +0,0 @@ -package team7.inplace.video.DTO; - -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 deleted file mode 100644 index 0ce3f9b8..00000000 --- a/src/main/java/team7/inplace/video/DTO/VideoResponse.java +++ /dev/null @@ -1,7 +0,0 @@ -package team7.inplace.video.DTO; - -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/application/AliasUtil.java b/src/main/java/team7/inplace/video/application/AliasUtil.java new file mode 100644 index 00000000..80667687 --- /dev/null +++ b/src/main/java/team7/inplace/video/application/AliasUtil.java @@ -0,0 +1,24 @@ +package team7.inplace.video.application; + +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; +import team7.inplace.place.domain.Category; + +@RequiredArgsConstructor(access = AccessLevel.PRIVATE) +public final class AliasUtil { + private final Template template; + public static String makeAlias(String influencerName, Category category){ + String alias = mapTemplateToCategory(category); + return influencerName + " " + alias; + } + + // 카테고리에 따라 템플릿을 매핑하는 메서드 + private static String mapTemplateToCategory(Category category) { + return switch (category) { + case CAFE -> Template.CAFE.getRandomTemplate(); + case WESTERN -> Template.WESTERN.getRandomTemplate(); + case JAPANESE -> Template.JAPANESE.getRandomTemplate(); + case KOREAN -> Template.KOREAN.getRandomTemplate(); + }; + } +} diff --git a/src/main/java/team7/inplace/video/application/Template.java b/src/main/java/team7/inplace/video/application/Template.java new file mode 100644 index 00000000..f4228236 --- /dev/null +++ b/src/main/java/team7/inplace/video/application/Template.java @@ -0,0 +1,52 @@ +package team7.inplace.video.application; + +import lombok.Getter; +import team7.inplace.place.domain.Category; + +import java.util.*; + +@Getter +public enum Template { + // 카페 관련 템플릿 + CAFE(new String[]{ + "이(가) 방문한 카페에서 따뜻한 커피를 즐겨보세요!", + "이(가) 방문했던 카페에서 여유로운 시간을 보내보세요!", + "이(가) 추천하는 사진 명소 예쁜 카페에 방문해보세요!" + }), + + // 양식 관련 템플릿 + WESTERN(new String[]{ + "이(가) 추천! 맛있는 서양 음식을 즐길 수 있는 곳!", + "이(가) 추천하는 고급스러운 서양 요리를 맛볼 수 있습니다.", + "이(가) 극찬! 서양식 디저트를 꼭 한 번 시도해보세요!" + }), + + // 일식 관련 템플릿 + JAPANESE(new String[]{ + "피셜, 현지와 다름없는 정통 일본 요리 레스토랑.", + "이(가) 추천하는 맛있는 일본 초밥과 라멘을 즐겨보세요.", + "이(가) 극찬! 일본 요리의 정수를 느껴보세요." + }), + + // 한식 관련 템플릿 + KOREAN(new String[]{ + "이(가) 전통 한식을 맛볼 수 있는 한식당입니다.", + "이(가) 추천하는 가게에서 정성스럽게 준비된 한식으로 든든한 한 끼를!", + "이(가) 극찬! 한식의 깊은 맛을 느껴보세요." + }); + + // 템플릿 배열을 반환하는 메서드 + // 필드 선언 + private final String[] templates; + + // 생성자 + Template(String[] templates) { + this.templates = templates; + } + + // 특정 템플릿을 랜덤으로 반환하는 메서드 + public String getRandomTemplate() { + int randomIndex = (int) (Math.random() * templates.length); + return templates[randomIndex]; + } +} diff --git a/src/main/java/team7/inplace/video/application/VideoService.java b/src/main/java/team7/inplace/video/application/VideoService.java new file mode 100644 index 00000000..edfe24f7 --- /dev/null +++ b/src/main/java/team7/inplace/video/application/VideoService.java @@ -0,0 +1,54 @@ +package team7.inplace.video.application; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import team7.inplace.influencer.entity.Influencer; +import team7.inplace.influencer.repository.InfluencerRepository; +import team7.inplace.place.domain.Place; +import team7.inplace.place.dto.PlaceForVideo; +import team7.inplace.video.application.dto.VideoInfo; +import team7.inplace.video.domain.Video; +import team7.inplace.video.persistence.VideoRepository; + +import java.util.ArrayList; +import java.util.List; + +@Service +@RequiredArgsConstructor +public class VideoService { + private final VideoRepository videoRepository; + private final InfluencerRepository influencerRepository; + + public List findByInfluencer(List influencers) { + // 인플루언서 정보 처리 + List influencerIds = influencerRepository.findByNameIn(influencers).stream() + .map(Influencer::getId) + .toList(); + + // 인플루언서 정보로 필터링한 비디오 정보 불러오기 + List