Skip to content

Commit

Permalink
Merge pull request #136 from CoolPeace-yanolza/develop
Browse files Browse the repository at this point in the history
2024-01-19 release
  • Loading branch information
tkddn204 authored Jan 19, 2024
2 parents 9028167 + 4cb7e37 commit 4a397b4
Show file tree
Hide file tree
Showing 26 changed files with 201 additions and 177 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public record CouponExposeRequest(

@NotNull(message = "쿠폰의 상태를 입력해야 합니다.")
@ValidEnum(enumClass = CouponStatusType.class, message = "올바른 쿠폰 상태를 입력해야 합니다.")
CouponStatusType couponStatus
String couponStatus
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.util.List;

Expand All @@ -19,19 +18,19 @@ public record CouponRegisterRequest(
String title,
@NotNull(message = "고객의 유형을 선택해야 합니다.")
@ValidEnum(enumClass = CustomerType.class, message = "올바르지 않은 고객의 유형입니다.")
CustomerType customerType,
String customerType,

// 할인 정책
@NotNull(message = "할인의 유형을 선택해야 합니다.")
@ValidEnum(enumClass = DiscountType.class, message = "올바르지 않은 할인의 유형입니다.")
DiscountType discountType,
String discountType,
@NotNull(message = "할인의 값을 입력해야 합니다.")
Integer discountValue,

// 객실 유형
@NotNull(message = "객실의 유형을 선택해야 합니다.")
@ValidEnum(enumClass = CouponRoomType.class, message = "올바르지 않은 객실의 유형입니다.")
CouponRoomType couponRoomType,
String couponRoomType,

// 숙소 ID
@NotNull(message = "숙박업체의 ID를 입력해야 합니다.")
Expand All @@ -44,7 +43,7 @@ public record CouponRegisterRequest(

// 쿠폰 사용 조건
Integer minimumReservationPrice,
List<DayOfWeek> couponUseConditionDays,
List<String> couponUseConditionDays,

// 노출 날짜
@NotNull(message = "노출 시작 날짜를 입력해야 합니다.")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
package com.coolpeace.domain.coupon.dto.request;

import com.coolpeace.domain.coupon.entity.type.CouponRoomType;
import com.coolpeace.domain.coupon.entity.type.CustomerType;
import com.coolpeace.domain.coupon.entity.type.DiscountType;
import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.NotNull;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.util.List;

public record CouponUpdateRequest(
@NotNull(message = "숙박업체의 ID를 입력해야 합니다.")
Long accommodationId,
CustomerType customerType,
DiscountType discountType,
// @ValidEnum(enumClass = CustomerType.class, message = "올바르지 않은 고객의 유형입니다.")
String customerType,
// @ValidEnum(enumClass = DiscountType.class, message = "올바르지 않은 고객의 유형입니다.")
String discountType,
Integer discountValue,
CouponRoomType couponRoomType,
// @ValidEnum(enumClass = CouponRoomType.class, message = "올바르지 않은 고객의 유형입니다.")
String couponRoomType,
Boolean registerAllRoom,
List<Integer> registerRooms,
Integer minimumReservationPrice,
List<DayOfWeek> couponUseConditionDays,
List<String> couponUseConditionDays,
@JsonFormat(pattern = "yyyy-MM-dd")
LocalDate exposureStartDate,
@JsonFormat(pattern = "yyyy-MM-dd")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

public record SearchCouponParams(
@ValidEnum(enumClass = SearchCouponStatusFilterType.class, message = "올바른 쿠폰 상태 값을 입력해주세요.")
SearchCouponStatusFilterType status,
String status,
String title,
@ValidEnum(enumClass = SearchCouponDateFilterType.class, message = "올바른 쿠폰 날짜 값을 입력해주세요.")
SearchCouponDateFilterType date
String date
) {
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
package com.coolpeace.domain.coupon.dto.request.type;

public enum SearchCouponDateFilterType {
YEAR, THREE_MONTHS, SIX_MONTHS
import com.coolpeace.global.common.ValuedEnum;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum SearchCouponDateFilterType implements ValuedEnum {
YEAR("1년"),
THREE_MONTHS("3개월"),
SIX_MONTHS("6개월");

private final String value;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
package com.coolpeace.domain.coupon.dto.request.type;

public enum SearchCouponStatusFilterType {
All, EXPOSURE_ON, EXPOSURE_OFF, EXPIRED
import com.coolpeace.global.common.ValuedEnum;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum SearchCouponStatusFilterType implements ValuedEnum {
All("전체"),
EXPOSURE_ON("노출 ON"),
EXPOSURE_OFF("노출 OFF"),
EXPIRED("만료");

private final String value;
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.coolpeace.domain.coupon.entity.type;

import com.coolpeace.global.common.ValuedEnum;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum CouponIssuerType {
public enum CouponIssuerType implements ValuedEnum {
YANOLJA("YC"),
OWNER("CC");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.coolpeace.domain.coupon.entity.type;

import com.coolpeace.global.common.ValuedEnum;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum CouponRoomType {
RENTAL(0, "대실"),
LODGE(1, "숙박"),
TWO_NIGHT(2, "2박 이상");
public enum CouponRoomType implements ValuedEnum {
RENTAL("대실"),
LODGE("숙박"),
TWO_NIGHT("2박 이상");

private final Integer index;
private final String value;
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package com.coolpeace.domain.coupon.entity.type;

import com.coolpeace.global.common.ValuedEnum;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum CouponStatusType {
EXPOSURE_ON("ON"),
EXPOSURE_OFF("OFF"),
EXPOSURE_WAIT("대기중"),
EXPOSURE_END("종료"),
public enum CouponStatusType implements ValuedEnum {
EXPOSURE_ON("노출 ON"),
EXPOSURE_OFF("노출 OFF"),
EXPOSURE_WAIT("노출 대기중"),
EXPOSURE_END("노출 기간 만료"),
DELETED("삭제");

private final String value;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package com.coolpeace.domain.coupon.entity.type;

import com.coolpeace.global.common.ValuedEnum;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
public enum CustomerType {
@RequiredArgsConstructor
public enum CustomerType implements ValuedEnum {
ALL_CLIENT("모든 고객"),
FIRST_CLIENT("첫방문 고객"),
RE_CLIENT("재방문 고객");

private final String value;

CustomerType(String value) {
this.value = value;
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package com.coolpeace.domain.coupon.entity.type;

import com.coolpeace.global.common.ValuedEnum;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
public enum DiscountType {
@RequiredArgsConstructor
public enum DiscountType implements ValuedEnum {
FIXED_RATE("정률"),
FIXED_PRICE("정액");

private final String value;

DiscountType(String value) {
this.value = value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import com.coolpeace.domain.accommodation.entity.Accommodation;
import com.coolpeace.domain.coupon.dto.request.SearchCouponParams;
import com.coolpeace.domain.coupon.dto.request.type.SearchCouponDateFilterType;
import com.coolpeace.domain.coupon.dto.request.type.SearchCouponStatusFilterType;
import com.coolpeace.domain.coupon.entity.Coupon;
import com.coolpeace.domain.coupon.entity.type.CouponStatusType;
import com.coolpeace.global.common.ValuedEnum;
import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.Tuple;
import com.querydsl.jpa.impl.JPAQuery;
Expand All @@ -23,6 +26,8 @@

import static com.coolpeace.domain.coupon.entity.QCoupon.coupon;
import static com.coolpeace.domain.coupon.entity.QCouponRooms.couponRooms;
import static com.coolpeace.domain.coupon.entity.type.CouponStatusType.EXPOSURE_OFF;
import static com.coolpeace.domain.coupon.entity.type.CouponStatusType.EXPOSURE_ON;
import static com.coolpeace.domain.room.entity.QRoom.room;

public class CouponRepositoryImpl extends QuerydslRepositorySupport implements CouponRepositoryCustom {
Expand All @@ -41,9 +46,9 @@ public Page<Coupon> findAllCoupons(Long memberId, SearchCouponParams params, Pag

// 쿠폰 상태
if (params.status() != null) {
searchCouponPredicate.and(switch (params.status()) {
case EXPOSURE_ON -> coupon.couponStatus.eq(CouponStatusType.EXPOSURE_ON);
case EXPOSURE_OFF -> coupon.couponStatus.eq(CouponStatusType.EXPOSURE_OFF)
searchCouponPredicate.and(switch (ValuedEnum.of(SearchCouponStatusFilterType.class, params.status())) {
case EXPOSURE_ON -> coupon.couponStatus.eq(EXPOSURE_ON);
case EXPOSURE_OFF -> coupon.couponStatus.eq(EXPOSURE_OFF)
.or(coupon.couponStatus.eq(CouponStatusType.EXPOSURE_WAIT));
case EXPIRED -> coupon.couponStatus.eq(CouponStatusType.EXPOSURE_END)
.or(coupon.couponStatus.eq(CouponStatusType.DELETED));
Expand All @@ -58,7 +63,7 @@ public Page<Coupon> findAllCoupons(Long memberId, SearchCouponParams params, Pag

// 쿠폰 날짜
if (params.date() != null) {
searchCouponPredicate.and(switch (params.date()) {
searchCouponPredicate.and(switch (ValuedEnum.of(SearchCouponDateFilterType.class, params.date())) {
case THREE_MONTHS -> coupon.createdAt.after(LocalDateTime.now().minusMonths(3));
case SIX_MONTHS -> coupon.createdAt.after(LocalDateTime.now().minusMonths(6));
case YEAR -> coupon.createdAt.after(LocalDateTime.now().minusYears(1));
Expand Down Expand Up @@ -119,7 +124,7 @@ public List<Coupon> exposureCoupons(Long memberId, Long accommodationId) {
return jpaQueryFactory.selectFrom(coupon)
.where(coupon.member.id.eq(memberId)
.and(coupon.accommodation.id.eq(accommodationId))
.and(coupon.couponStatus.eq(CouponStatusType.EXPOSURE_ON)))
.and(coupon.couponStatus.eq(EXPOSURE_ON)))
.fetch();
}

Expand All @@ -139,7 +144,7 @@ public Boolean noExposure(Long memberId, Long accommodationId) {
return jpaQueryFactory.selectFrom(coupon)
.where(coupon.member.id.eq(memberId)
.and(coupon.accommodation.id.eq(accommodationId))
.and(coupon.couponStatus.eq(CouponStatusType.EXPOSURE_ON)))
.and(coupon.couponStatus.eq(EXPOSURE_ON)))
.fetch().isEmpty();
}

Expand Down
Loading

0 comments on commit 4a397b4

Please sign in to comment.