-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
책 평가 리스트 조회 응답 구조를 수정한다.
- Loading branch information
Showing
6 changed files
with
67 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 8 additions & 4 deletions
12
api/src/main/java/com/dnd/sbooky/api/evaluation/response/GetEvaluationResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
package com.dnd.sbooky.api.evaluation.response; | ||
|
||
import com.dnd.sbooky.core.evaluation.EvaluationKeyword; | ||
import com.dnd.sbooky.core.evaluation.dto.GetEvaluationDTO; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
@Schema(description = "평가 리스트 조회 응답") | ||
public record GetEvaluationResponse( | ||
@Schema(description = "평가 ID") Long evaluationId, | ||
@Schema(description = "평가 타입") String type, | ||
@Schema(description = "평가 키워드") String keyword) { | ||
@Schema(description = "평가 키워드") String keyword, | ||
@Schema(description = "선택 여부") boolean isSelected) { | ||
|
||
public static GetEvaluationResponse of(EvaluationKeyword keyword) { | ||
public static GetEvaluationResponse of(GetEvaluationDTO dto) { | ||
return new GetEvaluationResponse( | ||
keyword.getId(), keyword.getType().getDescription(), keyword.getDescription()); | ||
dto.evaluationId(), | ||
dto.type().getDescription(), | ||
dto.keyword().getDescription(), | ||
dto.isSelected()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
core/src/main/java/com/dnd/sbooky/core/evaluation/EvaluationRepositoryCustom.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.dnd.sbooky.core.evaluation; | ||
|
||
import com.dnd.sbooky.core.evaluation.dto.GetEvaluationDTO; | ||
import java.util.List; | ||
import org.springframework.data.repository.NoRepositoryBean; | ||
|
||
@NoRepositoryBean | ||
public interface EvaluationRepositoryCustom { | ||
|
||
List<GetEvaluationDTO> findAllWithSelectedByMemberBookId(Long memberBookId); | ||
} |
37 changes: 37 additions & 0 deletions
37
core/src/main/java/com/dnd/sbooky/core/evaluation/EvaluationRepositoryImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.dnd.sbooky.core.evaluation; | ||
|
||
import com.dnd.sbooky.core.evaluation.dto.GetEvaluationDTO; | ||
import com.querydsl.core.types.Projections; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
public class EvaluationRepositoryImpl implements EvaluationRepositoryCustom { | ||
|
||
private final JPAQueryFactory queryFactory; | ||
private final QEvaluationEntity evaluation = QEvaluationEntity.evaluationEntity; | ||
private final QBookEvaluationEntity bookEvaluation = QBookEvaluationEntity.bookEvaluationEntity; | ||
|
||
@Override | ||
public List<GetEvaluationDTO> findAllWithSelectedByMemberBookId(Long memberBookId) { | ||
|
||
return queryFactory | ||
.select( | ||
Projections.constructor( | ||
GetEvaluationDTO.class, | ||
evaluation.id, | ||
evaluation.type, | ||
evaluation.keyword, | ||
bookEvaluation.isNotNull().as("isSelected"))) | ||
.from(evaluation) | ||
.leftJoin(bookEvaluation) | ||
.on( | ||
bookEvaluation | ||
.evaluation | ||
.id | ||
.eq(evaluation.id) | ||
.and(bookEvaluation.memberBook.id.eq(memberBookId))) | ||
.fetch(); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
core/src/main/java/com/dnd/sbooky/core/evaluation/dto/GetEvaluationDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.dnd.sbooky.core.evaluation.dto; | ||
|
||
import com.dnd.sbooky.core.evaluation.EvaluationKeyword; | ||
import com.dnd.sbooky.core.evaluation.EvaluationType; | ||
|
||
public record GetEvaluationDTO( | ||
Long evaluationId, EvaluationType type, EvaluationKeyword keyword, boolean isSelected) {} |