Skip to content

Commit

Permalink
refactor: 학교 검색 DTO 공용적으로 사용하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
carsago committed Mar 25, 2024
1 parent 1c3d3cd commit 5dbd257
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -14,7 +14,7 @@ public class SchoolBookmarkV1QueryService {

private final SchoolBookmarkV1QuerydslRepository schoolBookmarkV1QuerydslRepository;

public List<SchoolBookmarkTotalV1Response> findAllByMemberId(Long memberId) {
public List<SchoolBookmarkV1Response> findAllByMemberId(Long memberId) {
return schoolBookmarkV1QuerydslRepository.findAllByMemberId(memberId);
}
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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 {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,7 +22,7 @@ public class SchoolBookmarkController {

@GetMapping
@Operation(description = "특정한 회원의 학교 북마크 목록을 반환한다", summary = "회원 학교 북마크 목록 조회")
public ResponseEntity<List<SchoolBookmarkTotalV1Response>> findAllByMemberId(@Member Long memberId) {
public ResponseEntity<List<SchoolBookmarkV1Response>> findAllByMemberId(@Member Long memberId) {
return ResponseEntity.ok(schoolBookmarkV1QueryService.findAllByMemberId(memberId));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -20,9 +20,9 @@ protected SchoolBookmarkV1QuerydslRepository() {
super(Bookmark.class);
}

public List<SchoolBookmarkTotalV1Response> findAllByMemberId(Long memberId) {
return select(new QSchoolBookmarkTotalV1Response(
new QSchoolBookmarkV1Response(school.id, school.name, school.logoUrl), bookmark.createdAt))
public List<SchoolBookmarkV1Response> 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)
Expand Down

0 comments on commit 5dbd257

Please sign in to comment.