diff --git a/backend/src/main/java/com/project/capstone/content/controller/ContentController.java b/backend/src/main/java/com/project/capstone/content/controller/ContentController.java index e56f1b0ee4..b57e1b278c 100644 --- a/backend/src/main/java/com/project/capstone/content/controller/ContentController.java +++ b/backend/src/main/java/com/project/capstone/content/controller/ContentController.java @@ -36,8 +36,8 @@ public ResponseEntity getContent(@PathVariable Long id) { // 컨텐츠 종류별 조회 @GetMapping("/get") - public ResponseEntity> getContents(@RequestParam String type) { - List contentResponseList = contentService.getContents(type); + public ResponseEntity> getContents(@RequestParam String type, @RequestParam Long clubId) { + List contentResponseList = contentService.getContents(type, clubId); return ResponseEntity.ok().body(contentResponseList); } } diff --git a/backend/src/main/java/com/project/capstone/content/domain/ContentRepository.java b/backend/src/main/java/com/project/capstone/content/domain/ContentRepository.java index cf9c9190cc..86e2e2037a 100644 --- a/backend/src/main/java/com/project/capstone/content/domain/ContentRepository.java +++ b/backend/src/main/java/com/project/capstone/content/domain/ContentRepository.java @@ -1,5 +1,6 @@ package com.project.capstone.content.domain; +import com.project.capstone.club.domain.Club; import org.springframework.data.jpa.repository.JpaRepository; import java.util.List; @@ -7,5 +8,5 @@ public interface ContentRepository extends JpaRepository { Optional findContentById(Long id); - List findContentsByType(ContentType type); + List findContentsByTypeAndClub(ContentType type, Club club); } diff --git a/backend/src/main/java/com/project/capstone/content/service/ContentService.java b/backend/src/main/java/com/project/capstone/content/service/ContentService.java index fa8261c05f..bb2bd362c1 100644 --- a/backend/src/main/java/com/project/capstone/content/service/ContentService.java +++ b/backend/src/main/java/com/project/capstone/content/service/ContentService.java @@ -90,11 +90,15 @@ public ContentResponse getContent(Long id) { return new ContentResponse(content); } - public List getContents(String type) { + public List getContents(String type, Long clubId) { + Club club = clubRepository.findClubById(clubId).orElseThrow( + () -> new ClubException(CLUB_NOT_FOUND) + ); + for (ContentType contentType : ContentType.values()) { if (contentType.equals(ContentType.valueOf(type))) { - List contentsByType = contentRepository.findContentsByType(ContentType.valueOf(type)); - return contentsByType.stream() + List contentsByTypeAndClub = contentRepository.findContentsByTypeAndClub(ContentType.valueOf(type), club); + return contentsByTypeAndClub.stream() .map(ContentResponse::new) .toList(); } diff --git a/backend/src/main/resources/application.yml b/backend/src/main/resources/application.yml index 98c1b8ba6c..70094e9492 100644 --- a/backend/src/main/resources/application.yml +++ b/backend/src/main/resources/application.yml @@ -7,12 +7,7 @@ spring: jpa: hibernate: - ddl-auto: create - defer-datasource-initialization: true - - sql: - init: - mode: always + ddl-auto: update jwt: secret: ${JWT_SECRET} \ No newline at end of file