Skip to content

Commit

Permalink
✨ 추천 목록 조회 API 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
tinajeong committed Oct 28, 2024
1 parent f45e1ba commit b14468f
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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<Recommendation> getRecommendationsByGroupId(@PathVariable Long groupId) {
return recommendationService.getRecommendationsByGroupId(groupId);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<GroupRecommendation, Long> {
}
Original file line number Diff line number Diff line change
@@ -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<Recommendation, Long> {
List<Recommendation> findByGroupId(Long groupId);
}
Original file line number Diff line number Diff line change
@@ -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<Recommendation> getRecommendationsByGroupId(Long groupId);
}
Original file line number Diff line number Diff line change
@@ -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<Recommendation> getRecommendationsByGroupId(Long groupId) {
return recommendationRepository.findByGroupId(groupId);
}

}

0 comments on commit b14468f

Please sign in to comment.