From 5dbd2572d7d5c3de1d731bd2a1772793358aa5a0 Mon Sep 17 00:00:00 2001 From: carsago Date: Mon, 25 Mar 2024 12:57:14 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=ED=95=99=EA=B5=90=20=EA=B2=80?= =?UTF-8?q?=EC=83=89=20DTO=20=EA=B3=B5=EC=9A=A9=EC=A0=81=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/SchoolBookmarkV1QueryService.java | 4 ++-- .../dto/SchoolBookmarkTotalV1Response.java | 14 -------------- .../bookmark/dto/SchoolBookmarkV1Response.java | 14 -------------- .../bookmark/dto/v1/SchoolBookmarkV1Response.java | 15 +++++++++++++++ .../presentation/SchoolBookmarkController.java | 4 ++-- .../SchoolBookmarkV1QuerydslRepository.java | 12 ++++++------ 6 files changed, 25 insertions(+), 38 deletions(-) delete mode 100644 backend/src/main/java/com/festago/bookmark/dto/SchoolBookmarkTotalV1Response.java delete mode 100644 backend/src/main/java/com/festago/bookmark/dto/SchoolBookmarkV1Response.java create mode 100644 backend/src/main/java/com/festago/bookmark/dto/v1/SchoolBookmarkV1Response.java diff --git a/backend/src/main/java/com/festago/bookmark/application/SchoolBookmarkV1QueryService.java b/backend/src/main/java/com/festago/bookmark/application/SchoolBookmarkV1QueryService.java index 68f0dace3..65c6f23ed 100644 --- a/backend/src/main/java/com/festago/bookmark/application/SchoolBookmarkV1QueryService.java +++ b/backend/src/main/java/com/festago/bookmark/application/SchoolBookmarkV1QueryService.java @@ -1,6 +1,6 @@ package com.festago.bookmark.application; -import com.festago.bookmark.dto.SchoolBookmarkTotalV1Response; +import com.festago.bookmark.dto.v1.SchoolBookmarkV1Response; import com.festago.bookmark.repository.SchoolBookmarkV1QuerydslRepository; import java.util.List; import lombok.RequiredArgsConstructor; @@ -14,7 +14,7 @@ public class SchoolBookmarkV1QueryService { private final SchoolBookmarkV1QuerydslRepository schoolBookmarkV1QuerydslRepository; - public List findAllByMemberId(Long memberId) { + public List findAllByMemberId(Long memberId) { return schoolBookmarkV1QuerydslRepository.findAllByMemberId(memberId); } } diff --git a/backend/src/main/java/com/festago/bookmark/dto/SchoolBookmarkTotalV1Response.java b/backend/src/main/java/com/festago/bookmark/dto/SchoolBookmarkTotalV1Response.java deleted file mode 100644 index f0688c45a..000000000 --- a/backend/src/main/java/com/festago/bookmark/dto/SchoolBookmarkTotalV1Response.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.festago.bookmark.dto; - -import com.querydsl.core.annotations.QueryProjection; -import java.time.LocalDateTime; - -public record SchoolBookmarkTotalV1Response( - SchoolBookmarkV1Response school, - LocalDateTime bookmarkCreatedAt -) { - - @QueryProjection - public SchoolBookmarkTotalV1Response { - } -} diff --git a/backend/src/main/java/com/festago/bookmark/dto/SchoolBookmarkV1Response.java b/backend/src/main/java/com/festago/bookmark/dto/SchoolBookmarkV1Response.java deleted file mode 100644 index 92327a4b6..000000000 --- a/backend/src/main/java/com/festago/bookmark/dto/SchoolBookmarkV1Response.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.festago.bookmark.dto; - -import com.querydsl.core.annotations.QueryProjection; - -public record SchoolBookmarkV1Response( - Long id, - String name, - String logoUrl -) { - - @QueryProjection - public SchoolBookmarkV1Response { - } -} diff --git a/backend/src/main/java/com/festago/bookmark/dto/v1/SchoolBookmarkV1Response.java b/backend/src/main/java/com/festago/bookmark/dto/v1/SchoolBookmarkV1Response.java new file mode 100644 index 000000000..3b9a219e2 --- /dev/null +++ b/backend/src/main/java/com/festago/bookmark/dto/v1/SchoolBookmarkV1Response.java @@ -0,0 +1,15 @@ +package com.festago.bookmark.dto.v1; + +import com.festago.school.dto.v1.SchoolSearchV1Response; +import com.querydsl.core.annotations.QueryProjection; +import java.time.LocalDateTime; + +public record SchoolBookmarkV1Response( + SchoolSearchV1Response school, + LocalDateTime bookmarkCreatedAt +) { + + @QueryProjection + public SchoolBookmarkV1Response { + } +} diff --git a/backend/src/main/java/com/festago/bookmark/presentation/SchoolBookmarkController.java b/backend/src/main/java/com/festago/bookmark/presentation/SchoolBookmarkController.java index 19440642b..9f40b2678 100644 --- a/backend/src/main/java/com/festago/bookmark/presentation/SchoolBookmarkController.java +++ b/backend/src/main/java/com/festago/bookmark/presentation/SchoolBookmarkController.java @@ -2,7 +2,7 @@ import com.festago.auth.annotation.Member; import com.festago.bookmark.application.SchoolBookmarkV1QueryService; -import com.festago.bookmark.dto.SchoolBookmarkTotalV1Response; +import com.festago.bookmark.dto.v1.SchoolBookmarkV1Response; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import java.util.List; @@ -22,7 +22,7 @@ public class SchoolBookmarkController { @GetMapping @Operation(description = "특정한 회원의 학교 북마크 목록을 반환한다", summary = "회원 학교 북마크 목록 조회") - public ResponseEntity> findAllByMemberId(@Member Long memberId) { + public ResponseEntity> findAllByMemberId(@Member Long memberId) { return ResponseEntity.ok(schoolBookmarkV1QueryService.findAllByMemberId(memberId)); } } diff --git a/backend/src/main/java/com/festago/bookmark/repository/SchoolBookmarkV1QuerydslRepository.java b/backend/src/main/java/com/festago/bookmark/repository/SchoolBookmarkV1QuerydslRepository.java index d89aa6d61..e425a6ff1 100644 --- a/backend/src/main/java/com/festago/bookmark/repository/SchoolBookmarkV1QuerydslRepository.java +++ b/backend/src/main/java/com/festago/bookmark/repository/SchoolBookmarkV1QuerydslRepository.java @@ -6,10 +6,10 @@ import com.festago.bookmark.domain.Bookmark; import com.festago.bookmark.domain.BookmarkType; -import com.festago.bookmark.dto.QSchoolBookmarkTotalV1Response; -import com.festago.bookmark.dto.QSchoolBookmarkV1Response; -import com.festago.bookmark.dto.SchoolBookmarkTotalV1Response; +import com.festago.bookmark.dto.v1.QSchoolBookmarkV1Response; +import com.festago.bookmark.dto.v1.SchoolBookmarkV1Response; import com.festago.common.querydsl.QueryDslRepositorySupport; +import com.festago.school.dto.v1.QSchoolSearchV1Response; import java.util.List; import org.springframework.stereotype.Repository; @@ -20,9 +20,9 @@ protected SchoolBookmarkV1QuerydslRepository() { super(Bookmark.class); } - public List findAllByMemberId(Long memberId) { - return select(new QSchoolBookmarkTotalV1Response( - new QSchoolBookmarkV1Response(school.id, school.name, school.logoUrl), bookmark.createdAt)) + public List findAllByMemberId(Long memberId) { + return select(new QSchoolBookmarkV1Response( + new QSchoolSearchV1Response(school.id, school.name, school.logoUrl), bookmark.createdAt)) .from(bookmark) .innerJoin(school).on(school.id.eq(bookmark.resourceId)) .where(bookmark.bookmarkType.eq(BookmarkType.SCHOOL)