From dbc9c439ff2d696e927b688954125fd6190e7630 Mon Sep 17 00:00:00 2001 From: ji hwan Date: Fri, 10 May 2024 16:22:36 +0900 Subject: [PATCH] =?UTF-8?q?#25=20refactor:=20=EC=BB=A8=ED=85=90=EC=B8=A0?= =?UTF-8?q?=20=EC=A2=85=EB=A5=98=EB=B3=84=20=EC=A1=B0=ED=9A=8C=EB=A5=BC=20?= =?UTF-8?q?=EB=AA=A8=EC=9E=84=EB=B3=84=20=EC=A1=B0=ED=9A=8C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../capstone/content/controller/ContentController.java | 4 ++-- .../capstone/content/domain/ContentRepository.java | 3 ++- .../capstone/content/service/ContentService.java | 10 +++++++--- backend/src/main/resources/application.yml | 7 +------ 4 files changed, 12 insertions(+), 12 deletions(-) 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