Skip to content

Commit

Permalink
fix: 예약 리스트 조회 시 리뷰 제거 및 조회 시점 타입 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
min9805 committed May 24, 2024
1 parent 028d2c2 commit 8ab09b1
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.swygbro.trip.backend.domain.guideProduct.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.swygbro.trip.backend.domain.guideProduct.domain.GuideCategory;
import com.swygbro.trip.backend.domain.guideProduct.domain.GuideCategoryCode;
import com.swygbro.trip.backend.domain.guideProduct.domain.GuideProduct;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.ZonedDateTime;
import java.util.List;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class GuideProductSimpleDto {
@Schema(description = "유저 ID", example = "1")
private Long userId;
@Schema(description = "사용자 닉네임", example = "nickname01")
private String nickname;
@Schema(description = "상품 ID", example = "1")
private Long id;
@Schema(description = "상품 제목", example = "신나는 서울 투어")
private String title;
@Schema(description = "상품 설명", example = "서울 *** 여행 가이드 합니다.")
private String description;
@Schema(description = "가이드 비용", example = "10000")
private Long price;
@Schema(description = "가이드 위치 이름", example = "한강 공원")
private String locationName;
@Schema(description = "가이드 위치(위도)", example = "37")
private double latitude;
@Schema(description = "가이드 위치(경도)", example = "127")
private double longitude;
@Schema(description = "가이드 시작 날짜/시간", example = "2024-05-01 12:00:00")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Seoul")
private ZonedDateTime guideStart;
@Schema(description = "가이드 종료 날짜/시간", example = "2024-05-01 14:00:00")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Seoul")
private ZonedDateTime guideEnd;
@Schema(description = "가이드 소요 시간", example = "3")
private int guideTime;
@Schema(description = "상품 카테고리", example = "[\"DINING\", \"OUTDOOR\"]")
private List<GuideCategoryCode> categories;
@Schema(description = "대표 이미지 url", example = "https://S3저장소URL/저장위치/난수화된 이미지이름.이미지 타입")
private String thumb;

public static GuideProductSimpleDto fromEntity(GuideProduct product) {
List<GuideCategoryCode> categories = product.getCategories().stream().map(GuideCategory::getCategoryCode).toList();

return GuideProductSimpleDto.builder().id(product.getId())
.userId(product.getUser().getId())
.nickname(product.getUser().getNickname())
.title(product.getTitle())
.description(product.getDescription()).price(product.getPrice()).locationName(product.getLocationName())
.longitude(product.getLocation().getX()).latitude(product.getLocation().getY())
.guideStart(product.getGuideStart()).guideEnd(product.getGuideEnd())
.guideTime(product.getGuideTime()).categories(categories)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public ResponseEntity<ReservationDto> cancelPayment(@PathVariable String merchan
| 필드명 | 설명 | 제약조건 | 예시 |
|--------|------|----------|----------|
| isPast | 과거 or 미래 조건 | Boolean | ture |
| timeFilter | 과거 or 미래 조건 | 0(과거), 1(미래), null(all) | ture |
| statusFilter | 예약 Status 조건 | 0(확정 대기), 1(확정 및 정산 완료), 2(취소) | 1 |
| offset | 조회 offset | - | 0 |
| pageSize | 조회 페이지 크기 | - | 10 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class ReservationCustomRepositoryImpl implements ReservationCustomReposit
public List<Reservation> findReservationsByClientId(Long clientId, ReservationSearchCriteria criteria) {
BooleanBuilder builder = new BooleanBuilder();

timeFilter(criteria.isPast(), builder);
timeFilter(criteria.getTimeFilter(), builder);
statusFilter(criteria.getStatusFilter(), builder);

return queryFactory
Expand All @@ -41,7 +41,7 @@ public List<Reservation> findReservationsByClientId(Long clientId, ReservationSe
public List<Reservation> findReservationsByGuideId(Long guideId, ReservationSearchCriteria criteria) {
BooleanBuilder builder = new BooleanBuilder();

timeFilter(criteria.isPast(), builder);
timeFilter(criteria.getTimeFilter(), builder);
statusFilter(criteria.getStatusFilter(), builder);

return queryFactory
Expand Down Expand Up @@ -70,10 +70,10 @@ private static void statusFilter(int statusFilter, BooleanBuilder builder) {
}
}

private static void timeFilter(boolean isPast, BooleanBuilder builder) {
if (isPast) {
private static void timeFilter(int timeFilter, BooleanBuilder builder) {
if (timeFilter == 0) {
builder.and(isBeforeFromNow());
} else {
} else if (timeFilter == 1) {
builder.and(isAfterFromNow());
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.swygbro.trip.backend.domain.reservation.dto;

import com.swygbro.trip.backend.domain.guideProduct.dto.GuideProductDto;
import com.swygbro.trip.backend.domain.guideProduct.dto.GuideProductSimpleDto;
import com.swygbro.trip.backend.domain.reservation.domain.Reservation;
import com.swygbro.trip.backend.domain.user.dto.SimpleUserDto;
import com.swygbro.trip.backend.global.status.PayStatus;
Expand All @@ -22,7 +22,7 @@ public class ReservationDto {
private SimpleUserDto guide;

@Schema(description = "상품")
private GuideProductDto product;
private GuideProductSimpleDto product;

@Schema(description = "가이드 시작 날짜", example = "2024-04-29T12:30:45Z")
private ZonedDateTime guideStart;
Expand Down Expand Up @@ -52,7 +52,7 @@ public class ReservationDto {
public ReservationDto fromEntity(Reservation reservation) {
return ReservationDto.builder()
.guide(SimpleUserDto.fromEntity(reservation.getGuide()))
.product(GuideProductDto.fromEntity(reservation.getProduct()))
.product(GuideProductSimpleDto.fromEntity(reservation.getProduct()))
.guideStart(reservation.getGuideStart())
.guideEnd(reservation.getGuideEnd())
.personnel(reservation.getPersonnel())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
@Getter
@Builder
public class ReservationSearchCriteria {
@Schema(description = "과거/미래 여부", example = "false")
private boolean isPast;
@Schema(description = "시점 필터 {0: 과거, 1: 미래, null: all}", example = "0")
private int timeFilter;

@Schema(description = "상태 필터 {0: 예약 확정 대기, 1: 예약 확정, 2: 예약 취소", example = "0")
private int statusFilter = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ void getReservationList() {

ReservationSearchCriteria criteria = ReservationSearchCriteria.builder()
.statusFilter(0)
.isPast(false)
.timeFilter(0)
.offset(0)
.pageSize(10)
.build();
Expand Down

0 comments on commit 8ab09b1

Please sign in to comment.