From 5b890111e01d7901d9cd459bf639b74b8e2a7f03 Mon Sep 17 00:00:00 2001 From: haedoang Date: Thu, 19 Oct 2023 20:51:35 +0900 Subject: [PATCH] =?UTF-8?q?[feature/liked]=20=EA=B2=80=EC=83=89=20?= =?UTF-8?q?=EA=B0=80=EA=B5=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dto/RoomSearchCondition.java | 4 +-- .../room/application/dto/WriterResponse.java | 1 + .../api/room/infra/RoomRepositoryImpl.java | 27 ++++++++++--------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/koliving/api/room/application/dto/RoomSearchCondition.java b/src/main/java/com/koliving/api/room/application/dto/RoomSearchCondition.java index 213d3b8a..223af1c0 100644 --- a/src/main/java/com/koliving/api/room/application/dto/RoomSearchCondition.java +++ b/src/main/java/com/koliving/api/room/application/dto/RoomSearchCondition.java @@ -31,7 +31,7 @@ public record RoomSearchCondition( @Schema(description = "룸 타입", example = "STUDIO, ONE_BED_FLATS") List types, - @Schema(description = "가구류", example = "TV, DOOR_LOCK") - List furnishingTypes + @Schema(description = "가구류 ID", example = "1,2,3") + List furnishingTypes ) { } diff --git a/src/main/java/com/koliving/api/room/application/dto/WriterResponse.java b/src/main/java/com/koliving/api/room/application/dto/WriterResponse.java index f6ff57e8..40d9b89e 100644 --- a/src/main/java/com/koliving/api/room/application/dto/WriterResponse.java +++ b/src/main/java/com/koliving/api/room/application/dto/WriterResponse.java @@ -16,6 +16,7 @@ public record WriterResponse( @Schema(description = "작성자 성별") Gender gender, + @Schema(description = "작성자 생년월일") LocalDate birthDate, diff --git a/src/main/java/com/koliving/api/room/infra/RoomRepositoryImpl.java b/src/main/java/com/koliving/api/room/infra/RoomRepositoryImpl.java index e1a9d4d0..11fbe5c8 100644 --- a/src/main/java/com/koliving/api/room/infra/RoomRepositoryImpl.java +++ b/src/main/java/com/koliving/api/room/infra/RoomRepositoryImpl.java @@ -1,27 +1,26 @@ package com.koliving.api.room.infra; +import static com.koliving.api.room.domain.QRoom.room; + import com.koliving.api.room.application.dto.RoomResponse; import com.koliving.api.room.application.dto.RoomSearchCondition; -import com.koliving.api.room.domain.FurnishingType; import com.koliving.api.room.domain.Room; import com.koliving.api.room.domain.RoomType; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; +import java.time.LocalDate; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.support.PageableExecutionUtils; import org.springframework.util.CollectionUtils; -import java.time.LocalDate; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - -import static com.koliving.api.room.domain.QRoom.room; - @RequiredArgsConstructor public class RoomRepositoryImpl implements RoomRepositoryQueryDsl { + private final JPAQueryFactory queryFactory; @Override @@ -39,7 +38,6 @@ public Page search(Pageable pageable, RoomSearchCondition conditio .limit(pageable.getPageSize()) .fetch(); - long count = queryFactory.selectFrom(room) .where( filterByLocationIds(condition.locationIds()), @@ -57,12 +55,15 @@ public Page search(Pageable pageable, RoomSearchCondition conditio .collect(Collectors.toList()), pageable, () -> count); } - private BooleanExpression filterByFurnishings(List furnishingTypes) { + private BooleanExpression filterByFurnishings(List furnishingTypes) { if (CollectionUtils.isEmpty(furnishingTypes)) { return null; } - return room.furnishings.any().type.in(furnishingTypes); + return room.furnishings + .any() + .id + .in(furnishingTypes); } private BooleanExpression filterByTypes(List types) { @@ -70,7 +71,9 @@ private BooleanExpression filterByTypes(List types) { return null; } - return room.roomInfo.roomType.in(types); + return room.roomInfo + .roomType + .in(types); } private BooleanExpression filterByAvailableDate(LocalDate localDate) {