Skip to content

Commit

Permalink
Merge pull request #235 from haedoang/feature/liked
Browse files Browse the repository at this point in the history
[feature/liked] 검색 가구 수정
  • Loading branch information
haedoang authored Oct 19, 2023
2 parents 0043ba5 + 5b89011 commit 24c40ac
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public record RoomSearchCondition(
@Schema(description = "룸 타입", example = "STUDIO, ONE_BED_FLATS")
List<RoomType> types,

@Schema(description = "가구류", example = "TV, DOOR_LOCK")
List<FurnishingType> furnishingTypes
@Schema(description = "가구류 ID", example = "1,2,3")
List<Long> furnishingTypes
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public record WriterResponse(

@Schema(description = "작성자 성별")
Gender gender,

@Schema(description = "작성자 생년월일")
LocalDate birthDate,

Expand Down
27 changes: 15 additions & 12 deletions src/main/java/com/koliving/api/room/infra/RoomRepositoryImpl.java
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -39,7 +38,6 @@ public Page<RoomResponse> search(Pageable pageable, RoomSearchCondition conditio
.limit(pageable.getPageSize())
.fetch();


long count = queryFactory.selectFrom(room)
.where(
filterByLocationIds(condition.locationIds()),
Expand All @@ -57,20 +55,25 @@ public Page<RoomResponse> search(Pageable pageable, RoomSearchCondition conditio
.collect(Collectors.toList()), pageable, () -> count);
}

private BooleanExpression filterByFurnishings(List<FurnishingType> furnishingTypes) {
private BooleanExpression filterByFurnishings(List<Long> 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<RoomType> types) {
if (CollectionUtils.isEmpty(types)) {
return null;
}

return room.roomInfo.roomType.in(types);
return room.roomInfo
.roomType
.in(types);
}

private BooleanExpression filterByAvailableDate(LocalDate localDate) {
Expand Down

0 comments on commit 24c40ac

Please sign in to comment.