From b14468f1cbf0de5257f6893afd179b68fd714d4e Mon Sep 17 00:00:00 2001 From: Tina Date: Tue, 29 Oct 2024 00:48:36 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=EC=B6=94=EC=B2=9C=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20API=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GroupRecommendationController.java | 30 +++++++++++++++++++ .../domain/GroupRecommendation.java | 3 +- .../GroupRecommendationRepository.java | 10 +++++++ .../persistence/RecommendationRepository.java | 12 ++++++++ .../service/RecommendationService.java | 9 ++++++ .../service/RecommendationServiceImpl.java | 21 +++++++++++++ 6 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/moneygement/lyf/jarvis/recommendation/controller/GroupRecommendationController.java create mode 100644 src/main/java/com/moneygement/lyf/jarvis/recommendation/persistence/GroupRecommendationRepository.java create mode 100644 src/main/java/com/moneygement/lyf/jarvis/recommendation/persistence/RecommendationRepository.java create mode 100644 src/main/java/com/moneygement/lyf/jarvis/recommendation/service/RecommendationService.java create mode 100644 src/main/java/com/moneygement/lyf/jarvis/recommendation/service/RecommendationServiceImpl.java diff --git a/src/main/java/com/moneygement/lyf/jarvis/recommendation/controller/GroupRecommendationController.java b/src/main/java/com/moneygement/lyf/jarvis/recommendation/controller/GroupRecommendationController.java new file mode 100644 index 0000000..894a5cd --- /dev/null +++ b/src/main/java/com/moneygement/lyf/jarvis/recommendation/controller/GroupRecommendationController.java @@ -0,0 +1,30 @@ +package com.moneygement.lyf.jarvis.recommendation.controller; + +import java.util.List; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.moneygement.lyf.jarvis.recommendation.domain.Recommendation; +import com.moneygement.lyf.jarvis.recommendation.service.RecommendationService; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; + +@RestController +@RequestMapping("/api/recommend") +@RequiredArgsConstructor +@Tag(name = "Recommend", description = "추천 관련 정보를 호출하고, 저장하고, 조회할 수 있습니다.") +public class GroupRecommendationController { + private final RecommendationService recommendationService; + + @GetMapping("group/{groupId}") + @Operation(summary = "History 조회", description = "GroupId 기준의 추천 장소 목록 정보를 제공 합니다.") + public List getRecommendationsByGroupId(@PathVariable Long groupId) { + return recommendationService.getRecommendationsByGroupId(groupId); + } + +} diff --git a/src/main/java/com/moneygement/lyf/jarvis/recommendation/domain/GroupRecommendation.java b/src/main/java/com/moneygement/lyf/jarvis/recommendation/domain/GroupRecommendation.java index eca5952..0b6c4f0 100644 --- a/src/main/java/com/moneygement/lyf/jarvis/recommendation/domain/GroupRecommendation.java +++ b/src/main/java/com/moneygement/lyf/jarvis/recommendation/domain/GroupRecommendation.java @@ -32,8 +32,7 @@ public class GroupRecommendation { @Column(name = "owner_user_id", nullable = false, length = 40) private String ownerUserId; - public GroupRecommendation(String sessionName, String introduction, String ownerUserId) { - this.sessionName = sessionName; + public GroupRecommendation(String introduction, String ownerUserId) { this.introduction = introduction; this.ownerUserId = ownerUserId; } diff --git a/src/main/java/com/moneygement/lyf/jarvis/recommendation/persistence/GroupRecommendationRepository.java b/src/main/java/com/moneygement/lyf/jarvis/recommendation/persistence/GroupRecommendationRepository.java new file mode 100644 index 0000000..0ce544b --- /dev/null +++ b/src/main/java/com/moneygement/lyf/jarvis/recommendation/persistence/GroupRecommendationRepository.java @@ -0,0 +1,10 @@ +package com.moneygement.lyf.jarvis.recommendation.persistence; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import com.moneygement.lyf.jarvis.recommendation.domain.GroupRecommendation; + +@Repository +public interface GroupRecommendationRepository extends JpaRepository { +} diff --git a/src/main/java/com/moneygement/lyf/jarvis/recommendation/persistence/RecommendationRepository.java b/src/main/java/com/moneygement/lyf/jarvis/recommendation/persistence/RecommendationRepository.java new file mode 100644 index 0000000..6078840 --- /dev/null +++ b/src/main/java/com/moneygement/lyf/jarvis/recommendation/persistence/RecommendationRepository.java @@ -0,0 +1,12 @@ +package com.moneygement.lyf.jarvis.recommendation.persistence; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +import java.util.List; + +import com.moneygement.lyf.jarvis.recommendation.domain.Recommendation; + +@Repository +public interface RecommendationRepository extends JpaRepository { + List findByGroupId(Long groupId); +} \ No newline at end of file diff --git a/src/main/java/com/moneygement/lyf/jarvis/recommendation/service/RecommendationService.java b/src/main/java/com/moneygement/lyf/jarvis/recommendation/service/RecommendationService.java new file mode 100644 index 0000000..5dd6b88 --- /dev/null +++ b/src/main/java/com/moneygement/lyf/jarvis/recommendation/service/RecommendationService.java @@ -0,0 +1,9 @@ +package com.moneygement.lyf.jarvis.recommendation.service; + +import java.util.List; + +import com.moneygement.lyf.jarvis.recommendation.domain.Recommendation; + +public interface RecommendationService { + List getRecommendationsByGroupId(Long groupId); +} diff --git a/src/main/java/com/moneygement/lyf/jarvis/recommendation/service/RecommendationServiceImpl.java b/src/main/java/com/moneygement/lyf/jarvis/recommendation/service/RecommendationServiceImpl.java new file mode 100644 index 0000000..9c69f34 --- /dev/null +++ b/src/main/java/com/moneygement/lyf/jarvis/recommendation/service/RecommendationServiceImpl.java @@ -0,0 +1,21 @@ +package com.moneygement.lyf.jarvis.recommendation.service; + +import java.util.List; + +import org.springframework.stereotype.Service; + +import com.moneygement.lyf.jarvis.recommendation.domain.Recommendation; +import com.moneygement.lyf.jarvis.recommendation.persistence.RecommendationRepository; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class RecommendationServiceImpl implements RecommendationService{ + private final RecommendationRepository recommendationRepository; + + public List getRecommendationsByGroupId(Long groupId) { + return recommendationRepository.findByGroupId(groupId); + } + +}