From 42f3e516f8d26fa97436d88b90b8792edc4fcc1c Mon Sep 17 00:00:00 2001 From: HyunA Date: Fri, 2 Feb 2024 01:14:35 +0900 Subject: [PATCH 01/21] =?UTF-8?q?refactor:=20address=20=ED=85=8C=EC=9D=B4?= =?UTF-8?q?=EB=B8=94=20=EC=82=AD=EC=A0=9C=20=ED=9B=84=20accommodation?= =?UTF-8?q?=EC=97=90=20=EB=B3=91=ED=95=A9=20-=20=EB=B9=84=EC=A6=88?= =?UTF-8?q?=EB=8B=88=EC=8A=A4,=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EB=AA=A8?= =?UTF-8?q?=EB=91=90=20=EB=B9=8C=EB=93=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=ED=86=B5=EA=B3=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/AccommodationRegisterRequest.java | 9 ++-- .../response/AccommodationDetailResponse.java | 4 +- .../response/AccommodationInfoResponse.java | 4 +- .../AccommodationSummaryResponse.java | 2 +- .../accommodation/entity/Accommodation.java | 33 ++++++++----- .../domain/accommodation/entity/Address.java | 48 ------------------- .../service/AccommodationCommandService.java | 9 ++-- .../usecase/AccommodationQueryUseCase.java | 4 -- .../openapi/service/OpenApiService.java | 11 ++--- .../AccommodationOwnershipRepositoryTest.java | 9 ++-- .../AccommodationCommandServiceTest.java | 17 +++---- .../AccommodationQueryServiceTest.java | 13 ++--- .../CouponBackofficeControllerDocsTest.java | 9 ++-- .../CouponBackofficeControllerTest.java | 9 ++-- .../unit/repository/CouponRepositoryTest.java | 18 ++----- .../service/CouponBackofficeServiceTest.java | 10 ++-- .../docs/ReservationControllerDocsTest.java | 9 ++-- .../controller/ReservationControllerTest.java | 9 ++-- .../repository/ReservationRepositoryTest.java | 9 ++-- .../unit/service/ReservationServiceTest.java | 9 ++-- .../service/ReservationStockServiceTest.java | 9 ++-- .../unit/repository/RoomRepositoryTest.java | 9 ++-- .../unit/service/RoomCommandServiceTest.java | 37 +++++--------- .../unit/service/RoomQueryServiceTest.java | 13 ++--- 24 files changed, 95 insertions(+), 218 deletions(-) delete mode 100644 src/main/java/com/backoffice/upjuyanolja/domain/accommodation/entity/Address.java diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/request/AccommodationRegisterRequest.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/request/AccommodationRegisterRequest.java index aa4cff9f..3976b858 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/request/AccommodationRegisterRequest.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/request/AccommodationRegisterRequest.java @@ -1,7 +1,6 @@ package com.backoffice.upjuyanolja.domain.accommodation.dto.request; import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; -import com.backoffice.upjuyanolja.domain.accommodation.entity.Address; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.room.dto.request.RoomRegisterRequest; import jakarta.validation.constraints.NotBlank; @@ -51,11 +50,9 @@ public static Accommodation toEntity( ) { return Accommodation.builder() .name(request.name()) - .address(Address.builder() - .address(request.address()) - .detailAddress(request.detailAddress()) - .zipCode(request.zipCode()) - .build()) + .address(request.address()) + .detailAddress(request.detailAddress()) + .zipCode(request.zipCode()) .category(category) .description(request.description()) .thumbnail(request.thumbnail()) diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationDetailResponse.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationDetailResponse.java index 0da1a2d9..9fd990bb 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationDetailResponse.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationDetailResponse.java @@ -25,8 +25,8 @@ public static AccommodationDetailResponse of( .id(accommodation.getId()) .name(accommodation.getName()) .address( - accommodation.getAddress().getAddress() + "\n" - + accommodation.getAddress().getDetailAddress() + accommodation.getAddress() + "\n" + + accommodation.getDetailAddress() ) .description(accommodation.getDescription()) .category(accommodation.getCategory().getName()) diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationInfoResponse.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationInfoResponse.java index efec37b2..415d4e07 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationInfoResponse.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationInfoResponse.java @@ -26,9 +26,9 @@ public static AccommodationInfoResponse of(Accommodation accommodation) { .name(accommodation.getName()) .category(accommodation.getCategory().getName()) .description(accommodation.getDescription()) - .address(accommodation.getAddress().getAddress() + .address(accommodation.getAddress() + " " - + accommodation.getAddress().getDetailAddress()) + + accommodation.getDetailAddress()) .images(AccommodationImageResponse.of(accommodation.getImages())) .option(AccommodationOptionResponse.of(accommodation.getOption())) .rooms(rooms) diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationSummaryResponse.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationSummaryResponse.java index b8a8a06c..db70f261 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationSummaryResponse.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationSummaryResponse.java @@ -23,7 +23,7 @@ public static AccommodationSummaryResponse of( return AccommodationSummaryResponse.builder() .id(accommodation.getId()) .name(accommodation.getName()) - .address(accommodation.getAddress().getAddress()) + .address(accommodation.getAddress()) .category(accommodation.getCategory().getName()) .lowestPrice(lowestPrice) .discountPrice(discountPrice) diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/entity/Accommodation.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/entity/Accommodation.java index 11d95785..95e39641 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/entity/Accommodation.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/entity/Accommodation.java @@ -36,15 +36,6 @@ public class Accommodation extends BaseTime { @Comment("숙소 이름") private String name; - @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) - @Comment("숙소 위치") - private Address address; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "category_id") - @Comment("숙소 카테고리") - private Category category; - @Column(columnDefinition = "TEXT", nullable = false) @Comment("숙소 설명") private String description; @@ -53,6 +44,23 @@ public class Accommodation extends BaseTime { @Comment("숙소 대표 이미지 URL") private String thumbnail; + @Column(nullable = false) + @Comment("주소") + private String address; + + @Column(nullable = false) + @Comment("상세 주소") + private String detailAddress; + + @Column(nullable = false) + @Comment("우편번호") + private String zipCode; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "category_id") + @Comment("숙소 카테고리") + private Category category; + @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) @Comment("숙소 옵션 식별자") private AccommodationOption option; @@ -67,7 +75,9 @@ public class Accommodation extends BaseTime { public Accommodation( Long id, String name, - Address address, + String address, + String detailAddress, + String zipCode, Category category, String description, String thumbnail, @@ -78,6 +88,8 @@ public Accommodation( this.id = id; this.name = name; this.address = address; + this.detailAddress = detailAddress; + this.zipCode = zipCode; this.category = category; this.description = description; this.thumbnail = thumbnail; @@ -86,7 +98,6 @@ public Accommodation( this.rooms = rooms; } - // 숙소의 ID로 동등 비교를 하기 위해 추가함. @Override public boolean equals(Object o) { if (this == o) { diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/entity/Address.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/entity/Address.java deleted file mode 100644 index 2cd017bb..00000000 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/entity/Address.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.backoffice.upjuyanolja.domain.accommodation.entity; - -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import lombok.AccessLevel; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.hibernate.annotations.Comment; - -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -@Entity -public class Address { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Comment("주소 식별자") - private Long id; - - @Column(nullable = false) - @Comment("주소") - private String address; - - @Column(nullable = false) - @Comment("상세 주소") - private String detailAddress; - - @Column(nullable = false) - @Comment("우편번호") - private String zipCode; - - @Builder - public Address( - Long id, - String address, - String detailAddress, - String zipCode - ) { - this.id = id; - this.address = address; - this.detailAddress = detailAddress; - this.zipCode = zipCode; - } -} diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java index 7fd9d2e0..a8a72a46 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java @@ -6,7 +6,6 @@ import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOwnership; -import com.backoffice.upjuyanolja.domain.accommodation.entity.Address; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.accommodation.exception.AccommodationImageNotExistsException; import com.backoffice.upjuyanolja.domain.accommodation.exception.WrongCategoryException; @@ -51,11 +50,9 @@ public AccommodationInfoResponse createAccommodation( Accommodation accommodation = accommodationRepository.save(Accommodation.builder() .name(request.name()) - .address(Address.builder() - .address(request.address()) - .detailAddress(request.detailAddress()) - .zipCode(request.zipCode()) - .build()) + .address(request.address()) + .detailAddress(request.detailAddress()) + .zipCode(request.zipCode()) .description(request.description()) .category(category) .thumbnail(request.thumbnail()) diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/usecase/AccommodationQueryUseCase.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/usecase/AccommodationQueryUseCase.java index 34d05e5d..7e3c776a 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/usecase/AccommodationQueryUseCase.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/usecase/AccommodationQueryUseCase.java @@ -3,11 +3,7 @@ import com.backoffice.upjuyanolja.domain.accommodation.dto.response.AccommodationDetailResponse; import com.backoffice.upjuyanolja.domain.accommodation.dto.response.AccommodationOwnershipResponse; import com.backoffice.upjuyanolja.domain.accommodation.dto.response.AccommodationPageResponse; -import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; -import com.backoffice.upjuyanolja.domain.accommodation.entity.Address; -import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import java.time.LocalDate; -import lombok.Builder; import org.springframework.data.domain.Pageable; public interface AccommodationQueryUseCase { diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/openapi/service/OpenApiService.java b/src/main/java/com/backoffice/upjuyanolja/domain/openapi/service/OpenApiService.java index 2d1fba8e..896982ce 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/openapi/service/OpenApiService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/openapi/service/OpenApiService.java @@ -4,7 +4,6 @@ import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationImage; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOwnership; -import com.backoffice.upjuyanolja.domain.accommodation.entity.Address; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.accommodation.exception.WrongCategoryException; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationImageRepository; @@ -255,13 +254,9 @@ private Accommodation saveAccommodation( Accommodation accommodation = Accommodation.builder() .name(base.getString("title")) .category(category) - .address( - Address.builder() - .address(base.getString("addr1")) - .detailAddress(base.getString("addr2")) - .zipCode(common.getString("zipcode")) - .build() - ) + .address(base.getString("addr1")) + .detailAddress(base.getString("addr2")) + .zipCode(common.getString("zipcode")) .description(common.getString("overview")) .thumbnail(base.getString("firstimage")) .images(new ArrayList<>()) diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/repository/AccommodationOwnershipRepositoryTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/repository/AccommodationOwnershipRepositoryTest.java index dd1d702b..3d1f362a 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/repository/AccommodationOwnershipRepositoryTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/repository/AccommodationOwnershipRepositoryTest.java @@ -5,7 +5,6 @@ import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOwnership; -import com.backoffice.upjuyanolja.domain.accommodation.entity.Address; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationOwnershipRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationRepository; @@ -110,11 +109,9 @@ private Category saveCategory() { private Accommodation saveAccommodation() { return accommodationRepository.save(Accommodation.builder() .name("그랜드 하얏트 제주") - .address(Address.builder() - .address("제주특별자치도 제주시 노형동 925") - .detailAddress("") - .zipCode("63082") - .build()) + .address("제주특별자치도 제주시 노형동 925") + .detailAddress("") + .zipCode("63082") .category(saveCategory()) .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationCommandServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationCommandServiceTest.java index 4811229a..56dc8c21 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationCommandServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationCommandServiceTest.java @@ -13,7 +13,6 @@ import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationImage; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOwnership; -import com.backoffice.upjuyanolja.domain.accommodation.entity.Address; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationImageRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationOwnershipRepository; @@ -142,11 +141,9 @@ void _willSuccess() { Accommodation accommodation = Accommodation.builder() .id(1L) .name("그랜드 하얏트 제주") - .address(Address.builder() - .address("제주특별자치도 제주시 노형동 925") - .detailAddress("") - .zipCode("63082") - .build()) + .address("제주특별자치도 제주시 노형동 925") + .detailAddress("") + .zipCode("63082") .category(category) .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") @@ -220,11 +217,9 @@ void _willSuccess() { Accommodation savedAccommodation = Accommodation.builder() .id(1L) .name("그랜드 하얏트 제주") - .address(Address.builder() - .address("제주특별자치도 제주시 노형동 925") - .detailAddress("") - .zipCode("63082") - .build()) + .address("제주특별자치도 제주시 노형동 925") + .detailAddress("") + .zipCode("63082") .category(category) .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationQueryServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationQueryServiceTest.java index 49276add..09693ce1 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationQueryServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationQueryServiceTest.java @@ -9,7 +9,6 @@ import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationImage; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOwnership; -import com.backoffice.upjuyanolja.domain.accommodation.entity.Address; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationOwnershipRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationRepository; @@ -87,10 +86,8 @@ void _willSuccess() { Accommodation accommodation = Accommodation.builder() .id(1L) .name("그랜드 하얏트 제주") - .address(Address.builder() - .address("제주특별자치도 제주시 노형동 925") - .detailAddress("") - .build()) + .address("제주특별자치도 제주시 노형동 925") + .detailAddress("") .category(category) .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") @@ -140,10 +137,8 @@ void _willSuccess() { Accommodation savedAccommodation = Accommodation.builder() .id(1L) .name("그랜드 하얏트 제주") - .address(Address.builder() - .address("제주특별자치도 제주시 노형동 925") - .detailAddress("") - .build()) + .address("제주특별자치도 제주시 노형동 925") + .detailAddress("") .category(category) .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/docs/CouponBackofficeControllerDocsTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/docs/CouponBackofficeControllerDocsTest.java index 11627647..b4bea193 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/docs/CouponBackofficeControllerDocsTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/docs/CouponBackofficeControllerDocsTest.java @@ -20,7 +20,6 @@ import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; -import com.backoffice.upjuyanolja.domain.accommodation.entity.Address; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.coupon.dto.request.backoffice.CouponAddInfos; import com.backoffice.upjuyanolja.domain.coupon.dto.request.backoffice.CouponAddRequest; @@ -807,11 +806,9 @@ private Accommodation createAccommodation(Long accommodationId) { return Accommodation.builder() .id(accommodationId) .name("그랜드 하얏트 제주") - .address(Address.builder() - .address("제주특별자치도 제주시 노형동 925") - .detailAddress("") - .zipCode("63082") - .build()) + .address("제주특별자치도 제주시 노형동 925") + .detailAddress("") + .zipCode("63082") .category(createCategory()) .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/controller/CouponBackofficeControllerTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/controller/CouponBackofficeControllerTest.java index f7effd5c..485608a9 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/controller/CouponBackofficeControllerTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/controller/CouponBackofficeControllerTest.java @@ -17,7 +17,6 @@ import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; -import com.backoffice.upjuyanolja.domain.accommodation.entity.Address; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.coupon.controller.CouponBackofficeController; import com.backoffice.upjuyanolja.domain.coupon.dto.request.backoffice.CouponAddInfos; @@ -637,11 +636,9 @@ private Accommodation createAccommodation(Long accommodationId) { return Accommodation.builder() .id(accommodationId) .name("그랜드 하얏트 제주") - .address(Address.builder() - .address("제주특별자치도 제주시 노형동 925") - .detailAddress("") - .zipCode("63082") - .build()) + .address("제주특별자치도 제주시 노형동 925") + .detailAddress("") + .zipCode("63082") .category(createCategory()) .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/repository/CouponRepositoryTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/repository/CouponRepositoryTest.java index fd02ef48..0476b15f 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/repository/CouponRepositoryTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/repository/CouponRepositoryTest.java @@ -6,25 +6,16 @@ import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOwnership; -import com.backoffice.upjuyanolja.domain.accommodation.entity.Address; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationOwnershipRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.CategoryRepository; -import com.backoffice.upjuyanolja.domain.coupon.dto.request.backoffice.CouponAddInfos; -import com.backoffice.upjuyanolja.domain.coupon.dto.request.backoffice.CouponAddRequest; -import com.backoffice.upjuyanolja.domain.coupon.dto.request.backoffice.CouponAddRooms; -import com.backoffice.upjuyanolja.domain.coupon.dto.request.backoffice.CouponModifyInfos; -import com.backoffice.upjuyanolja.domain.coupon.dto.request.backoffice.CouponModifyRequest; -import com.backoffice.upjuyanolja.domain.coupon.dto.request.backoffice.CouponModifyRooms; import com.backoffice.upjuyanolja.domain.coupon.dto.response.backoffice.CouponMakeQueryDto; -import com.backoffice.upjuyanolja.domain.coupon.dto.response.backoffice.CouponMakeViewResponse; import com.backoffice.upjuyanolja.domain.coupon.dto.response.backoffice.CouponManageQueryDto; import com.backoffice.upjuyanolja.domain.coupon.entity.Coupon; import com.backoffice.upjuyanolja.domain.coupon.entity.CouponStatus; import com.backoffice.upjuyanolja.domain.coupon.entity.CouponType; import com.backoffice.upjuyanolja.domain.coupon.entity.DiscountType; -import com.backoffice.upjuyanolja.domain.coupon.exception.InvalidCouponInfoException; import com.backoffice.upjuyanolja.domain.coupon.repository.CouponRepository; import com.backoffice.upjuyanolja.domain.member.entity.Authority; import com.backoffice.upjuyanolja.domain.member.entity.Member; @@ -41,7 +32,6 @@ import jakarta.persistence.PersistenceContext; import java.time.LocalDate; import java.time.LocalTime; -import java.time.YearMonth; import java.util.ArrayList; import java.util.List; import org.junit.jupiter.api.BeforeEach; @@ -207,11 +197,9 @@ private Accommodation createAccommodation(Long accommodationId) { Accommodation accommodation = Accommodation.builder() .id(accommodationId) .name("그랜드 하얏트 제주") - .address(Address.builder() - .address("제주특별자치도 제주시 노형동 925") - .detailAddress("") - .zipCode("63082") - .build()) + .address("제주특별자치도 제주시 노형동 925") + .detailAddress("") + .zipCode("63082") .category(createCategory()) .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/service/CouponBackofficeServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/service/CouponBackofficeServiceTest.java index 5fe54126..bf3045ab 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/service/CouponBackofficeServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/service/CouponBackofficeServiceTest.java @@ -7,7 +7,6 @@ import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOwnership; -import com.backoffice.upjuyanolja.domain.accommodation.entity.Address; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.accommodation.exception.AccommodationNotFoundException; import com.backoffice.upjuyanolja.domain.coupon.dto.request.backoffice.CouponMakeRequest; @@ -25,7 +24,6 @@ import com.backoffice.upjuyanolja.domain.room.entity.RoomPrice; import com.backoffice.upjuyanolja.domain.room.entity.RoomStatus; import java.time.LocalTime; -import java.time.YearMonth; import java.util.ArrayList; import java.util.List; import org.junit.jupiter.api.BeforeEach; @@ -115,11 +113,9 @@ private Accommodation createAccommodation(long accommodationId) { Accommodation accommodation = Accommodation.builder() .id(accommodationId) .name("그랜드 하얏트 제주") - .address(Address.builder() - .address("제주특별자치도 제주시 노형동 925") - .detailAddress("") - .zipCode("63082") - .build()) + .address("제주특별자치도 제주시 노형동 925") + .detailAddress("") + .zipCode("63082") .category(category) .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/docs/ReservationControllerDocsTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/docs/ReservationControllerDocsTest.java index 0b4beb49..ea34edb9 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/docs/ReservationControllerDocsTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/docs/ReservationControllerDocsTest.java @@ -17,7 +17,6 @@ import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; -import com.backoffice.upjuyanolja.domain.accommodation.entity.Address; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.member.entity.Authority; import com.backoffice.upjuyanolja.domain.member.entity.Member; @@ -104,11 +103,9 @@ private static Room createRoom() { Accommodation accommodation = Accommodation.builder() .id(1L) .name("그랜드 하얏트 제주") - .address(Address.builder() - .address("제주특별자치도 제주시 노형동 925") - .detailAddress("") - .zipCode("63082") - .build()) + .address("제주특별자치도 제주시 노형동 925") + .detailAddress("") + .zipCode("63082") .category(category) .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/controller/ReservationControllerTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/controller/ReservationControllerTest.java index ae354ed2..650de5bd 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/controller/ReservationControllerTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/controller/ReservationControllerTest.java @@ -8,7 +8,6 @@ import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; -import com.backoffice.upjuyanolja.domain.accommodation.entity.Address; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.member.entity.Authority; import com.backoffice.upjuyanolja.domain.member.entity.Member; @@ -112,11 +111,9 @@ private static Room createRoom() { Accommodation accommodation = Accommodation.builder() .id(1L) .name("그랜드 하얏트 제주") - .address(Address.builder() - .address("제주특별자치도 제주시 노형동 925") - .detailAddress("") - .zipCode("63082") - .build()) + .address("제주특별자치도 제주시 노형동 925") + .detailAddress("") + .zipCode("63082") .category(category) .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/repository/ReservationRepositoryTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/repository/ReservationRepositoryTest.java index d9affc20..7be05e62 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/repository/ReservationRepositoryTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/repository/ReservationRepositoryTest.java @@ -5,7 +5,6 @@ import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; -import com.backoffice.upjuyanolja.domain.accommodation.entity.Address; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.CategoryRepository; @@ -112,11 +111,9 @@ private Room createRoom() { Accommodation accommodation = Accommodation.builder() .name("그랜드 하얏트 제주") - .address(Address.builder() - .address("제주특별자치도 제주시 노형동 925") - .detailAddress("") - .zipCode("63082") - .build()) + .address("제주특별자치도 제주시 노형동 925") + .detailAddress("") + .zipCode("63082") .category(category) .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationServiceTest.java index 27169c0a..0f377f10 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationServiceTest.java @@ -9,7 +9,6 @@ import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; -import com.backoffice.upjuyanolja.domain.accommodation.entity.Address; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.coupon.entity.Coupon; import com.backoffice.upjuyanolja.domain.coupon.entity.CouponRedeem; @@ -142,11 +141,9 @@ private static Accommodation createAccommodation() { Accommodation accommodation = Accommodation.builder() .id(1L) .name("그랜드 하얏트 제주") - .address(Address.builder() - .address("제주특별자치도 제주시 노형동 925") - .detailAddress("") - .zipCode("63082") - .build()) + .address("제주특별자치도 제주시 노형동 925") + .detailAddress("") + .zipCode("63082") .category(category) .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationStockServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationStockServiceTest.java index ff1c102c..cdba9217 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationStockServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationStockServiceTest.java @@ -4,7 +4,6 @@ import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; -import com.backoffice.upjuyanolja.domain.accommodation.entity.Address; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.CategoryRepository; @@ -100,11 +99,9 @@ private Room createRoom() { Accommodation accommodation = Accommodation.builder() .id(1L) .name("그랜드 하얏트 제주") - .address(Address.builder() - .address("제주특별자치도 제주시 노형동 925") - .detailAddress("") - .zipCode("63082") - .build()) + .address("제주특별자치도 제주시 노형동 925") + .detailAddress("") + .zipCode("63082") .category(category) .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/repository/RoomRepositoryTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/repository/RoomRepositoryTest.java index e8d96f46..4e110b80 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/repository/RoomRepositoryTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/repository/RoomRepositoryTest.java @@ -4,7 +4,6 @@ import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; -import com.backoffice.upjuyanolja.domain.accommodation.entity.Address; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.CategoryRepository; @@ -80,11 +79,9 @@ private Category saveCategory() { private Accommodation saveAccommodation() { return accommodationRepository.save(Accommodation.builder() .name("그랜드 하얏트 제주") - .address(Address.builder() - .address("제주특별자치도 제주시 노형동 925") - .detailAddress("") - .zipCode("63082") - .build()) + .address("제주특별자치도 제주시 노형동 925") + .detailAddress("") + .zipCode("63082") .category(saveCategory()) .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomCommandServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomCommandServiceTest.java index b8f970d6..c9078073 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomCommandServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomCommandServiceTest.java @@ -12,7 +12,6 @@ import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; -import com.backoffice.upjuyanolja.domain.accommodation.entity.Address; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationOwnershipRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationRepository; @@ -123,10 +122,8 @@ void _willSuccess() { Accommodation accommodation = Accommodation.builder() .name("그랜드 하얏트 제주") - .address(Address.builder() - .address("제주특별자치도 제주시 노형동 925") - .detailAddress("") - .build()) + .address("제주특별자치도 제주시 노형동 925") + .detailAddress("") .category(category) .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") @@ -285,10 +282,8 @@ void notOwner_willFail() { Accommodation accommodation = Accommodation.builder() .name("그랜드 하얏트 제주") - .address(Address.builder() - .address("제주특별자치도 제주시 노형동 925") - .detailAddress("") - .build()) + .address("제주특별자치도 제주시 노형동 925") + .detailAddress("") .category(category) .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") @@ -371,10 +366,8 @@ void _willSuccess() { Accommodation accommodation = Accommodation.builder() .name("그랜드 하얏트 제주") - .address(Address.builder() - .address("제주특별자치도 제주시 노형동 925") - .detailAddress("") - .build()) + .address("제주특별자치도 제주시 노형동 925") + .detailAddress("") .category(category) .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") @@ -509,10 +502,8 @@ void duplicatedRoomName_willFail() { Accommodation accommodation = Accommodation.builder() .name("그랜드 하얏트 제주") - .address(Address.builder() - .address("제주특별자치도 제주시 노형동 925") - .detailAddress("") - .build()) + .address("제주특별자치도 제주시 노형동 925") + .detailAddress("") .category(category) .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") @@ -597,10 +588,8 @@ void _willSuccess() { Accommodation accommodation = Accommodation.builder() .name("그랜드 하얏트 제주") - .address(Address.builder() - .address("제주특별자치도 제주시 노형동 925") - .detailAddress("") - .build()) + .address("제주특별자치도 제주시 노형동 925") + .detailAddress("") .category(category) .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") @@ -755,10 +744,8 @@ void _willSuccess() { Accommodation accommodation = Accommodation.builder() .name("그랜드 하얏트 제주") - .address(Address.builder() - .address("제주특별자치도 제주시 노형동 925") - .detailAddress("") - .build()) + .address("제주특별자치도 제주시 노형동 925") + .detailAddress("") .category(category) .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomQueryServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomQueryServiceTest.java index bcd957be..bd623a88 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomQueryServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomQueryServiceTest.java @@ -9,7 +9,6 @@ import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; -import com.backoffice.upjuyanolja.domain.accommodation.entity.Address; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationOwnershipRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationRepository; @@ -105,10 +104,8 @@ void _willSuccess() { Accommodation accommodation = Accommodation.builder() .name("그랜드 하얏트 제주") - .address(Address.builder() - .address("제주특별자치도 제주시 노형동 925") - .detailAddress("") - .build()) + .address("제주특별자치도 제주시 노형동 925") + .detailAddress("") .category(category) .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") @@ -327,10 +324,8 @@ void _willSuccess() { Accommodation accommodation = Accommodation.builder() .name("그랜드 하얏트 제주") - .address(Address.builder() - .address("제주특별자치도 제주시 노형동 925") - .detailAddress("") - .build()) + .address("제주특별자치도 제주시 노형동 925") + .detailAddress("") .category(category) .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") From c33045c9ceffca9db573b15ded39414628960dc0 Mon Sep 17 00:00:00 2001 From: HyunA Date: Fri, 2 Feb 2024 01:48:30 +0900 Subject: [PATCH 02/21] =?UTF-8?q?refactor:=20roomStock=20=EC=96=91?= =?UTF-8?q?=EB=B0=A9=ED=96=A5=20=EA=B4=80=EA=B3=84=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../upjuyanolja/domain/room/entity/Room.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/entity/Room.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/entity/Room.java index e7f69bba..c4ad07fc 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/entity/Room.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/entity/Room.java @@ -62,9 +62,6 @@ public class Room extends BaseTime { @Comment("객실 체크 아웃 시간") private LocalTime checkOutTime; - @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) - @Comment("객실 가격") - private RoomPrice price; @Column(nullable = false) @Comment("객실 개수") @@ -75,6 +72,10 @@ public class Room extends BaseTime { @Comment("객실 상태") private RoomStatus status; + @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) + @Comment("객실 가격") + private RoomPrice price; + @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) @Comment("객실 옵션 식별자") private RoomOption option; @@ -83,10 +84,6 @@ public class Room extends BaseTime { @Comment("객실 이미지 식별자") private List images = new ArrayList<>(); - @OneToMany(mappedBy = "room", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) - @Comment("객실 재고 식별자") - private List stocks = new ArrayList<>(); - @Builder public Room( @@ -101,8 +98,7 @@ public Room( RoomPrice price, RoomStatus status, RoomOption option, - List images, - List stocks + List images ) { this.id = id; this.accommodation = accommodation; @@ -116,7 +112,6 @@ public Room( this.status = status; this.option = option; this.images = images; - this.stocks = stocks; } public void updateRoom(RoomUpdate request) { From 19816fb1c4818a2b0c94eb6f636e2f8db1b189f7 Mon Sep 17 00:00:00 2001 From: HyunA Date: Fri, 2 Feb 2024 03:02:16 +0900 Subject: [PATCH 03/21] =?UTF-8?q?refactor:=20accommodation=EA=B3=BC=20acco?= =?UTF-8?q?mmodationOption=EC=9D=98=20=EC=9D=BC=EB=8C=80=EC=9D=BC=20?= =?UTF-8?q?=EC=9C=A0=EC=A7=80=20&=20=EC=99=B8=EB=9E=98=ED=82=A4=20?= =?UTF-8?q?=EA=B4=80=EA=B3=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/AccommodationOptionRequest.java | 11 +++- .../request/AccommodationRegisterRequest.java | 1 - .../response/AccommodationDetailResponse.java | 7 ++- .../response/AccommodationInfoResponse.java | 6 ++- .../accommodation/entity/Accommodation.java | 6 --- .../entity/AccommodationOption.java | 9 ++++ .../AccommodationOptionNotFoundException.java | 11 ++++ .../AccommodationOptionRepository.java | 4 ++ .../service/AccommodationCommandService.java | 52 ++++++++++++++----- .../service/AccommodationQueryService.java | 25 +++++++-- .../openapi/service/OpenApiService.java | 39 +++++++++----- .../global/exception/ErrorCode.java | 9 ++-- 12 files changed, 133 insertions(+), 47 deletions(-) create mode 100644 src/main/java/com/backoffice/upjuyanolja/domain/accommodation/exception/AccommodationOptionNotFoundException.java diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/request/AccommodationOptionRequest.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/request/AccommodationOptionRequest.java index 3f87b3af..bf85d6ed 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/request/AccommodationOptionRequest.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/request/AccommodationOptionRequest.java @@ -1,11 +1,16 @@ package com.backoffice.upjuyanolja.domain.accommodation.dto.request; +import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import jakarta.validation.constraints.NotNull; import lombok.Builder; @Builder public record AccommodationOptionRequest( + + @NotNull(message = "숙소 ID를 입력하세요.") + Long AccommodationId, + @NotNull(message = "객실 내 취사 여부를 입력하세요.") boolean cooking, @@ -34,8 +39,12 @@ public record AccommodationOptionRequest( boolean seminar ) { - public static AccommodationOption toEntity(AccommodationOptionRequest request) { + public static AccommodationOption toEntity( + AccommodationOptionRequest request, + Accommodation accommodation + ) { return AccommodationOption.builder() + .accommodation(accommodation) .cooking(request.cooking) .parking(request.parking) .pickup(request.pickup) diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/request/AccommodationRegisterRequest.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/request/AccommodationRegisterRequest.java index 3976b858..b000b5b3 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/request/AccommodationRegisterRequest.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/request/AccommodationRegisterRequest.java @@ -57,7 +57,6 @@ public static Accommodation toEntity( .description(request.description()) .thumbnail(request.thumbnail()) .images(new ArrayList<>()) - .option(AccommodationOptionRequest.toEntity(request.option())) .rooms(new ArrayList<>()) .build(); } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationDetailResponse.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationDetailResponse.java index 9fd990bb..0ea0c98f 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationDetailResponse.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationDetailResponse.java @@ -19,7 +19,8 @@ public record AccommodationDetailResponse( ) { public static AccommodationDetailResponse of( - Accommodation accommodation, String mainCoupon, List rooms + Accommodation accommodation, String mainCoupon, + AccommodationOptionResponse option, List rooms ) { return AccommodationDetailResponse.builder() .id(accommodation.getId()) @@ -36,9 +37,7 @@ public static AccommodationDetailResponse of( .map(image -> image.getUrl()) .toList() ) - .option( - AccommodationOptionResponse.of(accommodation.getOption()) - ) + .option(option) .rooms(rooms) .build(); } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationInfoResponse.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationInfoResponse.java index 415d4e07..a1f15e00 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationInfoResponse.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationInfoResponse.java @@ -18,7 +18,9 @@ public record AccommodationInfoResponse( List rooms ) { - public static AccommodationInfoResponse of(Accommodation accommodation) { + public static AccommodationInfoResponse of( + Accommodation accommodation, AccommodationOptionResponse option + ) { List rooms = new ArrayList<>(); accommodation.getRooms().forEach(room -> rooms.add(RoomInfoResponse.of(room))); return AccommodationInfoResponse.builder() @@ -30,7 +32,7 @@ public static AccommodationInfoResponse of(Accommodation accommodation) { + " " + accommodation.getDetailAddress()) .images(AccommodationImageResponse.of(accommodation.getImages())) - .option(AccommodationOptionResponse.of(accommodation.getOption())) + .option(option) .rooms(rooms) .build(); } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/entity/Accommodation.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/entity/Accommodation.java index 95e39641..31441197 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/entity/Accommodation.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/entity/Accommodation.java @@ -61,10 +61,6 @@ public class Accommodation extends BaseTime { @Comment("숙소 카테고리") private Category category; - @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) - @Comment("숙소 옵션 식별자") - private AccommodationOption option; - @OneToMany(mappedBy = "accommodation", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) private List images = new ArrayList<>(); @@ -81,7 +77,6 @@ public Accommodation( Category category, String description, String thumbnail, - AccommodationOption option, List images, List rooms ) { @@ -93,7 +88,6 @@ public Accommodation( this.category = category; this.description = description; this.thumbnail = thumbnail; - this.option = option; this.images = images; this.rooms = rooms; } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/entity/AccommodationOption.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/entity/AccommodationOption.java index 991d5477..85c65fca 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/entity/AccommodationOption.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/entity/AccommodationOption.java @@ -1,10 +1,13 @@ package com.backoffice.upjuyanolja.domain.accommodation.entity; +import jakarta.persistence.CascadeType; import jakarta.persistence.Column; import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; +import jakarta.persistence.OneToOne; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; @@ -21,6 +24,10 @@ public class AccommodationOption { @Comment("숙소 옵션 식별자") private Long id; + @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) + @Comment("숙소 식별자") + private Accommodation accommodation; + @Column(nullable = false) @Comment("객실 내 취사 여부") private boolean cooking; @@ -60,6 +67,7 @@ public class AccommodationOption { @Builder public AccommodationOption( Long id, + Accommodation accommodation, boolean cooking, boolean parking, boolean pickup, @@ -71,6 +79,7 @@ public AccommodationOption( boolean seminar ) { this.id = id; + this.accommodation = accommodation; this.cooking = cooking; this.parking = parking; this.pickup = pickup; diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/exception/AccommodationOptionNotFoundException.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/exception/AccommodationOptionNotFoundException.java new file mode 100644 index 00000000..2569619b --- /dev/null +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/exception/AccommodationOptionNotFoundException.java @@ -0,0 +1,11 @@ +package com.backoffice.upjuyanolja.domain.accommodation.exception; + +import com.backoffice.upjuyanolja.global.exception.ApplicationException; +import com.backoffice.upjuyanolja.global.exception.ErrorCode; + +public class AccommodationOptionNotFoundException extends ApplicationException { + + public AccommodationOptionNotFoundException() { + super(ErrorCode.ACCOMMODATION_OPTION_NOT_FOUND); + } +} diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/repository/AccommodationOptionRepository.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/repository/AccommodationOptionRepository.java index 5fdd5e68..6695d8a7 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/repository/AccommodationOptionRepository.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/repository/AccommodationOptionRepository.java @@ -1,8 +1,12 @@ package com.backoffice.upjuyanolja.domain.accommodation.repository; +import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; +import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; public interface AccommodationOptionRepository extends JpaRepository { + Optional findByAccommodation(Accommodation accommodation); + } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java index a8a72a46..85fc51c3 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java @@ -1,15 +1,19 @@ package com.backoffice.upjuyanolja.domain.accommodation.service; import com.backoffice.upjuyanolja.domain.accommodation.dto.request.AccommodationImageRequest; +import com.backoffice.upjuyanolja.domain.accommodation.dto.request.AccommodationOptionRequest; import com.backoffice.upjuyanolja.domain.accommodation.dto.request.AccommodationRegisterRequest; import com.backoffice.upjuyanolja.domain.accommodation.dto.response.AccommodationInfoResponse; +import com.backoffice.upjuyanolja.domain.accommodation.dto.response.AccommodationOptionResponse; import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOwnership; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.accommodation.exception.AccommodationImageNotExistsException; +import com.backoffice.upjuyanolja.domain.accommodation.exception.AccommodationNotFoundException; import com.backoffice.upjuyanolja.domain.accommodation.exception.WrongCategoryException; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationImageRepository; +import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationOptionRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationOwnershipRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.CategoryRepository; @@ -33,6 +37,7 @@ public class AccommodationCommandService implements AccommodationCommandUseCase private final MemberGetService memberGetService; private final AccommodationRepository accommodationRepository; + private final AccommodationOptionRepository accommodationOptionRepository; private final CategoryRepository categoryRepository; private final AccommodationOwnershipRepository accommodationOwnershipRepository; private final AccommodationImageRepository accommodationImageRepository; @@ -56,17 +61,6 @@ public AccommodationInfoResponse createAccommodation( .description(request.description()) .category(category) .thumbnail(request.thumbnail()) - .option(AccommodationOption.builder() - .cooking(request.option().cooking()) - .parking(request.option().parking()) - .pickup(request.option().pickup()) - .barbecue(request.option().barbecue()) - .fitness(request.option().fitness()) - .karaoke(request.option().karaoke()) - .sauna(request.option().sauna()) - .sports(request.option().sports()) - .seminar(request.option().seminar()) - .build()) .rooms(new ArrayList<>()) .images(new ArrayList<>()) .build()); @@ -84,8 +78,42 @@ public AccommodationInfoResponse createAccommodation( request.rooms().forEach( roomRegisterRequest -> roomCommandService.saveRoom(accommodation, roomRegisterRequest)); + AccommodationOptionResponse option = createAccommodationOption(request.option()); + em.refresh(accommodation); - return AccommodationInfoResponse.of(accommodation); + + return AccommodationInfoResponse.of(accommodation, option); + } + + public AccommodationOptionResponse createAccommodationOption( + AccommodationOptionRequest request + ) { + + Accommodation accommodation = getAccommodation(request.AccommodationId()); + + AccommodationOption accommodationOption = accommodationOptionRepository.save( + AccommodationOption.builder() + .accommodation(accommodation) + .cooking(request.cooking()) + .parking(request.parking()) + .pickup(request.pickup()) + .barbecue(request.barbecue()) + .fitness(request.fitness()) + .karaoke(request.karaoke()) + .sauna(request.sauna()) + .sports(request.sports()) + .seminar(request.seminar()) + .build() + ); + + em.refresh(accommodationOption); + return AccommodationOptionResponse.of(accommodationOption); + } + + + private Accommodation getAccommodation(Long accommodationId) { + return accommodationRepository.findById(accommodationId) + .orElseThrow(AccommodationNotFoundException::new); } private Category getCategory(String category) { diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationQueryService.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationQueryService.java index 6dea209a..26fb1d04 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationQueryService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationQueryService.java @@ -2,12 +2,16 @@ import com.backoffice.upjuyanolja.domain.accommodation.dto.response.AccommodationDetailResponse; import com.backoffice.upjuyanolja.domain.accommodation.dto.response.AccommodationNameResponse; +import com.backoffice.upjuyanolja.domain.accommodation.dto.response.AccommodationOptionResponse; import com.backoffice.upjuyanolja.domain.accommodation.dto.response.AccommodationOwnershipResponse; import com.backoffice.upjuyanolja.domain.accommodation.dto.response.AccommodationPageResponse; import com.backoffice.upjuyanolja.domain.accommodation.dto.response.AccommodationSummaryResponse; import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; +import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOwnership; import com.backoffice.upjuyanolja.domain.accommodation.exception.AccommodationNotFoundException; +import com.backoffice.upjuyanolja.domain.accommodation.exception.AccommodationOptionNotFoundException; +import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationOptionRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationOwnershipRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationRepository; import com.backoffice.upjuyanolja.domain.accommodation.service.usecase.AccommodationQueryUseCase; @@ -43,6 +47,7 @@ public class AccommodationQueryService implements AccommodationQueryUseCase { private final AccommodationRepository accommodationRepository; private final AccommodationOwnershipRepository accommodationOwnershipRepository; + private final AccommodationOptionRepository accommodationOptionRepository; private final MemberRepository memberRepository; private final CouponService couponService; private final RoomQueryService roomQueryService; @@ -97,8 +102,13 @@ public AccommodationDetailResponse findAccommodationWithRooms( accommodation.getRooms(), startDate, endDate ); - return AccommodationDetailResponse.of(accommodation, + AccommodationOption accommodationOption = + getAccommodationOptionByAccommodation(accommodation); + + return AccommodationDetailResponse.of( + accommodation, getMainCouponName(accommodationId), + AccommodationOptionResponse.of(accommodationOption), accommodation.getRooms().stream() .map(room -> RoomResponse.of( room, getDiscountPrice(room), @@ -141,6 +151,12 @@ public List getOwnershipByMember(Member member) { return accommodationOwnershipRepository.findAllByMember(member); } + @Transactional(readOnly = true) + public AccommodationOption getAccommodationOptionByAccommodation(Accommodation accommodation) { + return accommodationOptionRepository.findByAccommodation(accommodation) + .orElseThrow(AccommodationOptionNotFoundException::new); + } + private boolean checkCouponAvailability(Accommodation accommodation) { return !couponService.findCouponResponseInAccommodation(accommodation.getId()).isEmpty(); } @@ -165,9 +181,11 @@ private Optional getDiscountInfo(Long accommodationId) { for (Room room : rooms) { coupons = couponService.getCouponInRoom(room); responses.addAll( - couponService.getSortedDiscountTypeCouponResponseInRoom(room, coupons, DiscountType.FLAT)); + couponService.getSortedDiscountTypeCouponResponseInRoom(room, coupons, + DiscountType.FLAT)); responses.addAll( - couponService.getSortedDiscountTypeCouponResponseInRoom(room, coupons, DiscountType.RATE)); + couponService.getSortedDiscountTypeCouponResponseInRoom(room, coupons, + DiscountType.RATE)); } return responses.stream() @@ -179,7 +197,6 @@ private String getMainCouponName(Long accommodationId) { String flatName = couponService.getDiscountTypeMainRoomCouponName(rooms, DiscountType.FLAT); String rateName = couponService.getDiscountTypeMainRoomCouponName(rooms, DiscountType.RATE); - if (flatName.isEmpty() && rateName.isEmpty()) { return ""; } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/openapi/service/OpenApiService.java b/src/main/java/com/backoffice/upjuyanolja/domain/openapi/service/OpenApiService.java index 896982ce..3d40250f 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/openapi/service/OpenApiService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/openapi/service/OpenApiService.java @@ -7,6 +7,7 @@ import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.accommodation.exception.WrongCategoryException; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationImageRepository; +import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationOptionRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationOwnershipRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.CategoryRepository; @@ -66,6 +67,7 @@ public class OpenApiService { private final AccommodationRepository accommodationRepository; private final AccommodationImageRepository accommodationImageRepository; private final AccommodationOwnershipRepository accommodationOwnershipRepository; + private final AccommodationOptionRepository accommodationOptionRepository; private final CategoryRepository categoryRepository; private final RoomRepository roomRepository; private final RoomImageRepository roomImageRepository; @@ -236,17 +238,6 @@ private Accommodation saveAccommodation( JSONObject common, JSONObject intro ) throws JSONException { - AccommodationOption option = AccommodationOption.builder() - .cooking(intro.get("chkcooking").equals("가능")) - .parking(intro.get("parkinglodging").equals("가능")) - .pickup(intro.get("pickup").equals("가능")) - .barbecue(intro.get("barbecue").equals("1")) - .fitness(intro.get("fitness").equals("1")) - .karaoke(intro.get("karaoke").equals("1")) - .sports(intro.get("sports").equals("1")) - .seminar(intro.get("seminar").equals("1")) - .build(); - Category category = categoryRepository.findCategoryByNameAndIdGreaterThan( AccommodationType.getByCode(base.getString("cat3")).name(), 4L) .orElseThrow(WrongCategoryException::new); @@ -260,12 +251,34 @@ private Accommodation saveAccommodation( .description(common.getString("overview")) .thumbnail(base.getString("firstimage")) .images(new ArrayList<>()) - .option(option) .build(); - return accommodationRepository.save(accommodation); + Accommodation saveAccommodation = accommodationRepository.save(accommodation); + saveAccommodationOption(accommodation, intro); + + return saveAccommodation; + } + + private AccommodationOption saveAccommodationOption( + Accommodation accommodation, JSONObject intro + ) { + + AccommodationOption option = AccommodationOption.builder() + .accommodation(accommodation) + .cooking(intro.get("chkcooking").equals("가능")) + .parking(intro.get("parkinglodging").equals("가능")) + .pickup(intro.get("pickup").equals("가능")) + .barbecue(intro.get("barbecue").equals("1")) + .fitness(intro.get("fitness").equals("1")) + .karaoke(intro.get("karaoke").equals("1")) + .sports(intro.get("sports").equals("1")) + .seminar(intro.get("seminar").equals("1")) + .build(); + + return accommodationOptionRepository.save(option); } + private void saveOwnership(Accommodation accommodation, Member member) { accommodationOwnershipRepository.save(AccommodationOwnership.builder() .accommodation(accommodation) diff --git a/src/main/java/com/backoffice/upjuyanolja/global/exception/ErrorCode.java b/src/main/java/com/backoffice/upjuyanolja/global/exception/ErrorCode.java index 1bef081e..1c382446 100644 --- a/src/main/java/com/backoffice/upjuyanolja/global/exception/ErrorCode.java +++ b/src/main/java/com/backoffice/upjuyanolja/global/exception/ErrorCode.java @@ -25,10 +25,11 @@ public enum ErrorCode { // Accommodation ACCOMMODATION_NOT_FOUND(HttpStatus.NOT_FOUND, 2000, "숙소 정보를 찾을 수 없습니다."), - RESERVATION_NOT_POSSIBLE(HttpStatus.BAD_REQUEST, 2001, "예약이 불가능한 방입니다."), - WRONG_CATEGORY(HttpStatus.BAD_REQUEST, 2002, "알맞지 않은 카테고리입니다."), - ACCOMMODATION_IMAGE_NOT_EXISTS(HttpStatus.BAD_REQUEST, 2003, "숙소 이미지를 1개 이상 등록해야 합니다."), - FAILED_SAVE_IMAGE(HttpStatus.BAD_REQUEST, 2004, "이미지 저장에 실패했습니다."), + ACCOMMODATION_OPTION_NOT_FOUND(HttpStatus.NOT_FOUND, 2001, "숙소 옵션 정보를 찾을 수 없습니다."), + RESERVATION_NOT_POSSIBLE(HttpStatus.BAD_REQUEST, 2002, "예약이 불가능한 방입니다."), + WRONG_CATEGORY(HttpStatus.BAD_REQUEST, 2003, "알맞지 않은 카테고리입니다."), + ACCOMMODATION_IMAGE_NOT_EXISTS(HttpStatus.BAD_REQUEST, 2004, "숙소 이미지를 1개 이상 등록해야 합니다."), + FAILED_SAVE_IMAGE(HttpStatus.BAD_REQUEST, 2005, "이미지 저장에 실패했습니다."), // Room ROOM_NOT_FOUND(HttpStatus.NOT_FOUND, 3000, "객실 정보를 찾을 수 없습니다."), From 563eb6662262cb1dbe6b746da6d1a41afcac777d Mon Sep 17 00:00:00 2001 From: HyunA Date: Fri, 2 Feb 2024 20:12:57 +0900 Subject: [PATCH 04/21] =?UTF-8?q?test:=20accommodation=EA=B3=BC=20accommod?= =?UTF-8?q?ationOption=EC=9D=98=20=EA=B4=80=EA=B3=84=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=EC=97=90=20=EB=94=B0=EB=A5=B8=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95=20=EB=B0=8F=20=EB=B9=8C?= =?UTF-8?q?=EB=93=9C=20=ED=99=95=EC=9D=B8=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...mmodationBackofficeControllerDocsTest.java | 387 +++++++++--------- .../AccommodationOwnershipRepositoryTest.java | 36 +- .../AccommodationCommandServiceTest.java | 34 +- .../AccommodationQueryServiceTest.java | 22 - .../CouponBackofficeControllerDocsTest.java | 4 - .../CouponBackofficeControllerTest.java | 4 - .../unit/repository/CouponRepositoryTest.java | 4 - .../service/CouponBackofficeServiceTest.java | 11 - .../docs/ReservationControllerDocsTest.java | 11 - .../controller/ReservationControllerTest.java | 11 - .../repository/ReservationRepositoryTest.java | 11 - .../unit/service/ReservationServiceTest.java | 11 - .../service/ReservationStockServiceTest.java | 11 - .../unit/repository/RoomRepositoryTest.java | 11 - .../unit/service/RoomCommandServiceTest.java | 66 --- .../unit/service/RoomQueryServiceTest.java | 22 - 16 files changed, 233 insertions(+), 423 deletions(-) diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/docs/AccommodationBackofficeControllerDocsTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/docs/AccommodationBackofficeControllerDocsTest.java index 1a5a23b2..996d6936 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/docs/AccommodationBackofficeControllerDocsTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/docs/AccommodationBackofficeControllerDocsTest.java @@ -164,198 +164,203 @@ void registerAccommodation() throws Exception { .content(objectMapper.writeValueAsString(request)) .contentType(MediaType.APPLICATION_JSON)) .andDo(restDoc.document( - requestFields( - fieldWithPath("name").description("숙소 이름") - .attributes(key("constraints") - .value(accommodationRegisterDescriptions.descriptionsForProperty( - "name"))), - fieldWithPath("address").description("숙소 주소") - .attributes(key("constraints") - .value(accommodationRegisterDescriptions.descriptionsForProperty( - "address"))), - fieldWithPath("detailAddress").description("숙소 상세 주소") - .attributes(key("constraints") - .value(accommodationRegisterDescriptions.descriptionsForProperty( - "detailAddress"))), - fieldWithPath("zipCode").description("숙소 우편번호") - .attributes(key("constraints") - .value(accommodationRegisterDescriptions.descriptionsForProperty( - "zipCode"))), - fieldWithPath("description").description("숙소 설명") - .attributes(key("constraints") - .value(accommodationRegisterDescriptions.descriptionsForProperty( - "description"))), - fieldWithPath("category").description("숙소 유형") - .attributes(key("constraints") - .value(accommodationRegisterDescriptions.descriptionsForProperty( - "category"))), - fieldWithPath("thumbnail").description("숙소 대표 이미지") - .attributes(key("constraints") - .value(accommodationRegisterDescriptions.descriptionsForProperty( - "thumbnail"))), - fieldWithPath("images").description("숙소 이미지"), - fieldWithPath("images[].url").description("숙소 이미지 URL") - .attributes(key("constraints") - .value(accommodationImageRequestDescriptions.descriptionsForProperty( - "url"))), - fieldWithPath("option").description("숙소 옵션"), - fieldWithPath("option.cooking").description("객실 내 취사 여부") - .attributes(key("constraints") - .value(accommodationOptionRequestDescriptions.descriptionsForProperty( - "cooking"))), - fieldWithPath("option.parking").description("주차 시설 여부") - .attributes(key("constraints") - .value(accommodationOptionRequestDescriptions.descriptionsForProperty( - "parking"))), - fieldWithPath("option.pickup").description("픽업 서비스 여부") - .attributes(key("constraints") - .value(accommodationOptionRequestDescriptions.descriptionsForProperty( - "pickup"))), - fieldWithPath("option.barbecue").description("바베큐장 여부") - .attributes(key("constraints") - .value(accommodationOptionRequestDescriptions.descriptionsForProperty( - "barbecue"))), - fieldWithPath("option.fitness").description("피트니스 센터 여부") - .attributes(key("constraints") - .value(accommodationOptionRequestDescriptions.descriptionsForProperty( - "fitness"))), - fieldWithPath("option.karaoke").description("노래방 여부") - .attributes(key("constraints") - .value(accommodationOptionRequestDescriptions.descriptionsForProperty( - "karaoke"))), - fieldWithPath("option.sauna").description("사우나실 여부") - .attributes(key("constraints") - .value(accommodationOptionRequestDescriptions.descriptionsForProperty( - "sauna"))), - fieldWithPath("option.sports").description("스포츠 시설 여부") - .attributes(key("constraints") - .value(accommodationOptionRequestDescriptions.descriptionsForProperty( - "sports"))), - fieldWithPath("option.seminar").description("세미나실 여부") - .attributes(key("constraints") - .value(accommodationOptionRequestDescriptions.descriptionsForProperty( - "seminar"))), - fieldWithPath("rooms").description("객실 배열"), - fieldWithPath("rooms[].name").description("객실 이름") - .attributes(key("constraints") - .value(roomRegisterRequestDescriptions.descriptionsForProperty( - "name"))), - fieldWithPath("rooms[].price").description("객실 가격") - .attributes(key("constraints") - .value(roomRegisterRequestDescriptions.descriptionsForProperty( - "price"))), - fieldWithPath("rooms[].defaultCapacity").description("객실 기본 인원") - .attributes(key("constraints") - .value(roomRegisterRequestDescriptions.descriptionsForProperty( - "defaultCapacity"))), - fieldWithPath("rooms[].maxCapacity").description("객실 최대 인원") - .attributes(key("constraints") - .value(roomRegisterRequestDescriptions.descriptionsForProperty( - "maxCapacity"))), - fieldWithPath("rooms[].checkInTime").description("객실 체크인 시간") - .attributes(key("constraints") - .value(roomRegisterRequestDescriptions.descriptionsForProperty( - "checkInTime"))), - fieldWithPath("rooms[].checkOutTime").description("객실 체크아웃 시간") - .attributes(key("constraints") - .value(roomRegisterRequestDescriptions.descriptionsForProperty( - "checkOutTime"))), - fieldWithPath("rooms[].amount").description("객실 개수") - .attributes(key("constraints") - .value(roomRegisterRequestDescriptions.descriptionsForProperty( - "amount"))), - fieldWithPath("rooms[].images").description("객실 이미지 배열"), - fieldWithPath("rooms[].images[].url").description("객실 이미지 URL") - .attributes(key("constraints") - .value(roomImageRequestDescriptions.descriptionsForProperty( - "url"))), - fieldWithPath("rooms[].option").description("객실 옵션"), - fieldWithPath("rooms[].option.airCondition").description("객실 에어컨 여부") - .attributes(key("constraints") - .value(roomOptionRequestDescriptions.descriptionsForProperty( - "airCondition"))), - fieldWithPath("rooms[].option.tv").description("객실 TV 여부") - .attributes(key("constraints") - .value(roomOptionRequestDescriptions.descriptionsForProperty( - "tv"))), - fieldWithPath("rooms[].option.internet").description("객실 인터넷 여부") - .attributes(key("constraints") - .value(roomOptionRequestDescriptions.descriptionsForProperty( - "internet"))) - ), - responseFields( - fieldWithPath("accommodationId").type(JsonFieldType.NUMBER) - .description("숙소 식별자"), - fieldWithPath("name").type(JsonFieldType.STRING) - .description("숙소 이름"), - fieldWithPath("category").type(JsonFieldType.STRING) - .description("숙소 유형"), - fieldWithPath("address").type(JsonFieldType.STRING) - .description("숙소 주소"), - fieldWithPath("description").type(JsonFieldType.STRING) - .description("숙소 설명"), - fieldWithPath("images").type(JsonFieldType.ARRAY) - .description("숙소 이미지 배열"), - fieldWithPath("images[].id").type(JsonFieldType.NUMBER) - .description("숙소 이미지 식별자"), - fieldWithPath("images[].url").type(JsonFieldType.STRING) - .description("숙소 이미지 URL"), - fieldWithPath("option").type(JsonFieldType.OBJECT) - .description("숙소 옵션"), - fieldWithPath("option.cooking").type(JsonFieldType.BOOLEAN) - .description("객실 내 취사 여부"), - fieldWithPath("option.parking").type(JsonFieldType.BOOLEAN) - .description("주차 시설 여부"), - fieldWithPath("option.pickup").type(JsonFieldType.BOOLEAN) - .description("픽업 여부"), - fieldWithPath("option.barbecue").type(JsonFieldType.BOOLEAN) - .description("바베큐 여부"), - fieldWithPath("option.fitness").type(JsonFieldType.BOOLEAN) - .description("피트니스 센터 여부"), - fieldWithPath("option.karaoke").type(JsonFieldType.BOOLEAN) - .description("노래방 여부"), - fieldWithPath("option.sauna").type(JsonFieldType.BOOLEAN) - .description("사우나 여부"), - fieldWithPath("option.sports").type(JsonFieldType.BOOLEAN) - .description("스포츠 시설 여부"), - fieldWithPath("option.seminar").type(JsonFieldType.BOOLEAN) - .description("세미나실 여부"), - fieldWithPath("rooms").type(JsonFieldType.ARRAY) - .description("객실 배열"), - fieldWithPath("rooms[].id").type(JsonFieldType.NUMBER) - .description("객실 식별자"), - fieldWithPath("rooms[].name").type(JsonFieldType.STRING) - .description("객실 이름"), - fieldWithPath("rooms[].defaultCapacity").type(JsonFieldType.NUMBER) - .description("객실 기본 인원"), - fieldWithPath("rooms[].maxCapacity").type(JsonFieldType.NUMBER) - .description("객실 최대 인원"), - fieldWithPath("rooms[].checkInTime").type(JsonFieldType.STRING) - .description("객실 체크인 시간"), - fieldWithPath("rooms[].checkOutTime").type(JsonFieldType.STRING) - .description("객실 체크아웃 시간"), - fieldWithPath("rooms[].price").type(JsonFieldType.NUMBER) - .description("객실 가격"), - fieldWithPath("rooms[].amount").type(JsonFieldType.NUMBER) - .description("객실 개수"), - fieldWithPath("rooms[].status").type(JsonFieldType.STRING) - .description("객실 상태"), - fieldWithPath("rooms[].images").type(JsonFieldType.ARRAY) - .description("객실 이미지 배열"), - fieldWithPath("rooms[].images[].id").type(JsonFieldType.NUMBER) - .description("객실 이미지 식별자"), - fieldWithPath("rooms[].images[].url").type(JsonFieldType.STRING) - .description("객실 이미지 URL"), - fieldWithPath("rooms[].option").type(JsonFieldType.OBJECT) - .description("객실 옵션"), - fieldWithPath("rooms[].option.airCondition").type(JsonFieldType.BOOLEAN) - .description("에어컨 여부"), - fieldWithPath("rooms[].option.tv").type(JsonFieldType.BOOLEAN) - .description("TV 여부"), - fieldWithPath("rooms[].option.internet").type(JsonFieldType.BOOLEAN) - .description("인터넷 여부") + requestFields( + fieldWithPath("name").description("숙소 이름") + .attributes(key("constraints") + .value(accommodationRegisterDescriptions.descriptionsForProperty( + "name"))), + fieldWithPath("address").description("숙소 주소") + .attributes(key("constraints") + .value(accommodationRegisterDescriptions.descriptionsForProperty( + "address"))), + fieldWithPath("detailAddress").description("숙소 상세 주소") + .attributes(key("constraints") + .value(accommodationRegisterDescriptions.descriptionsForProperty( + "detailAddress"))), + fieldWithPath("zipCode").description("숙소 우편번호") + .attributes(key("constraints") + .value(accommodationRegisterDescriptions.descriptionsForProperty( + "zipCode"))), + fieldWithPath("description").description("숙소 설명") + .attributes(key("constraints") + .value(accommodationRegisterDescriptions.descriptionsForProperty( + "description"))), + fieldWithPath("category").description("숙소 유형") + .attributes(key("constraints") + .value(accommodationRegisterDescriptions.descriptionsForProperty( + "category"))), + fieldWithPath("thumbnail").description("숙소 대표 이미지") + .attributes(key("constraints") + .value(accommodationRegisterDescriptions.descriptionsForProperty( + "thumbnail"))), + fieldWithPath("images").description("숙소 이미지"), + fieldWithPath("images[].url").description("숙소 이미지 URL") + .attributes(key("constraints") + .value(accommodationImageRequestDescriptions.descriptionsForProperty( + "url"))), + fieldWithPath("option").description("숙소 옵션"), + fieldWithPath("option.AccommodationId").description("숙소 식별자") + .attributes(key("constraints") + .value(accommodationOptionRequestDescriptions.descriptionsForProperty( + "AccommodationId"))), + fieldWithPath("option.cooking").description("객실 내 취사 여부") + .attributes(key("constraints") + .value(accommodationOptionRequestDescriptions.descriptionsForProperty( + "cooking"))), + fieldWithPath("option.parking").description("주차 시설 여부") + .attributes(key("constraints") + .value(accommodationOptionRequestDescriptions.descriptionsForProperty( + "parking"))), + fieldWithPath("option.pickup").description("픽업 서비스 여부") + .attributes(key("constraints") + .value(accommodationOptionRequestDescriptions.descriptionsForProperty( + "pickup"))), + fieldWithPath("option.barbecue").description("바베큐장 여부") + .attributes(key("constraints") + .value(accommodationOptionRequestDescriptions.descriptionsForProperty( + "barbecue"))), + fieldWithPath("option.fitness").description("피트니스 센터 여부") + .attributes(key("constraints") + .value(accommodationOptionRequestDescriptions.descriptionsForProperty( + "fitness"))), + fieldWithPath("option.karaoke").description("노래방 여부") + .attributes(key("constraints") + .value(accommodationOptionRequestDescriptions.descriptionsForProperty( + "karaoke"))), + fieldWithPath("option.sauna").description("사우나실 여부") + .attributes(key("constraints") + .value(accommodationOptionRequestDescriptions.descriptionsForProperty( + "sauna"))), + fieldWithPath("option.sports").description("스포츠 시설 여부") + .attributes(key("constraints") + .value(accommodationOptionRequestDescriptions.descriptionsForProperty( + "sports"))), + fieldWithPath("option.seminar").description("세미나실 여부") + .attributes(key("constraints") + .value(accommodationOptionRequestDescriptions.descriptionsForProperty( + "seminar"))), + fieldWithPath("rooms").description("객실 배열"), + fieldWithPath("rooms[].name").description("객실 이름") + .attributes(key("constraints") + .value(roomRegisterRequestDescriptions.descriptionsForProperty( + "name"))), + fieldWithPath("rooms[].price").description("객실 가격") + .attributes(key("constraints") + .value(roomRegisterRequestDescriptions.descriptionsForProperty( + "price"))), + fieldWithPath("rooms[].defaultCapacity").description("객실 기본 인원") + .attributes(key("constraints") + .value(roomRegisterRequestDescriptions.descriptionsForProperty( + "defaultCapacity"))), + fieldWithPath("rooms[].maxCapacity").description("객실 최대 인원") + .attributes(key("constraints") + .value(roomRegisterRequestDescriptions.descriptionsForProperty( + "maxCapacity"))), + fieldWithPath("rooms[].checkInTime").description("객실 체크인 시간") + .attributes(key("constraints") + .value(roomRegisterRequestDescriptions.descriptionsForProperty( + "checkInTime"))), + fieldWithPath("rooms[].checkOutTime").description("객실 체크아웃 시간") + .attributes(key("constraints") + .value(roomRegisterRequestDescriptions.descriptionsForProperty( + "checkOutTime"))), + fieldWithPath("rooms[].amount").description("객실 개수") + .attributes(key("constraints") + .value(roomRegisterRequestDescriptions.descriptionsForProperty( + "amount"))), + fieldWithPath("rooms[].images").description("객실 이미지 배열"), + fieldWithPath("rooms[].images[].url").description("객실 이미지 URL") + .attributes(key("constraints") + .value(roomImageRequestDescriptions.descriptionsForProperty( + "url"))), + fieldWithPath("rooms[].option").description("객실 옵션"), + fieldWithPath("rooms[].option.airCondition").description("객실 에어컨 여부") + .attributes(key("constraints") + .value(roomOptionRequestDescriptions.descriptionsForProperty( + "airCondition"))), + fieldWithPath("rooms[].option.tv").description("객실 TV 여부") + .attributes(key("constraints") + .value(roomOptionRequestDescriptions.descriptionsForProperty( + "tv"))), + fieldWithPath("rooms[].option.internet").description("객실 인터넷 여부") + .attributes(key("constraints") + .value(roomOptionRequestDescriptions.descriptionsForProperty( + "internet"))) + ), + responseFields( + fieldWithPath("accommodationId").type(JsonFieldType.NUMBER) + .description("숙소 식별자"), + fieldWithPath("name").type(JsonFieldType.STRING) + .description("숙소 이름"), + fieldWithPath("category").type(JsonFieldType.STRING) + .description("숙소 유형"), + fieldWithPath("address").type(JsonFieldType.STRING) + .description("숙소 주소"), + fieldWithPath("description").type(JsonFieldType.STRING) + .description("숙소 설명"), + fieldWithPath("images").type(JsonFieldType.ARRAY) + .description("숙소 이미지 배열"), + fieldWithPath("images[].id").type(JsonFieldType.NUMBER) + .description("숙소 이미지 식별자"), + fieldWithPath("images[].url").type(JsonFieldType.STRING) + .description("숙소 이미지 URL"), + fieldWithPath("option").type(JsonFieldType.OBJECT) + .description("숙소 옵션"), + fieldWithPath("option.cooking").type(JsonFieldType.BOOLEAN) + .description("객실 내 취사 여부"), + fieldWithPath("option.parking").type(JsonFieldType.BOOLEAN) + .description("주차 시설 여부"), + fieldWithPath("option.pickup").type(JsonFieldType.BOOLEAN) + .description("픽업 여부"), + fieldWithPath("option.barbecue").type(JsonFieldType.BOOLEAN) + .description("바베큐 여부"), + fieldWithPath("option.fitness").type(JsonFieldType.BOOLEAN) + .description("피트니스 센터 여부"), + fieldWithPath("option.karaoke").type(JsonFieldType.BOOLEAN) + .description("노래방 여부"), + fieldWithPath("option.sauna").type(JsonFieldType.BOOLEAN) + .description("사우나 여부"), + fieldWithPath("option.sports").type(JsonFieldType.BOOLEAN) + .description("스포츠 시설 여부"), + fieldWithPath("option.seminar").type(JsonFieldType.BOOLEAN) + .description("세미나실 여부"), + fieldWithPath("rooms").type(JsonFieldType.ARRAY) + .description("객실 배열"), + fieldWithPath("rooms[].id").type(JsonFieldType.NUMBER) + .description("객실 식별자"), + fieldWithPath("rooms[].name").type(JsonFieldType.STRING) + .description("객실 이름"), + fieldWithPath("rooms[].defaultCapacity").type(JsonFieldType.NUMBER) + .description("객실 기본 인원"), + fieldWithPath("rooms[].maxCapacity").type(JsonFieldType.NUMBER) + .description("객실 최대 인원"), + fieldWithPath("rooms[].checkInTime").type(JsonFieldType.STRING) + .description("객실 체크인 시간"), + fieldWithPath("rooms[].checkOutTime").type(JsonFieldType.STRING) + .description("객실 체크아웃 시간"), + fieldWithPath("rooms[].price").type(JsonFieldType.NUMBER) + .description("객실 가격"), + fieldWithPath("rooms[].amount").type(JsonFieldType.NUMBER) + .description("객실 개수"), + fieldWithPath("rooms[].status").type(JsonFieldType.STRING) + .description("객실 상태"), + fieldWithPath("rooms[].images").type(JsonFieldType.ARRAY) + .description("객실 이미지 배열"), + fieldWithPath("rooms[].images[].id").type(JsonFieldType.NUMBER) + .description("객실 이미지 식별자"), + fieldWithPath("rooms[].images[].url").type(JsonFieldType.STRING) + .description("객실 이미지 URL"), + fieldWithPath("rooms[].option").type(JsonFieldType.OBJECT) + .description("객실 옵션"), + fieldWithPath("rooms[].option.airCondition").type(JsonFieldType.BOOLEAN) + .description("에어컨 여부"), + fieldWithPath("rooms[].option.tv").type(JsonFieldType.BOOLEAN) + .description("TV 여부"), + fieldWithPath("rooms[].option.internet").type(JsonFieldType.BOOLEAN) + .description("인터넷 여부") + ) ) - )); + ); verify(accommodationCommandService, times(1)) .createAccommodation(any(Long.TYPE), any(AccommodationRegisterRequest.class)); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/repository/AccommodationOwnershipRepositoryTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/repository/AccommodationOwnershipRepositoryTest.java index 3d1f362a..73470997 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/repository/AccommodationOwnershipRepositoryTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/repository/AccommodationOwnershipRepositoryTest.java @@ -6,6 +6,7 @@ import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOwnership; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; +import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationOptionRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationOwnershipRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.CategoryRepository; @@ -47,6 +48,9 @@ public class AccommodationOwnershipRepositoryTest { @Autowired private AccommodationRepository accommodationRepository; + @Autowired + private AccommodationOptionRepository accommodationOptionRepository; + @Autowired private CategoryRepository categoryRepository; @@ -64,11 +68,13 @@ public void reset() { categoryRepository.deleteAll(); accommodationRepository.deleteAll(); accommodationOwnershipRepository.deleteAll(); + accommodationOptionRepository.deleteAll(); memberRepository.deleteAll(); entityManager.createNativeQuery("TRUNCATE TABLE room").executeUpdate(); entityManager.createNativeQuery("TRUNCATE TABLE category").executeUpdate(); entityManager.createNativeQuery("TRUNCATE TABLE accommodation").executeUpdate(); entityManager.createNativeQuery("TRUNCATE TABLE accommodation_ownership").executeUpdate(); + entityManager.createNativeQuery("TRUNCATE TABLE accommodation_option").executeUpdate(); entityManager.createNativeQuery("TRUNCATE TABLE member").executeUpdate(); entityManager .createNativeQuery("ALTER TABLE room ALTER COLUMN `id` RESTART WITH 1") @@ -83,6 +89,10 @@ public void reset() { .createNativeQuery( "ALTER TABLE accommodation_ownership ALTER COLUMN `id` RESTART WITH 1") .executeUpdate(); + entityManager + .createNativeQuery( + "ALTER TABLE accommodation_option ALTER COLUMN `id` RESTART WITH 1") + .executeUpdate(); entityManager .createNativeQuery("ALTER TABLE member ALTER COLUMN `id` RESTART WITH 1") .executeUpdate(); @@ -116,22 +126,26 @@ private Accommodation saveAccommodation() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .option(AccommodationOption.builder() - .cooking(false) - .parking(true) - .pickup(false) - .barbecue(false) - .fitness(true) - .karaoke(false) - .sauna(false) - .sports(true) - .seminar(true) - .build()) .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build()); } + private AccommodationOption saveAccommodationOption(Accommodation accommodation) { + return accommodationOptionRepository.save(AccommodationOption.builder() + .accommodation(accommodation) + .cooking(false) + .parking(true) + .pickup(false) + .barbecue(false) + .fitness(true) + .karaoke(false) + .sauna(false) + .sports(true) + .seminar(true) + .build()); + } + private Member saveMember() { return memberRepository.save(Member.builder() .email("test@mail.com") diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationCommandServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationCommandServiceTest.java index 56dc8c21..f494f527 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationCommandServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationCommandServiceTest.java @@ -148,20 +148,21 @@ void _willSuccess() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .option(AccommodationOption.builder() - .cooking(false) - .parking(true) - .pickup(false) - .barbecue(false) - .fitness(true) - .karaoke(false) - .sauna(false) - .sports(true) - .seminar(true) - .build()) .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); + AccommodationOption accommodationOption = AccommodationOption.builder() + .id(1L) + .cooking(false) + .parking(true) + .pickup(false) + .barbecue(false) + .fitness(true) + .karaoke(false) + .sauna(false) + .sports(true) + .seminar(true) + .build(); AccommodationImage accommodationImage = AccommodationImage.builder() .id(1L) .accommodation(accommodation) @@ -224,17 +225,6 @@ void _willSuccess() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .option(AccommodationOption.builder() - .cooking(false) - .parking(true) - .pickup(false) - .barbecue(false) - .fitness(true) - .karaoke(false) - .sauna(false) - .sports(true) - .seminar(true) - .build()) .images(List.of(accommodationImage)) .rooms(List.of(room)) .build(); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationQueryServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationQueryServiceTest.java index 09693ce1..15cb5f06 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationQueryServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationQueryServiceTest.java @@ -92,17 +92,6 @@ void _willSuccess() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .option(AccommodationOption.builder() - .cooking(false) - .parking(true) - .pickup(false) - .barbecue(false) - .fitness(true) - .karaoke(false) - .sauna(false) - .sports(true) - .seminar(true) - .build()) .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); @@ -143,17 +132,6 @@ void _willSuccess() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .option(AccommodationOption.builder() - .cooking(false) - .parking(true) - .pickup(false) - .barbecue(false) - .fitness(true) - .karaoke(false) - .sauna(false) - .sports(true) - .seminar(true) - .build()) .images(List.of(accommodationImage)) .rooms(List.of(room)) .build(); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/docs/CouponBackofficeControllerDocsTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/docs/CouponBackofficeControllerDocsTest.java index b4bea193..d9e4ca5e 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/docs/CouponBackofficeControllerDocsTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/docs/CouponBackofficeControllerDocsTest.java @@ -813,10 +813,6 @@ private Accommodation createAccommodation(Long accommodationId) { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .option(AccommodationOption.builder() - .cooking(false).parking(true).pickup(false).barbecue(false).fitness(true) - .karaoke(false).sauna(false).sports(true).seminar(true) - .build()) .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/controller/CouponBackofficeControllerTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/controller/CouponBackofficeControllerTest.java index 485608a9..2de3c17b 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/controller/CouponBackofficeControllerTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/controller/CouponBackofficeControllerTest.java @@ -643,10 +643,6 @@ private Accommodation createAccommodation(Long accommodationId) { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .option(AccommodationOption.builder() - .cooking(false).parking(true).pickup(false).barbecue(false).fitness(true) - .karaoke(false).sauna(false).sports(true).seminar(true) - .build()) .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/repository/CouponRepositoryTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/repository/CouponRepositoryTest.java index 0476b15f..bfc37ec4 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/repository/CouponRepositoryTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/repository/CouponRepositoryTest.java @@ -204,10 +204,6 @@ private Accommodation createAccommodation(Long accommodationId) { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .option(AccommodationOption.builder() - .cooking(false).parking(true).pickup(false).barbecue(false).fitness(true) - .karaoke(false).sauna(false).sports(true).seminar(true) - .build()) .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/service/CouponBackofficeServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/service/CouponBackofficeServiceTest.java index bf3045ab..096f22ea 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/service/CouponBackofficeServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/service/CouponBackofficeServiceTest.java @@ -120,17 +120,6 @@ private Accommodation createAccommodation(long accommodationId) { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .option(AccommodationOption.builder() - .cooking(false) - .parking(true) - .pickup(false) - .barbecue(false) - .fitness(true) - .karaoke(false) - .sauna(false) - .sports(true) - .seminar(true) - .build()) .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/docs/ReservationControllerDocsTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/docs/ReservationControllerDocsTest.java index ea34edb9..2b199e14 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/docs/ReservationControllerDocsTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/docs/ReservationControllerDocsTest.java @@ -110,17 +110,6 @@ private static Room createRoom() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .option(AccommodationOption.builder() - .cooking(false) - .parking(true) - .pickup(false) - .barbecue(false) - .fitness(true) - .karaoke(false) - .sauna(false) - .sports(true) - .seminar(true) - .build()) .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/controller/ReservationControllerTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/controller/ReservationControllerTest.java index 650de5bd..f158ed13 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/controller/ReservationControllerTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/controller/ReservationControllerTest.java @@ -118,17 +118,6 @@ private static Room createRoom() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .option(AccommodationOption.builder() - .cooking(false) - .parking(true) - .pickup(false) - .barbecue(false) - .fitness(true) - .karaoke(false) - .sauna(false) - .sports(true) - .seminar(true) - .build()) .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/repository/ReservationRepositoryTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/repository/ReservationRepositoryTest.java index 7be05e62..1d785f04 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/repository/ReservationRepositoryTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/repository/ReservationRepositoryTest.java @@ -118,17 +118,6 @@ private Room createRoom() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .option(AccommodationOption.builder() - .cooking(false) - .parking(true) - .pickup(false) - .barbecue(false) - .fitness(true) - .karaoke(false) - .sauna(false) - .sports(true) - .seminar(true) - .build()) .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationServiceTest.java index 0f377f10..fef41f70 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationServiceTest.java @@ -148,17 +148,6 @@ private static Accommodation createAccommodation() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .option(AccommodationOption.builder() - .cooking(false) - .parking(true) - .pickup(false) - .barbecue(false) - .fitness(true) - .karaoke(false) - .sauna(false) - .sports(true) - .seminar(true) - .build()) .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationStockServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationStockServiceTest.java index cdba9217..7d64b50f 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationStockServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationStockServiceTest.java @@ -106,17 +106,6 @@ private Room createRoom() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .option(AccommodationOption.builder() - .cooking(false) - .parking(true) - .pickup(false) - .barbecue(false) - .fitness(true) - .karaoke(false) - .sauna(false) - .sports(true) - .seminar(true) - .build()) .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/repository/RoomRepositoryTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/repository/RoomRepositoryTest.java index 4e110b80..9cd1a2cd 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/repository/RoomRepositoryTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/repository/RoomRepositoryTest.java @@ -86,17 +86,6 @@ private Accommodation saveAccommodation() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .option(AccommodationOption.builder() - .cooking(false) - .parking(true) - .pickup(false) - .barbecue(false) - .fitness(true) - .karaoke(false) - .sauna(false) - .sports(true) - .seminar(true) - .build()) .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build()); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomCommandServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomCommandServiceTest.java index c9078073..b55adfea 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomCommandServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomCommandServiceTest.java @@ -128,17 +128,6 @@ void _willSuccess() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .option(AccommodationOption.builder() - .cooking(false) - .parking(true) - .pickup(false) - .barbecue(false) - .fitness(true) - .karaoke(false) - .sauna(false) - .sports(true) - .seminar(true) - .build()) .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); @@ -288,17 +277,6 @@ void notOwner_willFail() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .option(AccommodationOption.builder() - .cooking(false) - .parking(true) - .pickup(false) - .barbecue(false) - .fitness(true) - .karaoke(false) - .sauna(false) - .sports(true) - .seminar(true) - .build()) .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); @@ -372,17 +350,6 @@ void _willSuccess() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .option(AccommodationOption.builder() - .cooking(false) - .parking(true) - .pickup(false) - .barbecue(false) - .fitness(true) - .karaoke(false) - .sauna(false) - .sports(true) - .seminar(true) - .build()) .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); @@ -508,17 +475,6 @@ void duplicatedRoomName_willFail() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .option(AccommodationOption.builder() - .cooking(false) - .parking(true) - .pickup(false) - .barbecue(false) - .fitness(true) - .karaoke(false) - .sauna(false) - .sports(true) - .seminar(true) - .build()) .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); @@ -594,17 +550,6 @@ void _willSuccess() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .option(AccommodationOption.builder() - .cooking(false) - .parking(true) - .pickup(false) - .barbecue(false) - .fitness(true) - .karaoke(false) - .sauna(false) - .sports(true) - .seminar(true) - .build()) .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); @@ -750,17 +695,6 @@ void _willSuccess() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .option(AccommodationOption.builder() - .cooking(false) - .parking(true) - .pickup(false) - .barbecue(false) - .fitness(true) - .karaoke(false) - .sauna(false) - .sports(true) - .seminar(true) - .build()) .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomQueryServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomQueryServiceTest.java index bd623a88..c0495c85 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomQueryServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomQueryServiceTest.java @@ -110,17 +110,6 @@ void _willSuccess() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .option(AccommodationOption.builder() - .cooking(false) - .parking(true) - .pickup(false) - .barbecue(false) - .fitness(true) - .karaoke(false) - .sauna(false) - .sports(true) - .seminar(true) - .build()) .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); @@ -330,17 +319,6 @@ void _willSuccess() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .option(AccommodationOption.builder() - .cooking(false) - .parking(true) - .pickup(false) - .barbecue(false) - .fitness(true) - .karaoke(false) - .sauna(false) - .sports(true) - .seminar(true) - .build()) .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); From c68250b2a3af676f7aa212fe9a2af159645af030 Mon Sep 17 00:00:00 2001 From: HyunA Date: Fri, 2 Feb 2024 23:44:30 +0900 Subject: [PATCH 05/21] =?UTF-8?q?refactor:=20room=EA=B3=BC=20roomOption?= =?UTF-8?q?=EC=9D=98=20=EC=9D=BC=EB=8C=80=EC=9D=BC=20=EC=9C=A0=EC=A7=80=20?= =?UTF-8?q?&=20=EC=99=B8=EB=9E=98=ED=82=A4=20=EA=B4=80=EA=B3=84=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/AccommodationInfoResponse.java | 5 +- .../service/AccommodationCommandService.java | 5 +- .../service/AccommodationQueryService.java | 7 ++- .../openapi/service/OpenApiService.java | 31 +++++---- .../room/dto/response/RoomInfoResponse.java | 5 +- .../room/dto/response/RoomResponse.java | 7 ++- .../room/dto/response/RoomsInfoResponse.java | 7 ++- .../upjuyanolja/domain/room/entity/Room.java | 7 --- .../domain/room/entity/RoomOption.java | 19 +++++- .../RoomOptionNotFoundException.java | 11 ++++ .../repository/RoomCustomRepositoryImpl.java | 2 - .../room/repository/RoomOptionRepository.java | 12 ++++ .../room/service/RoomCommandService.java | 63 +++++++++++++++++-- .../domain/room/service/RoomQueryService.java | 12 +++- .../global/exception/ErrorCode.java | 17 ++--- 15 files changed, 159 insertions(+), 51 deletions(-) create mode 100644 src/main/java/com/backoffice/upjuyanolja/domain/room/exception/RoomOptionNotFoundException.java create mode 100644 src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomOptionRepository.java diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationInfoResponse.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationInfoResponse.java index a1f15e00..b3b068d9 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationInfoResponse.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationInfoResponse.java @@ -19,10 +19,9 @@ public record AccommodationInfoResponse( ) { public static AccommodationInfoResponse of( - Accommodation accommodation, AccommodationOptionResponse option + Accommodation accommodation, AccommodationOptionResponse option, + List rooms ) { - List rooms = new ArrayList<>(); - accommodation.getRooms().forEach(room -> rooms.add(RoomInfoResponse.of(room))); return AccommodationInfoResponse.builder() .accommodationId(accommodation.getId()) .name(accommodation.getName()) diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java index 85fc51c3..97038e9c 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java @@ -21,6 +21,7 @@ import com.backoffice.upjuyanolja.domain.member.entity.Member; import com.backoffice.upjuyanolja.domain.member.service.MemberGetService; import com.backoffice.upjuyanolja.domain.room.dto.request.RoomRegisterRequest; +import com.backoffice.upjuyanolja.domain.room.dto.response.RoomInfoResponse; import com.backoffice.upjuyanolja.domain.room.exception.RoomNotFoundException; import com.backoffice.upjuyanolja.domain.room.service.RoomCommandService; import jakarta.persistence.EntityManager; @@ -82,7 +83,9 @@ public AccommodationInfoResponse createAccommodation( em.refresh(accommodation); - return AccommodationInfoResponse.of(accommodation, option); + List room = roomCommandService.getRoomsInAccommodation(accommodation); + + return AccommodationInfoResponse.of(accommodation, option, room); } public AccommodationOptionResponse createAccommodationOption( diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationQueryService.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationQueryService.java index 26fb1d04..46dd8ea2 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationQueryService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationQueryService.java @@ -17,7 +17,6 @@ import com.backoffice.upjuyanolja.domain.accommodation.service.usecase.AccommodationQueryUseCase; import com.backoffice.upjuyanolja.domain.coupon.dto.response.CouponDetailResponse; import com.backoffice.upjuyanolja.domain.coupon.entity.Coupon; -import com.backoffice.upjuyanolja.domain.coupon.entity.CouponStatus; import com.backoffice.upjuyanolja.domain.coupon.entity.DiscountType; import com.backoffice.upjuyanolja.domain.coupon.service.CouponService; import com.backoffice.upjuyanolja.domain.member.entity.Member; @@ -26,6 +25,7 @@ import com.backoffice.upjuyanolja.domain.room.dto.response.RoomResponse; import com.backoffice.upjuyanolja.domain.room.entity.Room; import com.backoffice.upjuyanolja.domain.room.entity.RoomStock; +import com.backoffice.upjuyanolja.domain.room.service.RoomCommandService; import com.backoffice.upjuyanolja.domain.room.service.RoomQueryService; import java.time.LocalDate; import java.util.ArrayList; @@ -50,6 +50,7 @@ public class AccommodationQueryService implements AccommodationQueryUseCase { private final AccommodationOptionRepository accommodationOptionRepository; private final MemberRepository memberRepository; private final CouponService couponService; + private final RoomCommandService roomCommandService; private final RoomQueryService roomQueryService; @Override @@ -111,7 +112,9 @@ public AccommodationDetailResponse findAccommodationWithRooms( AccommodationOptionResponse.of(accommodationOption), accommodation.getRooms().stream() .map(room -> RoomResponse.of( - room, getDiscountPrice(room), + room, + roomCommandService.getRoomOption(room), + getDiscountPrice(room), !checkSoldOut(filterRooms, room), getMinFilteredRoomStock(room, startDate, endDate), couponService.getSortedTotalCouponResponseInRoom(room) diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/openapi/service/OpenApiService.java b/src/main/java/com/backoffice/upjuyanolja/domain/openapi/service/OpenApiService.java index 3d40250f..0405e8e2 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/openapi/service/OpenApiService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/openapi/service/OpenApiService.java @@ -24,6 +24,7 @@ import com.backoffice.upjuyanolja.domain.room.entity.RoomStatus; import com.backoffice.upjuyanolja.domain.room.entity.RoomStock; import com.backoffice.upjuyanolja.domain.room.repository.RoomImageRepository; +import com.backoffice.upjuyanolja.domain.room.repository.RoomOptionRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomStockRepository; import jakarta.annotation.PostConstruct; @@ -70,6 +71,7 @@ public class OpenApiService { private final AccommodationOptionRepository accommodationOptionRepository; private final CategoryRepository categoryRepository; private final RoomRepository roomRepository; + private final RoomOptionRepository roomOptionRepository; private final RoomImageRepository roomImageRepository; private final RoomStockRepository roomStockRepository; @@ -259,11 +261,10 @@ private Accommodation saveAccommodation( return saveAccommodation; } - private AccommodationOption saveAccommodationOption( + private void saveAccommodationOption( Accommodation accommodation, JSONObject intro ) { - - AccommodationOption option = AccommodationOption.builder() + accommodationOptionRepository.save(AccommodationOption.builder() .accommodation(accommodation) .cooking(intro.get("chkcooking").equals("가능")) .parking(intro.get("parkinglodging").equals("가능")) @@ -273,12 +274,10 @@ private AccommodationOption saveAccommodationOption( .karaoke(intro.get("karaoke").equals("1")) .sports(intro.get("sports").equals("1")) .seminar(intro.get("seminar").equals("1")) - .build(); - - return accommodationOptionRepository.save(option); + .build() + ); } - private void saveOwnership(Accommodation accommodation, Member member) { accommodationOwnershipRepository.save(AccommodationOwnership.builder() .accommodation(accommodation) @@ -336,11 +335,6 @@ private void saveRooms( .peakWeekDaysMinFee(peakWeekDaysMinFee) .peakWeekendMinFee(peakWeekendMinFee) .build(); - RoomOption option = RoomOption.builder() - .airCondition(roomJson.get("roomaircondition").equals("Y")) - .tv(roomJson.get("roomtv").equals("Y")) - .internet(roomJson.get("roominternet").equals("Y")) - .build(); Room room = roomRepository.save(Room.builder() .accommodation(accommodation) @@ -352,7 +346,6 @@ private void saveRooms( .checkInTime(checkIn) .checkOutTime(checkOut) .price(price) - .option(option) .images(new ArrayList<>()) .amount(Integer.parseInt(roomJson.getString("roomcount"))) .status(RoomStatus.SELLING) @@ -374,10 +367,22 @@ private void saveRooms( .build()); } } + + saveRoomOption(room, roomJson); } } } + private void saveRoomOption(Room room, JSONObject roomJson) { + roomOptionRepository.save(RoomOption.builder() + .room(room) + .airCondition(roomJson.get("roomaircondition").equals("Y")) + .tv(roomJson.get("roomtv").equals("Y")) + .internet(roomJson.get("roominternet").equals("Y")) + .build() + ); + } + private boolean isEmpty(JSONObject body) throws JSONException { return body.getInt("totalCount") == 0; } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomInfoResponse.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomInfoResponse.java index c74ad7f6..869b97ab 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomInfoResponse.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomInfoResponse.java @@ -1,6 +1,7 @@ package com.backoffice.upjuyanolja.domain.room.dto.response; import com.backoffice.upjuyanolja.domain.room.entity.Room; +import com.backoffice.upjuyanolja.domain.room.entity.RoomOption; import java.time.format.DateTimeFormatter; import java.util.List; import lombok.Builder; @@ -20,7 +21,7 @@ public record RoomInfoResponse( RoomOptionResponse option ) { - public static RoomInfoResponse of(Room room) { + public static RoomInfoResponse of(Room room, RoomOption option) { return RoomInfoResponse.builder() .id(room.getId()) .name(room.getName()) @@ -32,7 +33,7 @@ public static RoomInfoResponse of(Room room) { .amount(room.getAmount()) .status(room.getStatus().name()) .images(RoomImageResponse.of(room.getImages())) - .option(RoomOptionResponse.of(room.getOption())) + .option(RoomOptionResponse.of(option)) .build(); } } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomResponse.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomResponse.java index 5b9431e2..b5de2551 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomResponse.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomResponse.java @@ -2,6 +2,7 @@ import com.backoffice.upjuyanolja.domain.coupon.dto.response.CouponDetailResponse; import com.backoffice.upjuyanolja.domain.room.entity.Room; +import com.backoffice.upjuyanolja.domain.room.entity.RoomOption; import java.time.format.DateTimeFormatter; import java.util.List; import java.util.stream.Stream; @@ -25,8 +26,8 @@ public record RoomResponse( ) { public static RoomResponse of( - Room room, int discountPrice, boolean soldOut, int count, - List coupons + Room room, RoomOption option, int discountPrice, + boolean soldOut, int count, List coupons ) { return RoomResponse.builder() @@ -53,7 +54,7 @@ public static RoomResponse of( .map(image -> image.getUrl()) .toList() ) - .roomOption(RoomOptionResponse.of(room.getOption())) + .roomOption(RoomOptionResponse.of(option)) .build(); } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomsInfoResponse.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomsInfoResponse.java index 4c1bcb91..f9389d34 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomsInfoResponse.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomsInfoResponse.java @@ -2,6 +2,7 @@ import com.backoffice.upjuyanolja.domain.coupon.dto.response.CouponDetailResponse; import com.backoffice.upjuyanolja.domain.room.entity.Room; +import com.backoffice.upjuyanolja.domain.room.entity.RoomOption; import java.time.format.DateTimeFormatter; import java.util.Comparator; import java.util.List; @@ -25,7 +26,9 @@ public record RoomsInfoResponse( List coupons ) { - public static RoomsInfoResponse of(Room room, List coupons) { + public static RoomsInfoResponse of( + Room room, RoomOption option, List coupons + ) { PriorityQueue pq = new PriorityQueue<>(Comparator.comparingInt(i -> i)); for (CouponDetailResponse coupon : coupons) { pq.offer(coupon.price()); @@ -44,7 +47,7 @@ public static RoomsInfoResponse of(Room room, List coupons .amount(room.getAmount()) .status(room.getStatus().name()) .images(RoomImageResponse.of(room.getImages())) - .option(RoomOptionResponse.of(room.getOption())) + .option(RoomOptionResponse.of(option)) .coupons(coupons) .build(); } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/entity/Room.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/entity/Room.java index c4ad07fc..40ec1d6e 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/entity/Room.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/entity/Room.java @@ -76,10 +76,6 @@ public class Room extends BaseTime { @Comment("객실 가격") private RoomPrice price; - @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) - @Comment("객실 옵션 식별자") - private RoomOption option; - @OneToMany(mappedBy = "room", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) @Comment("객실 이미지 식별자") private List images = new ArrayList<>(); @@ -97,7 +93,6 @@ public Room( LocalTime checkOutTime, RoomPrice price, RoomStatus status, - RoomOption option, List images ) { this.id = id; @@ -110,7 +105,6 @@ public Room( this.checkOutTime = checkOutTime; this.price = price; this.status = status; - this.option = option; this.images = images; } @@ -123,7 +117,6 @@ public void updateRoom(RoomUpdate request) { this.checkInTime = DateTimeParser.timeParser(request.checkInTime()); this.checkOutTime = DateTimeParser.timeParser(request.checkOutTime()); this.amount = request.amount(); - this.option.updateRoomOption(request.option()); } @Override diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/entity/RoomOption.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/entity/RoomOption.java index 10e426c1..3fc4aac4 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/entity/RoomOption.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/entity/RoomOption.java @@ -1,11 +1,16 @@ package com.backoffice.upjuyanolja.domain.room.entity; import com.backoffice.upjuyanolja.domain.room.service.usecase.RoomCommandUseCase.RoomOptionUpdate; +import com.backoffice.upjuyanolja.global.common.entity.BaseTime; +import jakarta.persistence.CascadeType; import jakarta.persistence.Column; import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; +import jakarta.persistence.OneToOne; +import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; @@ -15,13 +20,17 @@ @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @Entity -public class RoomOption { +public class RoomOption extends BaseTime { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Comment("객실 옵션 식별자") private Long id; + @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) + @Comment("객실 식별자") + private Room room; + @Column(nullable = false) @Comment("에어컨 여부") private boolean airCondition; @@ -37,11 +46,13 @@ public class RoomOption { @Builder public RoomOption( Long id, + Room room, boolean airCondition, boolean tv, boolean internet ) { this.id = id; + this.room = room; this.airCondition = airCondition; this.tv = tv; this.internet = internet; @@ -52,4 +63,10 @@ public void updateRoomOption(RoomOptionUpdate request) { this.tv = request.tv(); this.internet = request.internet(); } + + @Override + public void delete(LocalDateTime currentTime) { + super.delete(currentTime); + } + } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/exception/RoomOptionNotFoundException.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/exception/RoomOptionNotFoundException.java new file mode 100644 index 00000000..a30ded2e --- /dev/null +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/exception/RoomOptionNotFoundException.java @@ -0,0 +1,11 @@ +package com.backoffice.upjuyanolja.domain.room.exception; + +import com.backoffice.upjuyanolja.global.exception.ApplicationException; +import com.backoffice.upjuyanolja.global.exception.ErrorCode; + +public class RoomOptionNotFoundException extends ApplicationException { + + public RoomOptionNotFoundException() { + super(ErrorCode.ROOM_OPTION_NOT_FOUND); + } +} diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomCustomRepositoryImpl.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomCustomRepositoryImpl.java index f4866cea..bc01d9a6 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomCustomRepositoryImpl.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomCustomRepositoryImpl.java @@ -37,7 +37,6 @@ public Page findAllByAccommodation(long accommodationId, Pageable pageable .select(room) .from(room) .leftJoin(room.accommodation, accommodation).fetchJoin() - .leftJoin(room.option, roomOption).fetchJoin() .leftJoin(room.images, roomImage).fetchJoin() .where(createSearchConditionsBuilder(accommodationId)) .offset(pageable.getOffset()) @@ -47,7 +46,6 @@ public Page findAllByAccommodation(long accommodationId, Pageable pageable .select(room) .from(room) .leftJoin(room.accommodation, accommodation).fetchJoin() - .leftJoin(room.option, roomOption).fetchJoin() .leftJoin(room.images, roomImage).fetchJoin() .where(room.accommodation.id.eq(accommodationId)); List content = query.fetch(); diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomOptionRepository.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomOptionRepository.java new file mode 100644 index 00000000..0d8153b0 --- /dev/null +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomOptionRepository.java @@ -0,0 +1,12 @@ +package com.backoffice.upjuyanolja.domain.room.repository; + +import com.backoffice.upjuyanolja.domain.room.entity.Room; +import com.backoffice.upjuyanolja.domain.room.entity.RoomOption; +import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface RoomOptionRepository extends JpaRepository { + + Optional findByRoom(Room room); + +} diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomCommandService.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomCommandService.java index b783607d..70801465 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomCommandService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomCommandService.java @@ -15,6 +15,7 @@ import com.backoffice.upjuyanolja.domain.room.dto.response.RoomInfoResponse; import com.backoffice.upjuyanolja.domain.room.entity.Room; import com.backoffice.upjuyanolja.domain.room.entity.RoomImage; +import com.backoffice.upjuyanolja.domain.room.entity.RoomOption; import com.backoffice.upjuyanolja.domain.room.entity.RoomPrice; import com.backoffice.upjuyanolja.domain.room.entity.RoomStatus; import com.backoffice.upjuyanolja.domain.room.entity.RoomStock; @@ -24,20 +25,22 @@ import com.backoffice.upjuyanolja.domain.room.exception.RoomImageNotExistsException; import com.backoffice.upjuyanolja.domain.room.exception.RoomImageNotFoundException; import com.backoffice.upjuyanolja.domain.room.exception.RoomNotFoundException; +import com.backoffice.upjuyanolja.domain.room.exception.RoomOptionNotFoundException; import com.backoffice.upjuyanolja.domain.room.repository.RoomImageRepository; +import com.backoffice.upjuyanolja.domain.room.repository.RoomOptionRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomStockRepository; import com.backoffice.upjuyanolja.domain.room.service.usecase.RoomCommandUseCase; import com.backoffice.upjuyanolja.global.exception.NotOwnerException; import com.backoffice.upjuyanolja.global.util.DateTimeParser; import jakarta.persistence.EntityManager; -import jakarta.transaction.Transactional; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service @Transactional @@ -47,6 +50,7 @@ public class RoomCommandService implements RoomCommandUseCase { private final MemberGetService memberGetService; private final RoomRepository roomRepository; private final RoomImageRepository roomImageRepository; + private final RoomOptionRepository roomOptionRepository; private final RoomStockRepository roomStockRepository; private final AccommodationRepository accommodationRepository; private final AccommodationOwnershipRepository accommodationOwnershipRepository; @@ -88,7 +92,6 @@ public RoomInfoResponse saveRoom(Accommodation accommodation, RoomRegisterReques .checkOutTime(DateTimeParser.timeParser(request.checkOutTime())) .amount(request.amount()) .images(new ArrayList<>()) - .option(RoomOptionRequest.toEntity(request.option())) .build() ); @@ -97,7 +100,9 @@ public RoomInfoResponse saveRoom(Accommodation accommodation, RoomRegisterReques createRoomStock(room); - return RoomInfoResponse.of(room); + RoomOption roomOption = saveRoomOption(room, request.option()); + + return RoomInfoResponse.of(room, roomOption); } @Override @@ -116,7 +121,9 @@ public RoomInfoResponse modifyRoom(long memberId, long roomId, RoomUpdateRequest em.flush(); em.refresh(room); - return RoomInfoResponse.of(room); + RoomOption roomOption = updateRoomOption(room, request.option().toRoomOptionUpdateDto()); + + return RoomInfoResponse.of(room, roomOption); } @Override @@ -128,7 +135,30 @@ public RoomInfoResponse deleteRoom(long memberId, long roomId) { throw new CanNotDeleteLastRoomException(); } room.delete(LocalDateTime.now()); - return RoomInfoResponse.of(room); + + RoomOption roomOption = getRoomOption(room); + roomOption.delete(LocalDateTime.now()); + + return RoomInfoResponse.of(room, roomOption); + } + + @Transactional(readOnly = true) + public List getRoomsInAccommodation(Accommodation accommodation) { + List rooms = new ArrayList<>(); + accommodation.getRooms() + .forEach(room -> { + RoomOption option = getRoomOption(room); + rooms.add(RoomInfoResponse.of(room, option)); + } + ); + + return rooms; + } + + @Transactional(readOnly = true) + public RoomOption getRoomOption(Room room) { + return roomOptionRepository.findByRoom(room) + .orElseThrow(RoomOptionNotFoundException::new); } private void validateRoomName(String name, Accommodation accommodation) { @@ -149,10 +179,21 @@ private void updateRoom(Room room, RoomUpdateRequest request) { updateRoomStock(room, request.amount() - room.getAmount()); } room.updateRoom(request.toRoomUpdateDto()); + updateRoomOption(room, request.option().toRoomOptionUpdateDto()); addRoomImages(room, request.addImages()); roomImageRepository.deleteAll(getRoomImages(request.deleteImages())); } + private RoomOption updateRoomOption(Room room, RoomOptionUpdate option) { + RoomOption roomOption = getRoomOption(room); + roomOption.updateRoomOption(option); + + em.flush(); + em.refresh(roomOption); + + return roomOption; + } + private void updateRoomStock(Room room, int quantity) { List stocks = roomStockRepository .findAllByRoomAndDateAfter(room, LocalDate.now().minusDays(1)); @@ -192,6 +233,18 @@ private void validateRoomStatus(String status) { } } + private RoomOption saveRoomOption(Room room, RoomOptionRequest request) { + RoomOption saveRoomOption = roomOptionRepository.save(RoomOption.builder() + .room(room) + .tv(request.tv()) + .airCondition(request.airCondition()) + .internet(request.internet()) + .build() + ); + + return saveRoomOption; + } + private void createRoomStock(Room room) { for (int i = 0; i < 30; i++) { roomStockRepository.save(RoomStock.builder() diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomQueryService.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomQueryService.java index d847fecc..2d61e6f7 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomQueryService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomQueryService.java @@ -14,6 +14,7 @@ import com.backoffice.upjuyanolja.domain.room.dto.response.RoomPageResponse; import com.backoffice.upjuyanolja.domain.room.dto.response.RoomsInfoResponse; import com.backoffice.upjuyanolja.domain.room.entity.Room; +import com.backoffice.upjuyanolja.domain.room.entity.RoomOption; import com.backoffice.upjuyanolja.domain.room.entity.RoomStock; import com.backoffice.upjuyanolja.domain.room.exception.RoomNotFoundException; import com.backoffice.upjuyanolja.domain.room.exception.RoomStockNotFoundException; @@ -41,6 +42,7 @@ public class RoomQueryService implements RoomQueryUseCase { private final AccommodationOwnershipRepository accommodationOwnershipRepository; private final RoomRepository roomRepository; private final CouponService couponService; + private final RoomCommandService roomCommandService; private final RoomStockRepository roomStockRepository; @Override @@ -58,7 +60,10 @@ public RoomPageResponse getRooms(long memberId, long accommodationId, Pageable p .getSortedDiscountTypeCouponResponseInRoom(room, coupons, DiscountType.FLAT)); couponDetails.addAll(couponService .getSortedDiscountTypeCouponResponseInRoom(room, coupons, DiscountType.RATE)); - rooms.add(RoomsInfoResponse.of(room, couponDetails)); + + RoomOption option = roomCommandService.getRoomOption(room); + + rooms.add(RoomsInfoResponse.of(room, option, couponDetails)); }); return RoomPageResponse.builder() .pageNum(roomPage.getNumber()) @@ -75,7 +80,10 @@ public RoomInfoResponse getRoom(long memberId, long roomId) { Member member = memberGetService.getMemberById(memberId); Room room = roomRepository.findById(roomId).orElseThrow(RoomNotFoundException::new); checkOwnership(member, room.getAccommodation()); - return RoomInfoResponse.of(room); + + RoomOption option = roomCommandService.getRoomOption(room); + + return RoomInfoResponse.of(room, option); } @Override diff --git a/src/main/java/com/backoffice/upjuyanolja/global/exception/ErrorCode.java b/src/main/java/com/backoffice/upjuyanolja/global/exception/ErrorCode.java index 1c382446..96e95f81 100644 --- a/src/main/java/com/backoffice/upjuyanolja/global/exception/ErrorCode.java +++ b/src/main/java/com/backoffice/upjuyanolja/global/exception/ErrorCode.java @@ -33,14 +33,15 @@ public enum ErrorCode { // Room ROOM_NOT_FOUND(HttpStatus.NOT_FOUND, 3000, "객실 정보를 찾을 수 없습니다."), - DUPLICATED_ROOM_NAME(HttpStatus.BAD_REQUEST, 3001, "중복된 객실 이름입니다."), - INVALID_TIME_FORMAT(HttpStatus.BAD_REQUEST, 3002, "올바르지 않은 형식의 시간입니다.(HH:mm)"), - INVALID_ROOM_STATUS(HttpStatus.BAD_REQUEST, 3003, "올바르지 않은 형식의 객실 상태입니다."), - ROOM_STOCK_NOT_FOUND(HttpStatus.NOT_FOUND, 3004, "객실 재고 정보를 찾을 수 없습니다."), - ROOM_IMAGE_NOT_FOUND(HttpStatus.NOT_FOUND, 3005, "객실 이미지 정보를 찾을 수 없습니다."), - ROOM_NOT_EXISTS(HttpStatus.BAD_REQUEST, 3006, "객실을 1개 이상 등록해야 합니다."), - ROOM_IMAGE_NOT_EXISTS(HttpStatus.BAD_REQUEST, 3007, "객실 이미지를 1개 이상 등록해야 합니다."), - LAST_ROOM(HttpStatus.BAD_REQUEST, 3008, "마지막 객실은 삭제할 수 없습니다."), + ROOM_OPTION_NOT_FOUND(HttpStatus.NOT_FOUND, 3001, "객실 옵션 정보를 찾을 수 없습니다."), + DUPLICATED_ROOM_NAME(HttpStatus.BAD_REQUEST, 3002, "중복된 객실 이름입니다."), + INVALID_TIME_FORMAT(HttpStatus.BAD_REQUEST, 3003, "올바르지 않은 형식의 시간입니다.(HH:mm)"), + INVALID_ROOM_STATUS(HttpStatus.BAD_REQUEST, 3004, "올바르지 않은 형식의 객실 상태입니다."), + ROOM_STOCK_NOT_FOUND(HttpStatus.NOT_FOUND, 3005, "객실 재고 정보를 찾을 수 없습니다."), + ROOM_IMAGE_NOT_FOUND(HttpStatus.NOT_FOUND, 3006, "객실 이미지 정보를 찾을 수 없습니다."), + ROOM_NOT_EXISTS(HttpStatus.BAD_REQUEST, 3007, "객실을 1개 이상 등록해야 합니다."), + ROOM_IMAGE_NOT_EXISTS(HttpStatus.BAD_REQUEST, 3008, "객실 이미지를 1개 이상 등록해야 합니다."), + LAST_ROOM(HttpStatus.BAD_REQUEST, 3009, "마지막 객실은 삭제할 수 없습니다."), // Reservation RESERVATION_PAYMENT_FAILED(HttpStatus.BAD_REQUEST, 4000, "결제에 실패 했습니다."), From 8d673454c745c014962fdafbc85e02c1d351209d Mon Sep 17 00:00:00 2001 From: HyunA Date: Sat, 3 Feb 2024 00:39:27 +0900 Subject: [PATCH 06/21] =?UTF-8?q?refactor:=20room=20=EC=B2=98=EB=9F=BC=20a?= =?UTF-8?q?ccommodation=EB=8F=84=20option=EC=9D=84=20dto=EA=B0=80=20?= =?UTF-8?q?=EC=95=84=EB=8B=8C=20entity=EB=A1=9C=20=EB=B0=9B=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/AccommodationInfoResponse.java | 5 +++-- .../service/AccommodationCommandService.java | 19 +++++-------------- .../AccommodationCommandServiceTest.java | 11 ++++++----- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationInfoResponse.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationInfoResponse.java index b3b068d9..31548696 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationInfoResponse.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationInfoResponse.java @@ -1,6 +1,7 @@ package com.backoffice.upjuyanolja.domain.accommodation.dto.response; import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; +import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import com.backoffice.upjuyanolja.domain.room.dto.response.RoomInfoResponse; import java.util.ArrayList; import java.util.List; @@ -19,7 +20,7 @@ public record AccommodationInfoResponse( ) { public static AccommodationInfoResponse of( - Accommodation accommodation, AccommodationOptionResponse option, + Accommodation accommodation, AccommodationOption option, List rooms ) { return AccommodationInfoResponse.builder() @@ -31,7 +32,7 @@ public static AccommodationInfoResponse of( + " " + accommodation.getDetailAddress()) .images(AccommodationImageResponse.of(accommodation.getImages())) - .option(option) + .option(AccommodationOptionResponse.of(option)) .rooms(rooms) .build(); } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java index 97038e9c..73330c23 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java @@ -79,21 +79,19 @@ public AccommodationInfoResponse createAccommodation( request.rooms().forEach( roomRegisterRequest -> roomCommandService.saveRoom(accommodation, roomRegisterRequest)); - AccommodationOptionResponse option = createAccommodationOption(request.option()); + AccommodationOption option = createAccommodationOption(accommodation, request.option()); em.refresh(accommodation); + em.refresh(option); List room = roomCommandService.getRoomsInAccommodation(accommodation); return AccommodationInfoResponse.of(accommodation, option, room); } - public AccommodationOptionResponse createAccommodationOption( - AccommodationOptionRequest request + public AccommodationOption createAccommodationOption( + Accommodation accommodation, AccommodationOptionRequest request ) { - - Accommodation accommodation = getAccommodation(request.AccommodationId()); - AccommodationOption accommodationOption = accommodationOptionRepository.save( AccommodationOption.builder() .accommodation(accommodation) @@ -109,14 +107,7 @@ public AccommodationOptionResponse createAccommodationOption( .build() ); - em.refresh(accommodationOption); - return AccommodationOptionResponse.of(accommodationOption); - } - - - private Accommodation getAccommodation(Long accommodationId) { - return accommodationRepository.findById(accommodationId) - .orElseThrow(AccommodationNotFoundException::new); + return accommodationOption; } private Category getCategory(String category) { diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationCommandServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationCommandServiceTest.java index f494f527..b4fbf7db 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationCommandServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationCommandServiceTest.java @@ -15,6 +15,7 @@ import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOwnership; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationImageRepository; +import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationOptionRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationOwnershipRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.CategoryRepository; @@ -66,6 +67,9 @@ public class AccommodationCommandServiceTest { @Mock private AccommodationOwnershipRepository accommodationOwnershipRepository; + @Mock + private AccommodationOptionRepository accommodationOptionRepository; + @Mock private AccommodationImageRepository accommodationImageRepository; @@ -153,6 +157,7 @@ void _willSuccess() { .build(); AccommodationOption accommodationOption = AccommodationOption.builder() .id(1L) + .accommodation(accommodation) .cooking(false) .parking(true) .pickup(false) @@ -208,11 +213,6 @@ void _willSuccess() { .build()) .amount(858) .status(RoomStatus.SELLING) - .option(RoomOption.builder() - .airCondition(true) - .tv(true) - .internet(true) - .build()) .images(new ArrayList<>()) .build(); Accommodation savedAccommodation = Accommodation.builder() @@ -234,6 +234,7 @@ void _willSuccess() { .findCategoryByNameAndIdGreaterThan(any(String.class), any(Long.TYPE))) .willReturn(Optional.of(category)); given(accommodationRepository.save(any(Accommodation.class))).willReturn(accommodation); + given(accommodationOptionRepository.save(any(AccommodationOption.class))).willReturn(accommodationOption); given(accommodationImageRepository.saveAll(any(List.class))) .willReturn(List.of(accommodationImage)); given(accommodationOwnershipRepository.save(any(AccommodationOwnership.class))) From 0bcc313467d3514e114e61907ebaafa64d8ba012 Mon Sep 17 00:00:00 2001 From: HyunA Date: Sat, 3 Feb 2024 03:20:55 +0900 Subject: [PATCH 07/21] =?UTF-8?q?refactor:=20=EB=8B=A4=EB=A5=B8=20?= =?UTF-8?q?=EB=8F=84=EB=A9=94=EC=9D=B8=EC=97=90=EC=84=9C=EB=8A=94=20RoomQu?= =?UTF-8?q?eryService=20=EC=95=84=EB=8B=8C=20RoomQueryUseCase=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=20=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/AccommodationQueryService.java | 20 +++++++++---------- .../AccommodationOwnershipRepositoryTest.java | 19 +++++++++++++----- .../AccommodationQueryServiceTest.java | 5 ----- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationQueryService.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationQueryService.java index 46dd8ea2..beadb24d 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationQueryService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationQueryService.java @@ -25,8 +25,7 @@ import com.backoffice.upjuyanolja.domain.room.dto.response.RoomResponse; import com.backoffice.upjuyanolja.domain.room.entity.Room; import com.backoffice.upjuyanolja.domain.room.entity.RoomStock; -import com.backoffice.upjuyanolja.domain.room.service.RoomCommandService; -import com.backoffice.upjuyanolja.domain.room.service.RoomQueryService; +import com.backoffice.upjuyanolja.domain.room.service.usecase.RoomQueryUseCase; import java.time.LocalDate; import java.util.ArrayList; import java.util.Comparator; @@ -50,8 +49,7 @@ public class AccommodationQueryService implements AccommodationQueryUseCase { private final AccommodationOptionRepository accommodationOptionRepository; private final MemberRepository memberRepository; private final CouponService couponService; - private final RoomCommandService roomCommandService; - private final RoomQueryService roomQueryService; + private final RoomQueryUseCase roomQueryUseCase; @Override @Transactional(readOnly = true) @@ -113,7 +111,7 @@ public AccommodationDetailResponse findAccommodationWithRooms( accommodation.getRooms().stream() .map(room -> RoomResponse.of( room, - roomCommandService.getRoomOption(room), + roomQueryUseCase.findRoomOptionByRoom(room), getDiscountPrice(room), !checkSoldOut(filterRooms, room), getMinFilteredRoomStock(room, startDate, endDate), @@ -165,7 +163,7 @@ private boolean checkCouponAvailability(Accommodation accommodation) { } private int getLowestPrice(Long accommodationId) { - List rooms = roomQueryService.findByAccommodationId(accommodationId); + List rooms = roomQueryUseCase.findByAccommodationId(accommodationId); PriorityQueue pq = new PriorityQueue<>(Comparator.comparingInt(i -> i)); @@ -178,7 +176,7 @@ private int getLowestPrice(Long accommodationId) { private Optional getDiscountInfo(Long accommodationId) { List responses = new ArrayList<>(); - List rooms = roomQueryService.findByAccommodationId(accommodationId); + List rooms = roomQueryUseCase.findByAccommodationId(accommodationId); List coupons = new ArrayList<>(); for (Room room : rooms) { @@ -196,7 +194,7 @@ private Optional getDiscountInfo(Long accommodationId) { } private String getMainCouponName(Long accommodationId) { - List rooms = roomQueryService.findByAccommodationId(accommodationId); + List rooms = roomQueryUseCase.findByAccommodationId(accommodationId); String flatName = couponService.getDiscountTypeMainRoomCouponName(rooms, DiscountType.FLAT); String rateName = couponService.getDiscountTypeMainRoomCouponName(rooms, DiscountType.RATE); @@ -214,7 +212,7 @@ private String getMainCouponName(Long accommodationId) { @Transactional(readOnly = true) public Accommodation findAccommodationByRoomId(long roomId) { - return roomQueryService.findRoomById(roomId).getAccommodation(); + return roomQueryUseCase.findRoomById(roomId).getAccommodation(); } @@ -232,7 +230,7 @@ private List getFilteredRoomsByDate( List filterRoom = new ArrayList<>(); for (Room room : rooms) { - List filteredStocks = roomQueryService.getFilteredRoomStocksByDate(room, + List filteredStocks = roomQueryUseCase.getFilteredRoomStocksByDate(room, startDate, endDate); if (!filteredStocks.isEmpty()) { filterRoom.add(room); @@ -244,7 +242,7 @@ private List getFilteredRoomsByDate( private int getMinFilteredRoomStock( Room room, LocalDate startDate, LocalDate endDate ) { - return roomQueryService.getFilteredRoomStocksByDate(room, startDate, endDate).stream() + return roomQueryUseCase.getFilteredRoomStocksByDate(room, startDate, endDate).stream() .mapToInt(RoomStock::getCount) .min() .orElse(0); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/repository/AccommodationOwnershipRepositoryTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/repository/AccommodationOwnershipRepositoryTest.java index 73470997..ca6a721e 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/repository/AccommodationOwnershipRepositoryTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/repository/AccommodationOwnershipRepositoryTest.java @@ -17,6 +17,7 @@ import com.backoffice.upjuyanolja.domain.room.entity.RoomOption; import com.backoffice.upjuyanolja.domain.room.entity.RoomPrice; import com.backoffice.upjuyanolja.domain.room.entity.RoomStatus; +import com.backoffice.upjuyanolja.domain.room.repository.RoomOptionRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomRepository; import com.backoffice.upjuyanolja.global.config.QueryDslConfig; import jakarta.persistence.EntityManager; @@ -57,6 +58,9 @@ public class AccommodationOwnershipRepositoryTest { @Autowired private RoomRepository roomRepository; + @Autowired + private RoomOptionRepository roomOptionRepository; + @PersistenceContext private EntityManager entityManager; @@ -174,15 +178,20 @@ private Room saveRoom(Accommodation accommodation) { .build()) .amount(858) .status(RoomStatus.SELLING) - .option(RoomOption.builder() - .airCondition(true) - .tv(true) - .internet(true) - .build()) .images(new ArrayList<>()) .build()); } + + private RoomOption saveRoomOption(Room room) { + return roomOptionRepository.save(RoomOption.builder() + .room(room) + .airCondition(true) + .tv(true) + .internet(true) + .build()); + } + @Nested @DisplayName("findAllByMember()는") class Context_findAllByMember { diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationQueryServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationQueryServiceTest.java index 15cb5f06..2d8b1613 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationQueryServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationQueryServiceTest.java @@ -116,11 +116,6 @@ void _willSuccess() { .build()) .amount(858) .status(RoomStatus.SELLING) - .option(RoomOption.builder() - .airCondition(true) - .tv(true) - .internet(true) - .build()) .images(new ArrayList<>()) .build(); Accommodation savedAccommodation = Accommodation.builder() From 583767c3f9df700c7cd9a261182cd73121f5c305 Mon Sep 17 00:00:00 2001 From: HyunA Date: Sat, 3 Feb 2024 03:21:38 +0900 Subject: [PATCH 08/21] =?UTF-8?q?test:=20room=EA=B3=BC=20roomOption=20?= =?UTF-8?q?=EA=B4=80=EA=B3=84=20=EB=B3=80=EA=B2=BD=EC=97=90=20=EB=94=B0?= =?UTF-8?q?=EB=A5=B8=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EB=B0=8F=20=EB=B9=8C=EB=93=9C=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../room/service/RoomCommandService.java | 48 +++++------ .../domain/room/service/RoomQueryService.java | 33 +++++--- .../service/usecase/RoomQueryUseCase.java | 13 +-- .../CouponBackofficeControllerDocsTest.java | 5 -- .../CouponBackofficeControllerTest.java | 5 -- .../unit/repository/CouponRepositoryTest.java | 5 -- .../service/CouponBackofficeServiceTest.java | 5 -- .../docs/ReservationControllerDocsTest.java | 5 -- .../controller/ReservationControllerTest.java | 5 -- .../repository/ReservationRepositoryTest.java | 5 -- .../unit/service/ReservationServiceTest.java | 5 -- .../service/ReservationStockServiceTest.java | 5 -- .../unit/repository/RoomRepositoryTest.java | 5 -- .../unit/service/RoomCommandServiceTest.java | 81 +++++++++++-------- .../unit/service/RoomQueryServiceTest.java | 49 ++++++----- 15 files changed, 125 insertions(+), 149 deletions(-) diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomCommandService.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomCommandService.java index 70801465..15d6ae71 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomCommandService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomCommandService.java @@ -25,12 +25,12 @@ import com.backoffice.upjuyanolja.domain.room.exception.RoomImageNotExistsException; import com.backoffice.upjuyanolja.domain.room.exception.RoomImageNotFoundException; import com.backoffice.upjuyanolja.domain.room.exception.RoomNotFoundException; -import com.backoffice.upjuyanolja.domain.room.exception.RoomOptionNotFoundException; import com.backoffice.upjuyanolja.domain.room.repository.RoomImageRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomOptionRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomStockRepository; import com.backoffice.upjuyanolja.domain.room.service.usecase.RoomCommandUseCase; +import com.backoffice.upjuyanolja.domain.room.service.usecase.RoomQueryUseCase; import com.backoffice.upjuyanolja.global.exception.NotOwnerException; import com.backoffice.upjuyanolja.global.util.DateTimeParser; import jakarta.persistence.EntityManager; @@ -54,6 +54,7 @@ public class RoomCommandService implements RoomCommandUseCase { private final RoomStockRepository roomStockRepository; private final AccommodationRepository accommodationRepository; private final AccommodationOwnershipRepository accommodationOwnershipRepository; + private final RoomQueryUseCase roomQueryUseCase; private final EntityManager em; @Override @@ -105,6 +106,18 @@ public RoomInfoResponse saveRoom(Accommodation accommodation, RoomRegisterReques return RoomInfoResponse.of(room, roomOption); } + public RoomOption saveRoomOption(Room room, RoomOptionRequest request) { + RoomOption saveRoomOption = roomOptionRepository.save(RoomOption.builder() + .room(room) + .tv(request.tv()) + .airCondition(request.airCondition()) + .internet(request.internet()) + .build() + ); + + return saveRoomOption; + } + @Override public RoomInfoResponse modifyRoom(long memberId, long roomId, RoomUpdateRequest request) { Member member = memberGetService.getMemberById(memberId); @@ -118,10 +131,11 @@ public RoomInfoResponse modifyRoom(long memberId, long roomId, RoomUpdateRequest updateRoom(room, request); + RoomOption roomOption = updateRoomOption(room, request.option().toRoomOptionUpdateDto()); + em.flush(); em.refresh(room); - - RoomOption roomOption = updateRoomOption(room, request.option().toRoomOptionUpdateDto()); + em.refresh(roomOption); return RoomInfoResponse.of(room, roomOption); } @@ -136,7 +150,7 @@ public RoomInfoResponse deleteRoom(long memberId, long roomId) { } room.delete(LocalDateTime.now()); - RoomOption roomOption = getRoomOption(room); + RoomOption roomOption = roomQueryUseCase.findRoomOptionByRoom(room); roomOption.delete(LocalDateTime.now()); return RoomInfoResponse.of(room, roomOption); @@ -147,7 +161,7 @@ public List getRoomsInAccommodation(Accommodation accommodatio List rooms = new ArrayList<>(); accommodation.getRooms() .forEach(room -> { - RoomOption option = getRoomOption(room); + RoomOption option = roomQueryUseCase.findRoomOptionByRoom(room); rooms.add(RoomInfoResponse.of(room, option)); } ); @@ -155,12 +169,6 @@ public List getRoomsInAccommodation(Accommodation accommodatio return rooms; } - @Transactional(readOnly = true) - public RoomOption getRoomOption(Room room) { - return roomOptionRepository.findByRoom(room) - .orElseThrow(RoomOptionNotFoundException::new); - } - private void validateRoomName(String name, Accommodation accommodation) { if (roomRepository.existsRoomByNameAndAccommodation(name, accommodation)) { throw new DuplicateRoomNameException(); @@ -179,18 +187,14 @@ private void updateRoom(Room room, RoomUpdateRequest request) { updateRoomStock(room, request.amount() - room.getAmount()); } room.updateRoom(request.toRoomUpdateDto()); - updateRoomOption(room, request.option().toRoomOptionUpdateDto()); addRoomImages(room, request.addImages()); roomImageRepository.deleteAll(getRoomImages(request.deleteImages())); } private RoomOption updateRoomOption(Room room, RoomOptionUpdate option) { - RoomOption roomOption = getRoomOption(room); + RoomOption roomOption = roomQueryUseCase.findRoomOptionByRoom(room); roomOption.updateRoomOption(option); - em.flush(); - em.refresh(roomOption); - return roomOption; } @@ -233,18 +237,6 @@ private void validateRoomStatus(String status) { } } - private RoomOption saveRoomOption(Room room, RoomOptionRequest request) { - RoomOption saveRoomOption = roomOptionRepository.save(RoomOption.builder() - .room(room) - .tv(request.tv()) - .airCondition(request.airCondition()) - .internet(request.internet()) - .build() - ); - - return saveRoomOption; - } - private void createRoomStock(Room room) { for (int i = 0; i < 30; i++) { roomStockRepository.save(RoomStock.builder() diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomQueryService.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomQueryService.java index 2d61e6f7..b27c999f 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomQueryService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomQueryService.java @@ -17,8 +17,9 @@ import com.backoffice.upjuyanolja.domain.room.entity.RoomOption; import com.backoffice.upjuyanolja.domain.room.entity.RoomStock; import com.backoffice.upjuyanolja.domain.room.exception.RoomNotFoundException; +import com.backoffice.upjuyanolja.domain.room.exception.RoomOptionNotFoundException; import com.backoffice.upjuyanolja.domain.room.exception.RoomStockNotFoundException; -import com.backoffice.upjuyanolja.domain.room.repository.RoomImageRepository; +import com.backoffice.upjuyanolja.domain.room.repository.RoomOptionRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomStockRepository; import com.backoffice.upjuyanolja.domain.room.service.usecase.RoomQueryUseCase; @@ -42,9 +43,25 @@ public class RoomQueryService implements RoomQueryUseCase { private final AccommodationOwnershipRepository accommodationOwnershipRepository; private final RoomRepository roomRepository; private final CouponService couponService; - private final RoomCommandService roomCommandService; + private final RoomOptionRepository roomOptionRepository; private final RoomStockRepository roomStockRepository; + @Override + public List findByAccommodationId(long accommodationId) { + return roomRepository.findByAccommodationId(accommodationId); + } + + @Override + public Room findRoomById(long roomId) { + return roomRepository.findById(roomId).orElseThrow(RoomNotFoundException::new); + } + + @Override + public RoomOption findRoomOptionByRoom(Room room) { + return roomOptionRepository.findByRoom(room) + .orElseThrow(RoomOptionNotFoundException::new); + } + @Override public RoomPageResponse getRooms(long memberId, long accommodationId, Pageable pageable) { Member member = memberGetService.getMemberById(memberId); @@ -61,7 +78,7 @@ public RoomPageResponse getRooms(long memberId, long accommodationId, Pageable p couponDetails.addAll(couponService .getSortedDiscountTypeCouponResponseInRoom(room, coupons, DiscountType.RATE)); - RoomOption option = roomCommandService.getRoomOption(room); + RoomOption option = findRoomOptionByRoom(room); rooms.add(RoomsInfoResponse.of(room, option, couponDetails)); }); @@ -81,7 +98,7 @@ public RoomInfoResponse getRoom(long memberId, long roomId) { Room room = roomRepository.findById(roomId).orElseThrow(RoomNotFoundException::new); checkOwnership(member, room.getAccommodation()); - RoomOption option = roomCommandService.getRoomOption(room); + RoomOption option = findRoomOptionByRoom(room); return RoomInfoResponse.of(room, option); } @@ -100,7 +117,6 @@ public List getFilteredRoomStocksByDate( ) .toList(); } - private void checkOwnership(Member member, Accommodation accommodation) { if (!accommodationOwnershipRepository .existsAccommodationOwnershipByMemberAndAccommodation(member, accommodation)) { @@ -108,11 +124,4 @@ private void checkOwnership(Member member, Accommodation accommodation) { } } - public List findByAccommodationId(long accommodationId) { - return roomRepository.findByAccommodationId(accommodationId); - } - - public Room findRoomById(long roomId) { - return roomRepository.findById(roomId).orElseThrow(RoomNotFoundException::new); - } } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/usecase/RoomQueryUseCase.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/usecase/RoomQueryUseCase.java index d10d8b0c..5aa83ff0 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/usecase/RoomQueryUseCase.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/usecase/RoomQueryUseCase.java @@ -1,25 +1,26 @@ package com.backoffice.upjuyanolja.domain.room.service.usecase; -import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; import com.backoffice.upjuyanolja.domain.room.dto.response.RoomInfoResponse; import com.backoffice.upjuyanolja.domain.room.dto.response.RoomPageResponse; import com.backoffice.upjuyanolja.domain.room.entity.Room; -import com.backoffice.upjuyanolja.domain.room.entity.RoomImage; import com.backoffice.upjuyanolja.domain.room.entity.RoomOption; -import com.backoffice.upjuyanolja.domain.room.entity.RoomPrice; import com.backoffice.upjuyanolja.domain.room.entity.RoomStock; import java.time.LocalDate; -import java.time.LocalTime; import java.util.List; -import lombok.Builder; -import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; public interface RoomQueryUseCase { + Room findRoomById(long roomId); + + List findByAccommodationId(long accommodationId); + + RoomOption findRoomOptionByRoom(Room room); + RoomPageResponse getRooms(long memberId, long accommodationId, Pageable pageable); RoomInfoResponse getRoom(long memberId, long roomId); List getFilteredRoomStocksByDate(Room room, LocalDate startDate, LocalDate endDate); + } diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/docs/CouponBackofficeControllerDocsTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/docs/CouponBackofficeControllerDocsTest.java index d9e4ca5e..bb4982f7 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/docs/CouponBackofficeControllerDocsTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/docs/CouponBackofficeControllerDocsTest.java @@ -738,11 +738,6 @@ private Room createRoom( .build()) .amount(858) .status(RoomStatus.SELLING) - .option(RoomOption.builder() - .airCondition(true) - .tv(true) - .internet(true) - .build()) .images(new ArrayList<>()) .build(); } diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/controller/CouponBackofficeControllerTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/controller/CouponBackofficeControllerTest.java index 2de3c17b..652c5934 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/controller/CouponBackofficeControllerTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/controller/CouponBackofficeControllerTest.java @@ -542,11 +542,6 @@ private Room createRoom( .build()) .amount(858) .status(RoomStatus.SELLING) - .option(RoomOption.builder() - .airCondition(true) - .tv(true) - .internet(true) - .build()) .images(new ArrayList<>()) .build(); } diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/repository/CouponRepositoryTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/repository/CouponRepositoryTest.java index bfc37ec4..5e0314e4 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/repository/CouponRepositoryTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/repository/CouponRepositoryTest.java @@ -257,11 +257,6 @@ private Room createRoom(Long roomId, String roomName, Accommodation mockAccommod .build()) .amount(858) .status(RoomStatus.SELLING) - .option(RoomOption.builder() - .airCondition(true) - .tv(true) - .internet(true) - .build()) .images(new ArrayList<>()) .build(); } diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/service/CouponBackofficeServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/service/CouponBackofficeServiceTest.java index 096f22ea..3d1f2c80 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/service/CouponBackofficeServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/service/CouponBackofficeServiceTest.java @@ -174,11 +174,6 @@ private Room createRoom( .build()) .amount(858) .status(RoomStatus.SELLING) - .option(RoomOption.builder() - .airCondition(true) - .tv(true) - .internet(true) - .build()) .images(new ArrayList<>()) .build(); } diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/docs/ReservationControllerDocsTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/docs/ReservationControllerDocsTest.java index 2b199e14..feb88c0c 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/docs/ReservationControllerDocsTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/docs/ReservationControllerDocsTest.java @@ -130,11 +130,6 @@ private static Room createRoom() { .build()) .amount(858) .status(RoomStatus.SELLING) - .option(RoomOption.builder() - .airCondition(true) - .tv(true) - .internet(true) - .build()) .images(new ArrayList<>()) .build(); return room; diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/controller/ReservationControllerTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/controller/ReservationControllerTest.java index f158ed13..06ab15b5 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/controller/ReservationControllerTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/controller/ReservationControllerTest.java @@ -138,11 +138,6 @@ private static Room createRoom() { .build()) .amount(858) .status(RoomStatus.SELLING) - .option(RoomOption.builder() - .airCondition(true) - .tv(true) - .internet(true) - .build()) .images(new ArrayList<>()) .build(); return room; diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/repository/ReservationRepositoryTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/repository/ReservationRepositoryTest.java index 1d785f04..a6875db8 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/repository/ReservationRepositoryTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/repository/ReservationRepositoryTest.java @@ -139,11 +139,6 @@ private Room createRoom() { .build()) .amount(858) .status(RoomStatus.SELLING) - .option(RoomOption.builder() - .airCondition(true) - .tv(true) - .internet(true) - .build()) .images(new ArrayList<>()) .build(); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationServiceTest.java index fef41f70..9fe851ac 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationServiceTest.java @@ -171,11 +171,6 @@ private static Room createRoom(Long id, RoomStatus status) { .build()) .amount(858) .status(status) - .option(RoomOption.builder() - .airCondition(true) - .tv(true) - .internet(true) - .build()) .images(new ArrayList<>()) .build(); return room; diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationStockServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationStockServiceTest.java index 7d64b50f..20f8bedd 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationStockServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationStockServiceTest.java @@ -127,11 +127,6 @@ private Room createRoom() { .build()) .amount(858) .status(RoomStatus.SELLING) - .option(RoomOption.builder() - .airCondition(true) - .tv(true) - .internet(true) - .build()) .images(new ArrayList<>()) .build(); roomRepository.save(room); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/repository/RoomRepositoryTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/repository/RoomRepositoryTest.java index 9cd1a2cd..8046a688 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/repository/RoomRepositoryTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/repository/RoomRepositoryTest.java @@ -107,11 +107,6 @@ private void saveRoom(Accommodation accommodation) { .build()) .amount(858) .status(RoomStatus.SELLING) - .option(RoomOption.builder() - .airCondition(true) - .tv(true) - .internet(true) - .build()) .images(new ArrayList<>()) .build()); } diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomCommandServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomCommandServiceTest.java index b55adfea..e63b6c27 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomCommandServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomCommandServiceTest.java @@ -32,9 +32,11 @@ import com.backoffice.upjuyanolja.domain.room.entity.RoomStatus; import com.backoffice.upjuyanolja.domain.room.exception.DuplicateRoomNameException; import com.backoffice.upjuyanolja.domain.room.repository.RoomImageRepository; +import com.backoffice.upjuyanolja.domain.room.repository.RoomOptionRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomStockRepository; import com.backoffice.upjuyanolja.domain.room.service.RoomCommandService; +import com.backoffice.upjuyanolja.domain.room.service.usecase.RoomQueryUseCase; import com.backoffice.upjuyanolja.global.exception.NotOwnerException; import jakarta.persistence.EntityManager; import java.time.LocalTime; @@ -60,9 +62,15 @@ public class RoomCommandServiceTest { @Mock private MemberGetService memberGetService; + @Mock + private RoomQueryUseCase roomQueryUseCase; + @Mock private RoomRepository roomRepository; + @Mock + private RoomOptionRepository roomOptionRepository; + @Mock private RoomImageRepository roomImageRepository; @@ -148,14 +156,17 @@ void _willSuccess() { .build()) .amount(858) .status(RoomStatus.SELLING) - .option(RoomOption.builder() - .airCondition(true) - .tv(true) - .internet(true) - .build()) .images(new ArrayList<>()) .build(); + RoomOption roomOption = RoomOption.builder() + .id(1L) + .room(room) + .airCondition(true) + .tv(true) + .internet(true) + .build(); + RoomImage roomImage = RoomImage.builder() .id(1L) .room(room) @@ -178,11 +189,6 @@ void _willSuccess() { .build()) .amount(858) .status(RoomStatus.SELLING) - .option(RoomOption.builder() - .airCondition(true) - .tv(true) - .internet(true) - .build()) .images(List.of(roomImage)) .build(); @@ -199,6 +205,7 @@ void _willSuccess() { .existsRoomByNameAndAccommodation(any(String.class), any(Accommodation.class))) .willReturn(false); given(roomRepository.save(any(Room.class))).willReturn(room); + given(roomOptionRepository.save(any(RoomOption.class))).willReturn(roomOption); given(roomImageRepository.saveAll(any(List.class))).willReturn(List.of(roomImage)); // when @@ -370,14 +377,17 @@ void _willSuccess() { .build()) .amount(858) .status(RoomStatus.SELLING) - .option(RoomOption.builder() - .airCondition(true) - .tv(true) - .internet(true) - .build()) .images(new ArrayList<>()) .build(); + RoomOption roomOption = RoomOption.builder() + .id(1L) + .room(room) + .airCondition(true) + .tv(true) + .internet(true) + .build(); + RoomImage roomImage = RoomImage.builder() .id(1L) .room(room) @@ -400,11 +410,6 @@ void _willSuccess() { .build()) .amount(858) .status(RoomStatus.SELLING) - .option(RoomOption.builder() - .airCondition(true) - .tv(true) - .internet(true) - .build()) .images(List.of(roomImage)) .build(); @@ -413,6 +418,7 @@ void _willSuccess() { any(Accommodation.class))) .willReturn(false); given(roomRepository.save(any(Room.class))).willReturn(room); + given(roomOptionRepository.save(any(RoomOption.class))).willReturn(roomOption); given(roomImageRepository.saveAll(any(List.class))).willReturn(List.of(roomImage)); // when @@ -575,14 +581,17 @@ void _willSuccess() { .build()) .amount(858) .status(RoomStatus.SELLING) - .option(RoomOption.builder() - .airCondition(true) - .tv(true) - .internet(true) - .build()) .images(List.of(roomImage1)) .build(); + RoomOption roomOption = RoomOption.builder() + .id(1L) + .room(room) + .airCondition(true) + .tv(true) + .internet(true) + .build(); + RoomImage roomImage2 = RoomImage.builder() .id(2L) .room(room) @@ -610,16 +619,12 @@ void _willSuccess() { .build()) .amount(858) .status(RoomStatus.STOP_SELLING) - .option(RoomOption.builder() - .airCondition(true) - .tv(true) - .internet(true) - .build()) .images(List.of(roomImage2, roomImage3)) .build(); given(memberGetService.getMemberById(any(Long.TYPE))).willReturn(member); given(roomRepository.findById(any(Long.TYPE))).willReturn(Optional.of(room)); + given(roomQueryUseCase.findRoomOptionByRoom(any(Room.class))).willReturn(roomOption); given(accommodationOwnershipRepository .existsAccommodationOwnershipByMemberAndAccommodation( any(Member.class), @@ -652,6 +657,7 @@ void _willSuccess() { verify(memberGetService, times(1)).getMemberById(any(Long.TYPE)); verify(roomRepository, times(1)).findById(any(Long.TYPE)); + verify(roomQueryUseCase, times(1)).findRoomOptionByRoom(room); verify(accommodationOwnershipRepository, times(1)) .existsAccommodationOwnershipByMemberAndAccommodation( any(Member.class), @@ -720,15 +726,19 @@ void _willSuccess() { .build()) .amount(858) .status(RoomStatus.SELLING) - .option(RoomOption.builder() - .airCondition(true) - .tv(true) - .internet(true) - .build()) .images(List.of(roomImage1)) .build(); + RoomOption roomOption = RoomOption.builder() + .id(1L) + .room(room) + .airCondition(true) + .tv(true) + .internet(true) + .build(); + given(memberGetService.getMemberById(any(Long.TYPE))).willReturn(member); + given(roomQueryUseCase.findRoomOptionByRoom(any(Room.class))).willReturn(roomOption); given(roomRepository.findById(any(Long.TYPE))).willReturn(Optional.of(room)); given(accommodationOwnershipRepository .existsAccommodationOwnershipByMemberAndAccommodation( @@ -759,6 +769,7 @@ void _willSuccess() { verify(memberGetService, times(1)).getMemberById(any(Long.TYPE)); verify(roomRepository, times(1)).findById(any(Long.TYPE)); + verify(roomQueryUseCase, times(1)).findRoomOptionByRoom(room); verify(accommodationOwnershipRepository, times(1)) .existsAccommodationOwnershipByMemberAndAccommodation( any(Member.class), diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomQueryServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomQueryServiceTest.java index c0495c85..472c2a2d 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomQueryServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomQueryServiceTest.java @@ -8,7 +8,6 @@ import static org.mockito.Mockito.verify; import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; -import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationOwnershipRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationRepository; @@ -29,8 +28,8 @@ import com.backoffice.upjuyanolja.domain.room.entity.RoomOption; import com.backoffice.upjuyanolja.domain.room.entity.RoomPrice; import com.backoffice.upjuyanolja.domain.room.entity.RoomStatus; +import com.backoffice.upjuyanolja.domain.room.repository.RoomOptionRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomRepository; -import com.backoffice.upjuyanolja.domain.room.repository.RoomStockRepository; import com.backoffice.upjuyanolja.domain.room.service.RoomQueryService; import java.time.LocalDate; import java.time.LocalTime; @@ -68,7 +67,7 @@ public class RoomQueryServiceTest { private RoomRepository roomRepository; @Mock - private RoomStockRepository roomStockRepository; + private RoomOptionRepository roomOptionRepository; @Mock private CouponService couponService; @@ -130,14 +129,17 @@ void _willSuccess() { .build()) .amount(858) .status(RoomStatus.SELLING) - .option(RoomOption.builder() - .airCondition(true) - .tv(true) - .internet(true) - .build()) .images(new ArrayList<>()) .build(); + RoomOption roomOption = RoomOption.builder() + .id(1L) + .room(room) + .airCondition(true) + .tv(true) + .internet(true) + .build(); + RoomImage roomImage = RoomImage.builder() .id(1L) .room(room) @@ -160,13 +162,17 @@ void _willSuccess() { .build()) .amount(858) .status(RoomStatus.SELLING) - .option(RoomOption.builder() - .airCondition(true) - .tv(true) - .internet(true) - .build()) .images(List.of(roomImage)) .build(); + + RoomOption savedRoomOption = RoomOption.builder() + .id(1L) + .room(room) + .airCondition(true) + .tv(true) + .internet(true) + .build(); + List coupons = List.of( Coupon.builder() .id(1L) @@ -229,6 +235,8 @@ void _willSuccess() { .willReturn(true); given(roomRepository.findAllByAccommodation(any(Long.TYPE), any(Pageable.class))) .willReturn(new PageImpl<>(List.of(savedRoom))); + given(roomOptionRepository.findByRoom(savedRoom)) + .willReturn(Optional.of(savedRoomOption)); given(couponService.getCouponInRoom(any(Room.class))).willReturn(coupons); given(couponService.getSortedDiscountTypeCouponResponseInRoom( any(Room.class), @@ -344,16 +352,21 @@ void _willSuccess() { .build()) .amount(858) .status(RoomStatus.SELLING) - .option(RoomOption.builder() - .airCondition(true) - .tv(true) - .internet(true) - .build()) .images(List.of(roomImage1)) .build(); + RoomOption roomOption = RoomOption.builder() + .id(1L) + .room(room) + .airCondition(true) + .tv(true) + .internet(true) + .build(); + given(memberGetService.getMemberById(any(Long.TYPE))).willReturn(member); given(roomRepository.findById(any(Long.TYPE))).willReturn(Optional.of(room)); + given(roomOptionRepository.findByRoom(room)) + .willReturn(Optional.of(roomOption)); given(accommodationOwnershipRepository .existsAccommodationOwnershipByMemberAndAccommodation( any(Member.class), From fc099a6d8ff99718371f9eed622f42de3e111d5b Mon Sep 17 00:00:00 2001 From: HyunA Date: Sat, 3 Feb 2024 04:43:41 +0900 Subject: [PATCH 09/21] =?UTF-8?q?refactor:=20room=EA=B3=BC=20roomPrice?= =?UTF-8?q?=EC=9D=98=20=EC=9D=BC=EB=8C=80=EC=9D=BC=20=EC=9C=A0=EC=A7=80=20?= =?UTF-8?q?&=20=EC=99=B8=EB=9E=98=ED=82=A4=20=EA=B4=80=EA=B3=84=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/AccommodationInfoResponse.java | 1 - .../service/AccommodationCommandService.java | 8 +-- .../service/AccommodationQueryService.java | 52 ++++++++++------ .../repository/CouponRepositoryImpl.java | 4 +- .../member/service/MemberAuthService.java | 52 ++++++++-------- .../member/service/OwnerAuthService.java | 32 +++++----- .../openapi/service/OpenApiService.java | 56 ++++++++++-------- .../service/ReservationService.java | 13 ++-- .../room/dto/response/RoomInfoResponse.java | 6 +- .../room/dto/response/RoomResponse.java | 11 +--- .../room/dto/response/RoomsInfoResponse.java | 6 +- .../upjuyanolja/domain/room/entity/Room.java | 9 --- .../domain/room/entity/RoomPrice.java | 19 +++++- .../exception/RoomPriceNotFoundException.java | 11 ++++ .../repository/RoomCustomRepositoryImpl.java | 5 +- .../room/repository/RoomPriceRepository.java | 15 +++++ .../room/service/RoomCommandService.java | 59 +++++++++++++------ .../global/exception/ErrorCode.java | 17 +++--- 18 files changed, 227 insertions(+), 149 deletions(-) create mode 100644 src/main/java/com/backoffice/upjuyanolja/domain/room/exception/RoomPriceNotFoundException.java create mode 100644 src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomPriceRepository.java diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationInfoResponse.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationInfoResponse.java index 31548696..0d195a2b 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationInfoResponse.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationInfoResponse.java @@ -3,7 +3,6 @@ import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import com.backoffice.upjuyanolja.domain.room.dto.response.RoomInfoResponse; -import java.util.ArrayList; import java.util.List; import lombok.Builder; diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java index 73330c23..493ebb7c 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java @@ -4,13 +4,11 @@ import com.backoffice.upjuyanolja.domain.accommodation.dto.request.AccommodationOptionRequest; import com.backoffice.upjuyanolja.domain.accommodation.dto.request.AccommodationRegisterRequest; import com.backoffice.upjuyanolja.domain.accommodation.dto.response.AccommodationInfoResponse; -import com.backoffice.upjuyanolja.domain.accommodation.dto.response.AccommodationOptionResponse; import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOwnership; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.accommodation.exception.AccommodationImageNotExistsException; -import com.backoffice.upjuyanolja.domain.accommodation.exception.AccommodationNotFoundException; import com.backoffice.upjuyanolja.domain.accommodation.exception.WrongCategoryException; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationImageRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationOptionRepository; @@ -36,13 +34,15 @@ @RequiredArgsConstructor public class AccommodationCommandService implements AccommodationCommandUseCase { - private final MemberGetService memberGetService; private final AccommodationRepository accommodationRepository; private final AccommodationOptionRepository accommodationOptionRepository; private final CategoryRepository categoryRepository; private final AccommodationOwnershipRepository accommodationOwnershipRepository; private final AccommodationImageRepository accommodationImageRepository; + + private final MemberGetService memberGetService; private final RoomCommandService roomCommandService; + private final EntityManager em; @Override @@ -84,7 +84,7 @@ public AccommodationInfoResponse createAccommodation( em.refresh(accommodation); em.refresh(option); - List room = roomCommandService.getRoomsInAccommodation(accommodation); + List room = roomCommandService.getRoomInfoResponses(accommodation); return AccommodationInfoResponse.of(accommodation, option, room); } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationQueryService.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationQueryService.java index beadb24d..c4626b5e 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationQueryService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationQueryService.java @@ -109,14 +109,22 @@ public AccommodationDetailResponse findAccommodationWithRooms( getMainCouponName(accommodationId), AccommodationOptionResponse.of(accommodationOption), accommodation.getRooms().stream() - .map(room -> RoomResponse.of( - room, - roomQueryUseCase.findRoomOptionByRoom(room), - getDiscountPrice(room), - !checkSoldOut(filterRooms, room), - getMinFilteredRoomStock(room, startDate, endDate), - couponService.getSortedTotalCouponResponseInRoom(room) - ) + .map(room -> { + int roomPrice = roomQueryUseCase.findRoomPriceByRoom(room) + .getOffWeekDaysMinFee(); + + return RoomResponse.of( + room, + roomQueryUseCase.findRoomOptionByRoom(room), + roomQueryUseCase.findRoomPriceByRoom(room).getOffWeekDaysMinFee(), + getDiscountPrice(room, roomPrice), + !checkSoldOut(filterRooms, room), + getMinFilteredRoomStock(room, startDate, endDate), + couponService.getSortedTotalCouponResponseInRoom( + room, roomPrice + ) + ); + } ) .toList() ); @@ -168,7 +176,7 @@ private int getLowestPrice(Long accommodationId) { PriorityQueue pq = new PriorityQueue<>(Comparator.comparingInt(i -> i)); for (Room room : rooms) { - pq.offer(room.getPrice().getOffWeekDaysMinFee()); + pq.offer(roomQueryUseCase.findRoomPriceByRoom(room).getOffWeekDaysMinFee()); } return pq.poll(); @@ -182,11 +190,13 @@ private Optional getDiscountInfo(Long accommodationId) { for (Room room : rooms) { coupons = couponService.getCouponInRoom(room); responses.addAll( - couponService.getSortedDiscountTypeCouponResponseInRoom(room, coupons, - DiscountType.FLAT)); + couponService.getSortedDiscountTypeCouponResponseInRoom( + room, roomQueryUseCase.findRoomPriceByRoom(room).getOffWeekDaysMinFee(), + coupons, DiscountType.FLAT)); responses.addAll( - couponService.getSortedDiscountTypeCouponResponseInRoom(room, coupons, - DiscountType.RATE)); + couponService.getSortedDiscountTypeCouponResponseInRoom( + room, roomQueryUseCase.findRoomPriceByRoom(room).getOffWeekDaysMinFee(), + coupons, DiscountType.RATE)); } return responses.stream() @@ -195,8 +205,13 @@ private Optional getDiscountInfo(Long accommodationId) { private String getMainCouponName(Long accommodationId) { List rooms = roomQueryUseCase.findByAccommodationId(accommodationId); - String flatName = couponService.getDiscountTypeMainRoomCouponName(rooms, DiscountType.FLAT); - String rateName = couponService.getDiscountTypeMainRoomCouponName(rooms, DiscountType.RATE); + + String flatName = couponService.getDiscountTypeMainRoomCouponName( + rooms, DiscountType.FLAT, roomQueryUseCase.getMinRoomPriceWithRoom(rooms) + ); + String rateName = couponService.getDiscountTypeMainRoomCouponName( + rooms, DiscountType.RATE, roomQueryUseCase.getMinRoomPriceWithRoom(rooms) + ); if (flatName.isEmpty() && rateName.isEmpty()) { return ""; @@ -216,12 +231,11 @@ public Accommodation findAccommodationByRoomId(long roomId) { } - private int getDiscountPrice(Room room) { - return couponService.getSortedTotalCouponResponseInRoom(room) - .stream() + private int getDiscountPrice(Room room, int roomPrice) { + return couponService.getSortedTotalCouponResponseInRoom(room, roomPrice).stream() .findFirst() .map(coupon -> coupon.price()) - .orElse(room.getPrice().getOffWeekDaysMinFee()); + .orElse(roomPrice); } private List getFilteredRoomsByDate( diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/coupon/repository/CouponRepositoryImpl.java b/src/main/java/com/backoffice/upjuyanolja/domain/coupon/repository/CouponRepositoryImpl.java index b169ff2b..f5736e4d 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/coupon/repository/CouponRepositoryImpl.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/coupon/repository/CouponRepositoryImpl.java @@ -31,7 +31,7 @@ public List findRoomsByAccommodationId(Long accommodationId) )) .from(qRoom) .leftJoin(qAccommodation).on(qRoom.accommodation.id.eq(qAccommodation.id)) - .innerJoin(qRoomPrice).on(qRoom.price.id.eq(qRoomPrice.id)) + .innerJoin(qRoomPrice).on(qRoom.eq(qRoomPrice.room)) .where(qAccommodation.id.eq(accommodationId) .and(qAccommodation.deletedAt.isNull() .and(qRoom.deletedAt.isNull())) @@ -68,7 +68,7 @@ public List findCouponsByAccommodationId(Long accommodatio .from(qCoupon) .join(qRoom).on(qCoupon.room.id.eq(qRoom.id)) .join(qAccommodation).on(qRoom.accommodation.id.eq(qAccommodation.id)) - .join(qRoomPrice).on(qRoom.price.id.eq(qRoomPrice.id)) + .join(qRoomPrice).on(qRoom.eq(qRoomPrice.room)) .where(qAccommodation.id.eq(accommodationId) .and(qAccommodation.deletedAt.isNull() .and(qRoom.deletedAt.isNull())) diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/member/service/MemberAuthService.java b/src/main/java/com/backoffice/upjuyanolja/domain/member/service/MemberAuthService.java index 12749132..8d4865bd 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/member/service/MemberAuthService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/member/service/MemberAuthService.java @@ -37,7 +37,7 @@ public class MemberAuthService implements AuthServiceProvider()) .amount(Integer.parseInt(roomJson.getString("roomcount"))) .status(RoomStatus.SELLING) @@ -369,6 +347,8 @@ private void saveRooms( } saveRoomOption(room, roomJson); + saveRoomPrice(room, roomJson); + } } } @@ -383,6 +363,34 @@ private void saveRoomOption(Room room, JSONObject roomJson) { ); } + private void saveRoomPrice(Room room, JSONObject roomJson){ + int offWeekDaysMinFee = Integer.parseInt( + roomJson.getString("roomoffseasonminfee1")) == 0 ? DEFAULT_PRICE + : Integer.parseInt( + roomJson.getString("roomoffseasonminfee1")); + int offWeekendMinFee = Math.max(Integer.parseInt( + roomJson.getString("roomoffseasonminfee2")) == 0 ? DEFAULT_PRICE + : Integer.parseInt( + roomJson.getString("roomoffseasonminfee2")), offWeekDaysMinFee); + int peakWeekDaysMinFee = Math.max(Integer.parseInt( + roomJson.getString("roompeakseasonminfee1")) == 0 ? DEFAULT_PRICE + : Integer.parseInt( + roomJson.getString("roompeakseasonminfee1")), offWeekendMinFee); + int peakWeekendMinFee = Math.max(Integer.parseInt( + roomJson.getString("roompeakseasonminfee2")) == 0 ? DEFAULT_PRICE + : Integer.parseInt( + roomJson.getString("roompeakseasonminfee2")), peakWeekDaysMinFee); + + roomPriceRepository.save(RoomPrice.builder() + .room(room) + .offWeekDaysMinFee(offWeekDaysMinFee) + .offWeekendMinFee(offWeekendMinFee) + .peakWeekDaysMinFee(peakWeekDaysMinFee) + .peakWeekendMinFee(peakWeekendMinFee) + .build()); + + } + private boolean isEmpty(JSONObject body) throws JSONException { return body.getInt("totalCount") == 0; } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/reservation/service/ReservationService.java b/src/main/java/com/backoffice/upjuyanolja/domain/reservation/service/ReservationService.java index 91416d57..f0ab9878 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/reservation/service/ReservationService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/reservation/service/ReservationService.java @@ -26,8 +26,10 @@ import com.backoffice.upjuyanolja.domain.room.entity.RoomStatus; import com.backoffice.upjuyanolja.domain.room.entity.RoomStock; import com.backoffice.upjuyanolja.domain.room.repository.RoomRepository; +import com.backoffice.upjuyanolja.domain.room.service.RoomCommandService; import com.backoffice.upjuyanolja.domain.room.service.RoomQueryService; import com.backoffice.upjuyanolja.domain.room.service.usecase.RoomCommandUseCase; +import com.backoffice.upjuyanolja.domain.room.service.usecase.RoomQueryUseCase; import java.time.LocalDate; import java.time.Period; import java.util.ArrayList; @@ -52,8 +54,7 @@ public class ReservationService { private final ReservationRoomRepository reservationRoomRepository; private final ReservationRepository reservationRepository; - private final RoomCommandUseCase roomCommandUseCase; - private final RoomQueryService roomQueryService; + private final RoomQueryUseCase roomQueryUseCase; private final ReservationStockService stockService; @Transactional @@ -73,7 +74,7 @@ public void create(Member currentMember, CreateReservationRequest request) { // 할인 금액 계산 int totalAmount = getValidTotalAmount(request.getTotalPrice(), - room.getPrice().getOffWeekDaysMinFee(), coupon); + roomQueryUseCase.findRoomPriceByRoom(room).getOffWeekDaysMinFee(), coupon); /* * 객실 재고 차감 @@ -136,7 +137,7 @@ private Coupon getValidCoupon(CreateReservationRequest request, Room room) { private List getRoomStock(Room room, LocalDate startDate, LocalDate endDate) { int daysCount = Period.between(startDate, endDate).getDays() + 1; - List roomStocks = roomQueryService.getFilteredRoomStocksByDate(room, + List roomStocks = roomQueryUseCase.getFilteredRoomStocksByDate(room, startDate, endDate); if (roomStocks.size() != daysCount || @@ -207,7 +208,7 @@ private ReservationRoom saveReservationRoom(CreateReservationRequest request, Ro .room(room) .startDate(request.getStartDate()) .endDate(request.getEndDate()) - .price(room.getPrice().getOffWeekDaysMinFee()) + .price(roomQueryUseCase.findRoomPriceByRoom(room).getOffWeekDaysMinFee()) .build()); } @@ -297,7 +298,7 @@ private List getReservationRoomStock(Room room, LocalDate startDate, LocalDate endDate) { int daysCount = Period.between(startDate, endDate).getDays() + 1; - List roomStocks = roomQueryService.getFilteredRoomStocksByDate(room, + List roomStocks = roomQueryUseCase.getFilteredRoomStocksByDate(room, startDate, endDate); if (roomStocks.size() != daysCount) { diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomInfoResponse.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomInfoResponse.java index 869b97ab..876fa725 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomInfoResponse.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomInfoResponse.java @@ -21,7 +21,9 @@ public record RoomInfoResponse( RoomOptionResponse option ) { - public static RoomInfoResponse of(Room room, RoomOption option) { + public static RoomInfoResponse of( + Room room, RoomOption option, int price + ) { return RoomInfoResponse.builder() .id(room.getId()) .name(room.getName()) @@ -29,7 +31,7 @@ public static RoomInfoResponse of(Room room, RoomOption option) { .maxCapacity(room.getMaxCapacity()) .checkInTime(room.getCheckInTime().format(DateTimeFormatter.ofPattern("HH:mm"))) .checkOutTime(room.getCheckOutTime().format(DateTimeFormatter.ofPattern("HH:mm"))) - .price(room.getPrice().getOffWeekDaysMinFee()) + .price(price) .amount(room.getAmount()) .status(room.getStatus().name()) .images(RoomImageResponse.of(room.getImages())) diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomResponse.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomResponse.java index b5de2551..d4725db8 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomResponse.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomResponse.java @@ -26,21 +26,14 @@ public record RoomResponse( ) { public static RoomResponse of( - Room room, RoomOption option, int discountPrice, + Room room, RoomOption option, int roomPrice, int discountPrice, boolean soldOut, int count, List coupons ) { return RoomResponse.builder() .id(room.getId()) .name(room.getName()) - .basePrice( - Stream.of( - room.getPrice().getOffWeekDaysMinFee(), - room.getPrice().getOffWeekendMinFee(), - room.getPrice().getPeakWeekDaysMinFee(), - room.getPrice().getPeakWeekendMinFee()) - .reduce(Math::min).orElse(0) - ) + .basePrice(roomPrice) .discountPrice(discountPrice) .defaultCapacity(room.getDefaultCapacity()) .maxCapacity(room.getMaxCapacity()) diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomsInfoResponse.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomsInfoResponse.java index f9389d34..6635ddcb 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomsInfoResponse.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomsInfoResponse.java @@ -27,13 +27,13 @@ public record RoomsInfoResponse( ) { public static RoomsInfoResponse of( - Room room, RoomOption option, List coupons + Room room, RoomOption option, List coupons, int roomPrice ) { PriorityQueue pq = new PriorityQueue<>(Comparator.comparingInt(i -> i)); for (CouponDetailResponse coupon : coupons) { pq.offer(coupon.price()); } - int discountPrice = pq.isEmpty() ? room.getPrice().getOffWeekDaysMinFee() : pq.poll(); + int discountPrice = pq.isEmpty() ? roomPrice : pq.poll(); return RoomsInfoResponse.builder() .id(room.getId()) @@ -42,7 +42,7 @@ public static RoomsInfoResponse of( .maxCapacity(room.getMaxCapacity()) .checkInTime(room.getCheckInTime().format(DateTimeFormatter.ofPattern("HH:mm"))) .checkOutTime(room.getCheckOutTime().format(DateTimeFormatter.ofPattern("HH:mm"))) - .basePrice(room.getPrice().getOffWeekDaysMinFee()) + .basePrice(roomPrice) .discountPrice(discountPrice) .amount(room.getAmount()) .status(room.getStatus().name()) diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/entity/Room.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/entity/Room.java index 40ec1d6e..31c7c502 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/entity/Room.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/entity/Room.java @@ -16,7 +16,6 @@ import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; -import jakarta.persistence.OneToOne; import java.time.LocalDateTime; import java.time.LocalTime; import java.util.ArrayList; @@ -62,7 +61,6 @@ public class Room extends BaseTime { @Comment("객실 체크 아웃 시간") private LocalTime checkOutTime; - @Column(nullable = false) @Comment("객실 개수") private int amount; @@ -72,10 +70,6 @@ public class Room extends BaseTime { @Comment("객실 상태") private RoomStatus status; - @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) - @Comment("객실 가격") - private RoomPrice price; - @OneToMany(mappedBy = "room", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) @Comment("객실 이미지 식별자") private List images = new ArrayList<>(); @@ -91,7 +85,6 @@ public Room( int amount, LocalTime checkInTime, LocalTime checkOutTime, - RoomPrice price, RoomStatus status, List images ) { @@ -103,7 +96,6 @@ public Room( this.amount = amount; this.checkInTime = checkInTime; this.checkOutTime = checkOutTime; - this.price = price; this.status = status; this.images = images; } @@ -111,7 +103,6 @@ public Room( public void updateRoom(RoomUpdate request) { this.name = request.name(); this.status = RoomStatus.valueOf(request.status()); - this.price.updateRoomPrice(request.price()); this.defaultCapacity = request.defaultCapacity(); this.maxCapacity = request.maxCapacity(); this.checkInTime = DateTimeParser.timeParser(request.checkInTime()); diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/entity/RoomPrice.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/entity/RoomPrice.java index 5fbc79d0..e135b2db 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/entity/RoomPrice.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/entity/RoomPrice.java @@ -1,10 +1,15 @@ package com.backoffice.upjuyanolja.domain.room.entity; +import com.backoffice.upjuyanolja.global.common.entity.BaseTime; +import jakarta.persistence.CascadeType; import jakarta.persistence.Column; import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; +import jakarta.persistence.OneToOne; +import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; @@ -14,13 +19,17 @@ @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @Entity -public class RoomPrice { +public class RoomPrice extends BaseTime { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Comment("객실 가격 식별자") private Long id; + @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) + @Comment("객실 식별자") + private Room room; + @Column(nullable = false) @Comment("비수기 주중 최소 가격") private int offWeekDaysMinFee; @@ -40,12 +49,14 @@ public class RoomPrice { @Builder private RoomPrice( Long id, + Room room, int offWeekDaysMinFee, int offWeekendMinFee, int peakWeekDaysMinFee, int peakWeekendMinFee ) { this.id = id; + this.room = room; this.offWeekDaysMinFee = offWeekDaysMinFee; this.offWeekendMinFee = offWeekendMinFee; this.peakWeekDaysMinFee = peakWeekDaysMinFee; @@ -58,4 +69,10 @@ public void updateRoomPrice(int price) { this.peakWeekDaysMinFee = price; this.peakWeekendMinFee = price; } + + @Override + public void delete(LocalDateTime currentTime) { + super.delete(currentTime); + } + } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/exception/RoomPriceNotFoundException.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/exception/RoomPriceNotFoundException.java new file mode 100644 index 00000000..00c156f2 --- /dev/null +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/exception/RoomPriceNotFoundException.java @@ -0,0 +1,11 @@ +package com.backoffice.upjuyanolja.domain.room.exception; + +import com.backoffice.upjuyanolja.global.exception.ApplicationException; +import com.backoffice.upjuyanolja.global.exception.ErrorCode; + +public class RoomPriceNotFoundException extends ApplicationException { + + public RoomPriceNotFoundException() { + super(ErrorCode.ROOM_PRICE_NOT_FOUND); + } +} diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomCustomRepositoryImpl.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomCustomRepositoryImpl.java index bc01d9a6..eec48722 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomCustomRepositoryImpl.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomCustomRepositoryImpl.java @@ -27,7 +27,9 @@ public class RoomCustomRepositoryImpl implements RoomCustomRepository { private final JPAQueryFactory queryFactory; - RoomCustomRepositoryImpl(JPAQueryFactory jpaQueryFactory) { + RoomCustomRepositoryImpl( + JPAQueryFactory jpaQueryFactory + ) { this.queryFactory = jpaQueryFactory; } @@ -84,7 +86,6 @@ private BooleanBuilder createExistsSearchConditionsBuilder( private List> getAllOrderSpecifiers() { List> orders = new LinkedList<>(); orders.add(QueryDslUtil.getSortedColumn(Order.ASC, room, "status")); - orders.add(QueryDslUtil.getSortedColumn(Order.ASC, room.price, "offWeekDaysMinFee")); orders.add(QueryDslUtil.getSortedColumn(Order.ASC, room, "id")); return orders; } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomPriceRepository.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomPriceRepository.java new file mode 100644 index 00000000..c52d04f3 --- /dev/null +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomPriceRepository.java @@ -0,0 +1,15 @@ +package com.backoffice.upjuyanolja.domain.room.repository; + +import com.backoffice.upjuyanolja.domain.room.entity.Room; +import com.backoffice.upjuyanolja.domain.room.entity.RoomPrice; +import com.backoffice.upjuyanolja.domain.room.entity.RoomStock; +import java.time.LocalDate; +import java.util.List; +import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface RoomPriceRepository extends JpaRepository { + + Optional findByRoom(Room room); + +} diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomCommandService.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomCommandService.java index 15d6ae71..34dda12c 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomCommandService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomCommandService.java @@ -26,8 +26,9 @@ import com.backoffice.upjuyanolja.domain.room.exception.RoomImageNotFoundException; import com.backoffice.upjuyanolja.domain.room.exception.RoomNotFoundException; import com.backoffice.upjuyanolja.domain.room.repository.RoomImageRepository; -import com.backoffice.upjuyanolja.domain.room.repository.RoomOptionRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomRepository; +import com.backoffice.upjuyanolja.domain.room.repository.RoomOptionRepository; +import com.backoffice.upjuyanolja.domain.room.repository.RoomPriceRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomStockRepository; import com.backoffice.upjuyanolja.domain.room.service.usecase.RoomCommandUseCase; import com.backoffice.upjuyanolja.domain.room.service.usecase.RoomQueryUseCase; @@ -47,14 +48,17 @@ @RequiredArgsConstructor public class RoomCommandService implements RoomCommandUseCase { - private final MemberGetService memberGetService; private final RoomRepository roomRepository; private final RoomImageRepository roomImageRepository; private final RoomOptionRepository roomOptionRepository; + private final RoomPriceRepository roomPriceRepository; private final RoomStockRepository roomStockRepository; private final AccommodationRepository accommodationRepository; private final AccommodationOwnershipRepository accommodationOwnershipRepository; + + private final MemberGetService memberGetService; private final RoomQueryUseCase roomQueryUseCase; + private final EntityManager em; @Override @@ -81,12 +85,6 @@ public RoomInfoResponse saveRoom(Accommodation accommodation, RoomRegisterReques .accommodation(accommodation) .name(request.name()) .status(RoomStatus.SELLING) - .price(RoomPrice.builder() - .offWeekDaysMinFee(request.price()) - .offWeekendMinFee(request.price()) - .peakWeekDaysMinFee(request.price()) - .peakWeekendMinFee(request.price()) - .build()) .defaultCapacity(request.defaultCapacity()) .maxCapacity(request.maxCapacity()) .checkInTime(DateTimeParser.timeParser(request.checkInTime())) @@ -102,8 +100,9 @@ public RoomInfoResponse saveRoom(Accommodation accommodation, RoomRegisterReques createRoomStock(room); RoomOption roomOption = saveRoomOption(room, request.option()); + RoomPrice roomPrice = saveRoomPrice(room, request.price()); - return RoomInfoResponse.of(room, roomOption); + return RoomInfoResponse.of(room, roomOption, roomPrice.getOffWeekDaysMinFee()); } public RoomOption saveRoomOption(Room room, RoomOptionRequest request) { @@ -118,6 +117,19 @@ public RoomOption saveRoomOption(Room room, RoomOptionRequest request) { return saveRoomOption; } + private RoomPrice saveRoomPrice(Room room, int price) { + RoomPrice saveRoomPrice = roomPriceRepository.save(RoomPrice.builder() + .room(room) + .offWeekDaysMinFee(price) + .offWeekendMinFee(price) + .peakWeekDaysMinFee(price) + .peakWeekendMinFee(price) + .build() + ); + + return saveRoomPrice; + } + @Override public RoomInfoResponse modifyRoom(long memberId, long roomId, RoomUpdateRequest request) { Member member = memberGetService.getMemberById(memberId); @@ -130,14 +142,16 @@ public RoomInfoResponse modifyRoom(long memberId, long roomId, RoomUpdateRequest checkOwnership(member, room.getAccommodation()); updateRoom(room, request); - RoomOption roomOption = updateRoomOption(room, request.option().toRoomOptionUpdateDto()); + RoomPrice roomPrice = updateRoomPrice(room, request.price()); + em.flush(); em.refresh(room); em.refresh(roomOption); + em.refresh(roomPrice); - return RoomInfoResponse.of(room, roomOption); + return RoomInfoResponse.of(room, roomOption, roomPrice.getOffWeekDaysMinFee()); } @Override @@ -152,21 +166,24 @@ public RoomInfoResponse deleteRoom(long memberId, long roomId) { RoomOption roomOption = roomQueryUseCase.findRoomOptionByRoom(room); roomOption.delete(LocalDateTime.now()); + RoomPrice roomPrice = roomQueryUseCase.findRoomPriceByRoom(room); + roomPrice.delete(LocalDateTime.now()); - return RoomInfoResponse.of(room, roomOption); + return RoomInfoResponse.of(room, roomOption, roomPrice.getOffWeekDaysMinFee()); } @Transactional(readOnly = true) - public List getRoomsInAccommodation(Accommodation accommodation) { - List rooms = new ArrayList<>(); + public List getRoomInfoResponses(Accommodation accommodation) { + List roomInfoResponses = new ArrayList<>(); accommodation.getRooms() .forEach(room -> { - RoomOption option = roomQueryUseCase.findRoomOptionByRoom(room); - rooms.add(RoomInfoResponse.of(room, option)); + RoomOption option = roomQueryUseCase.findRoomOptionByRoom(room); + int roomPrice = roomQueryUseCase.findRoomPriceByRoom(room).getOffWeekDaysMinFee(); + roomInfoResponses.add(RoomInfoResponse.of(room, option, roomPrice)); } ); - return rooms; + return roomInfoResponses; } private void validateRoomName(String name, Accommodation accommodation) { @@ -198,6 +215,14 @@ private RoomOption updateRoomOption(Room room, RoomOptionUpdate option) { return roomOption; } + private RoomPrice updateRoomPrice(Room room, int price) { + RoomPrice roomPrice = roomQueryUseCase.findRoomPriceByRoom(room); + roomPrice.updateRoomPrice(price); + roomPriceRepository.save(roomPrice); + + return roomPrice; + } + private void updateRoomStock(Room room, int quantity) { List stocks = roomStockRepository .findAllByRoomAndDateAfter(room, LocalDate.now().minusDays(1)); diff --git a/src/main/java/com/backoffice/upjuyanolja/global/exception/ErrorCode.java b/src/main/java/com/backoffice/upjuyanolja/global/exception/ErrorCode.java index 96e95f81..310effb4 100644 --- a/src/main/java/com/backoffice/upjuyanolja/global/exception/ErrorCode.java +++ b/src/main/java/com/backoffice/upjuyanolja/global/exception/ErrorCode.java @@ -34,14 +34,15 @@ public enum ErrorCode { // Room ROOM_NOT_FOUND(HttpStatus.NOT_FOUND, 3000, "객실 정보를 찾을 수 없습니다."), ROOM_OPTION_NOT_FOUND(HttpStatus.NOT_FOUND, 3001, "객실 옵션 정보를 찾을 수 없습니다."), - DUPLICATED_ROOM_NAME(HttpStatus.BAD_REQUEST, 3002, "중복된 객실 이름입니다."), - INVALID_TIME_FORMAT(HttpStatus.BAD_REQUEST, 3003, "올바르지 않은 형식의 시간입니다.(HH:mm)"), - INVALID_ROOM_STATUS(HttpStatus.BAD_REQUEST, 3004, "올바르지 않은 형식의 객실 상태입니다."), - ROOM_STOCK_NOT_FOUND(HttpStatus.NOT_FOUND, 3005, "객실 재고 정보를 찾을 수 없습니다."), - ROOM_IMAGE_NOT_FOUND(HttpStatus.NOT_FOUND, 3006, "객실 이미지 정보를 찾을 수 없습니다."), - ROOM_NOT_EXISTS(HttpStatus.BAD_REQUEST, 3007, "객실을 1개 이상 등록해야 합니다."), - ROOM_IMAGE_NOT_EXISTS(HttpStatus.BAD_REQUEST, 3008, "객실 이미지를 1개 이상 등록해야 합니다."), - LAST_ROOM(HttpStatus.BAD_REQUEST, 3009, "마지막 객실은 삭제할 수 없습니다."), + ROOM_PRICE_NOT_FOUND(HttpStatus.NOT_FOUND, 3002, "객실 가격 정보를 찾을 수 없습니다."), + DUPLICATED_ROOM_NAME(HttpStatus.BAD_REQUEST, 3003, "중복된 객실 이름입니다."), + INVALID_TIME_FORMAT(HttpStatus.BAD_REQUEST, 3004, "올바르지 않은 형식의 시간입니다.(HH:mm)"), + INVALID_ROOM_STATUS(HttpStatus.BAD_REQUEST, 3005, "올바르지 않은 형식의 객실 상태입니다."), + ROOM_STOCK_NOT_FOUND(HttpStatus.NOT_FOUND, 3006, "객실 재고 정보를 찾을 수 없습니다."), + ROOM_IMAGE_NOT_FOUND(HttpStatus.NOT_FOUND, 3007, "객실 이미지 정보를 찾을 수 없습니다."), + ROOM_NOT_EXISTS(HttpStatus.BAD_REQUEST, 3008, "객실을 1개 이상 등록해야 합니다."), + ROOM_IMAGE_NOT_EXISTS(HttpStatus.BAD_REQUEST, 3009, "객실 이미지를 1개 이상 등록해야 합니다."), + LAST_ROOM(HttpStatus.BAD_REQUEST, 3010, "마지막 객실은 삭제할 수 없습니다."), // Reservation RESERVATION_PAYMENT_FAILED(HttpStatus.BAD_REQUEST, 4000, "결제에 실패 했습니다."), From 7b6fa40cd6033ea7fbc7019620147185e34554f7 Mon Sep 17 00:00:00 2001 From: HyunA Date: Sat, 3 Feb 2024 04:44:41 +0900 Subject: [PATCH 10/21] =?UTF-8?q?fix:=20CouponService=EC=99=80=20RoomQuery?= =?UTF-8?q?Service(RoomQueryUseCase)=EC=9D=98=20=EC=88=9C=ED=99=98=20?= =?UTF-8?q?=EC=B0=B8=EC=A1=B0=20=ED=95=B4=EA=B2=B0=20=ED=95=98=EA=B8=B0=20?= =?UTF-8?q?=EC=9C=84=ED=95=9C=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EB=B0=8F=20=EA=B8=B0=EC=A1=B4=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=EC=9D=98=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/coupon/service/CouponService.java | 14 ++--- .../domain/room/service/RoomQueryService.java | 51 ++++++++++++++++--- .../service/usecase/RoomQueryUseCase.java | 6 +++ 3 files changed, 56 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/coupon/service/CouponService.java b/src/main/java/com/backoffice/upjuyanolja/domain/coupon/service/CouponService.java index c381e5fc..1ed40567 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/coupon/service/CouponService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/coupon/service/CouponService.java @@ -9,11 +9,11 @@ import com.backoffice.upjuyanolja.domain.coupon.repository.CouponRepository; import com.backoffice.upjuyanolja.domain.room.entity.Room; import com.backoffice.upjuyanolja.domain.room.repository.RoomRepository; -import com.backoffice.upjuyanolja.domain.room.service.usecase.RoomQueryUseCase; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; +import java.util.Map; import java.util.TreeMap; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; @@ -48,13 +48,12 @@ public List findCouponResponseInAccommodation( } public List getSortedDiscountTypeCouponResponseInRoom( - Room room, List coupons, DiscountType discountType + Room room, int roomPrice, List coupons, DiscountType discountType ) { List responses = new ArrayList<>(); List discountTypeCouponInRoom = getDiscountTypeCouponInRoom(coupons, discountType); List resultCoupons = new ArrayList<>(); - int roomPrice = room.getPrice().getOffWeekDaysMinFee(); if (discountTypeCouponInRoom.isEmpty()) { return new ArrayList<>(); @@ -80,9 +79,8 @@ public List getCouponInRoom(Room room) { } @Transactional(readOnly = true) - public List getSortedTotalCouponResponseInRoom(Room room) { + public List getSortedTotalCouponResponseInRoom(Room room, int roomPrice) { List roomCoupons = couponRepository.findByRoom(room); - int roomPrice = room.getPrice().getOffWeekDaysMinFee(); if (roomCoupons.isEmpty()) { return new ArrayList<>(); @@ -105,11 +103,13 @@ public List getSortedTotalCouponResponseInRoom(Room room) } @Transactional(readOnly = true) - public String getDiscountTypeMainRoomCouponName(List rooms, DiscountType discountType) { + public String getDiscountTypeMainRoomCouponName( + List rooms, DiscountType discountType, Map priceRoomMap + ) { TreeMap result = new TreeMap<>(Comparator.reverseOrder()); for (Room room : rooms) { - int roomPrice = room.getPrice().getOffWeekDaysMinFee(); + int roomPrice = priceRoomMap.get(room); List coupons = getDiscountTypeCouponInRoom( getCouponInRoom(room), discountType ); diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomQueryService.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomQueryService.java index b27c999f..a26a28bd 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomQueryService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomQueryService.java @@ -15,18 +15,23 @@ import com.backoffice.upjuyanolja.domain.room.dto.response.RoomsInfoResponse; import com.backoffice.upjuyanolja.domain.room.entity.Room; import com.backoffice.upjuyanolja.domain.room.entity.RoomOption; +import com.backoffice.upjuyanolja.domain.room.entity.RoomPrice; import com.backoffice.upjuyanolja.domain.room.entity.RoomStock; import com.backoffice.upjuyanolja.domain.room.exception.RoomNotFoundException; import com.backoffice.upjuyanolja.domain.room.exception.RoomOptionNotFoundException; +import com.backoffice.upjuyanolja.domain.room.exception.RoomPriceNotFoundException; import com.backoffice.upjuyanolja.domain.room.exception.RoomStockNotFoundException; import com.backoffice.upjuyanolja.domain.room.repository.RoomOptionRepository; +import com.backoffice.upjuyanolja.domain.room.repository.RoomPriceRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomStockRepository; import com.backoffice.upjuyanolja.domain.room.service.usecase.RoomQueryUseCase; import com.backoffice.upjuyanolja.global.exception.NotOwnerException; import java.time.LocalDate; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -38,14 +43,16 @@ @RequiredArgsConstructor public class RoomQueryService implements RoomQueryUseCase { - private final MemberGetService memberGetService; private final AccommodationRepository accommodationRepository; private final AccommodationOwnershipRepository accommodationOwnershipRepository; private final RoomRepository roomRepository; - private final CouponService couponService; private final RoomOptionRepository roomOptionRepository; + private final RoomPriceRepository roomPriceRepository; private final RoomStockRepository roomStockRepository; + private final MemberGetService memberGetService; + private final CouponService couponService; + @Override public List findByAccommodationId(long accommodationId) { return roomRepository.findByAccommodationId(accommodationId); @@ -62,6 +69,12 @@ public RoomOption findRoomOptionByRoom(Room room) { .orElseThrow(RoomOptionNotFoundException::new); } + @Override + public RoomPrice findRoomPriceByRoom(Room room) { + return roomPriceRepository.findByRoom(room) + .orElseThrow(RoomPriceNotFoundException::new); + } + @Override public RoomPageResponse getRooms(long memberId, long accommodationId, Pageable pageable) { Member member = memberGetService.getMemberById(memberId); @@ -73,14 +86,22 @@ public RoomPageResponse getRooms(long memberId, long accommodationId, Pageable p roomPage.get().forEach(room -> { List couponDetails = new ArrayList<>(); List coupons = couponService.getCouponInRoom(room); + RoomOption option = findRoomOptionByRoom(room); + int roomPrice = findRoomPriceByRoom(room).getOffWeekDaysMinFee(); + couponDetails.addAll(couponService - .getSortedDiscountTypeCouponResponseInRoom(room, coupons, DiscountType.FLAT)); + .getSortedDiscountTypeCouponResponseInRoom( + room, roomPrice, + coupons, DiscountType.FLAT) + ); couponDetails.addAll(couponService - .getSortedDiscountTypeCouponResponseInRoom(room, coupons, DiscountType.RATE)); + .getSortedDiscountTypeCouponResponseInRoom( + room, roomPrice, + coupons, DiscountType.RATE) + ); - RoomOption option = findRoomOptionByRoom(room); - - rooms.add(RoomsInfoResponse.of(room, option, couponDetails)); + rooms.add(RoomsInfoResponse.of(room, option, couponDetails, + roomPrice)); }); return RoomPageResponse.builder() .pageNum(roomPage.getNumber()) @@ -99,8 +120,9 @@ public RoomInfoResponse getRoom(long memberId, long roomId) { checkOwnership(member, room.getAccommodation()); RoomOption option = findRoomOptionByRoom(room); + int roomPrice = findRoomPriceByRoom(room).getOffWeekDaysMinFee(); - return RoomInfoResponse.of(room, option); + return RoomInfoResponse.of(room, option, roomPrice); } @Override @@ -117,6 +139,19 @@ public List getFilteredRoomStocksByDate( ) .toList(); } + + @Override + public Map getMinRoomPriceWithRoom(List rooms) { + Map roomMinPriceMap = new HashMap<>(); + + for (Room room: rooms) { + int roomPrice = findRoomPriceByRoom(room).getOffWeekDaysMinFee(); + roomMinPriceMap.put(room, roomPrice); + } + + return roomMinPriceMap; + } + private void checkOwnership(Member member, Accommodation accommodation) { if (!accommodationOwnershipRepository .existsAccommodationOwnershipByMemberAndAccommodation(member, accommodation)) { diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/usecase/RoomQueryUseCase.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/usecase/RoomQueryUseCase.java index 5aa83ff0..3775a7ee 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/usecase/RoomQueryUseCase.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/usecase/RoomQueryUseCase.java @@ -4,9 +4,11 @@ import com.backoffice.upjuyanolja.domain.room.dto.response.RoomPageResponse; import com.backoffice.upjuyanolja.domain.room.entity.Room; import com.backoffice.upjuyanolja.domain.room.entity.RoomOption; +import com.backoffice.upjuyanolja.domain.room.entity.RoomPrice; import com.backoffice.upjuyanolja.domain.room.entity.RoomStock; import java.time.LocalDate; import java.util.List; +import java.util.Map; import org.springframework.data.domain.Pageable; public interface RoomQueryUseCase { @@ -17,10 +19,14 @@ public interface RoomQueryUseCase { RoomOption findRoomOptionByRoom(Room room); + RoomPrice findRoomPriceByRoom(Room room); + RoomPageResponse getRooms(long memberId, long accommodationId, Pageable pageable); RoomInfoResponse getRoom(long memberId, long roomId); List getFilteredRoomStocksByDate(Room room, LocalDate startDate, LocalDate endDate); + Map getMinRoomPriceWithRoom(List rooms); + } From 6d1e0cc99623c405dfb1b43e53939fea85b487f4 Mon Sep 17 00:00:00 2001 From: HyunA Date: Sat, 3 Feb 2024 23:59:02 +0900 Subject: [PATCH 11/21] =?UTF-8?q?test:=20room=EA=B3=BC=20roomPrice=20?= =?UTF-8?q?=EA=B4=80=EA=B3=84=20=EB=B3=80=EA=B2=BD=EC=97=90=20=EB=94=B0?= =?UTF-8?q?=EB=A5=B8=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EB=B0=8F=20=EB=B9=8C=EB=93=9C=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../room/service/RoomCommandService.java | 1 - .../AccommodationOwnershipRepositoryTest.java | 6 -- .../AccommodationCommandServiceTest.java | 6 -- .../AccommodationQueryServiceTest.java | 6 -- .../CouponBackofficeControllerDocsTest.java | 6 -- .../CouponBackofficeControllerTest.java | 6 -- .../unit/repository/CouponRepositoryTest.java | 42 +++++++-- .../service/CouponBackofficeServiceTest.java | 6 -- .../docs/ReservationControllerDocsTest.java | 33 ++++--- .../controller/ReservationControllerTest.java | 33 ++++--- .../repository/ReservationRepositoryTest.java | 33 +++++-- .../unit/service/ReservationServiceTest.java | 54 +++++++----- .../service/ReservationStockServiceTest.java | 7 +- .../unit/repository/RoomRepositoryTest.java | 6 -- .../unit/service/RoomCommandServiceTest.java | 88 ++++++++++--------- .../unit/service/RoomQueryServiceTest.java | 67 +++++++------- 16 files changed, 210 insertions(+), 190 deletions(-) diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomCommandService.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomCommandService.java index 34dda12c..1e70afd6 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomCommandService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomCommandService.java @@ -218,7 +218,6 @@ private RoomOption updateRoomOption(Room room, RoomOptionUpdate option) { private RoomPrice updateRoomPrice(Room room, int price) { RoomPrice roomPrice = roomQueryUseCase.findRoomPriceByRoom(room); roomPrice.updateRoomPrice(price); - roomPriceRepository.save(roomPrice); return roomPrice; } diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/repository/AccommodationOwnershipRepositoryTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/repository/AccommodationOwnershipRepositoryTest.java index ca6a721e..1f6d6855 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/repository/AccommodationOwnershipRepositoryTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/repository/AccommodationOwnershipRepositoryTest.java @@ -170,12 +170,6 @@ private Room saveRoom(Accommodation accommodation) { .maxCapacity(3) .checkInTime(LocalTime.of(15, 0, 0)) .checkOutTime(LocalTime.of(11, 0, 0)) - .price(RoomPrice.builder() - .offWeekDaysMinFee(100000) - .offWeekendMinFee(100000) - .peakWeekDaysMinFee(100000) - .peakWeekendMinFee(100000) - .build()) .amount(858) .status(RoomStatus.SELLING) .images(new ArrayList<>()) diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationCommandServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationCommandServiceTest.java index b4fbf7db..7c0aa3ec 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationCommandServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationCommandServiceTest.java @@ -205,12 +205,6 @@ void _willSuccess() { .maxCapacity(3) .checkInTime(LocalTime.of(15, 0, 0)) .checkOutTime(LocalTime.of(11, 0, 0)) - .price(RoomPrice.builder() - .offWeekDaysMinFee(100000) - .offWeekendMinFee(100000) - .peakWeekDaysMinFee(100000) - .peakWeekendMinFee(100000) - .build()) .amount(858) .status(RoomStatus.SELLING) .images(new ArrayList<>()) diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationQueryServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationQueryServiceTest.java index 2d8b1613..a9bc8ae8 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationQueryServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationQueryServiceTest.java @@ -108,12 +108,6 @@ void _willSuccess() { .maxCapacity(3) .checkInTime(LocalTime.of(15, 0, 0)) .checkOutTime(LocalTime.of(11, 0, 0)) - .price(RoomPrice.builder() - .offWeekDaysMinFee(100000) - .offWeekendMinFee(100000) - .peakWeekDaysMinFee(100000) - .peakWeekendMinFee(100000) - .build()) .amount(858) .status(RoomStatus.SELLING) .images(new ArrayList<>()) diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/docs/CouponBackofficeControllerDocsTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/docs/CouponBackofficeControllerDocsTest.java index bb4982f7..d136f168 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/docs/CouponBackofficeControllerDocsTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/docs/CouponBackofficeControllerDocsTest.java @@ -730,12 +730,6 @@ private Room createRoom( .maxCapacity(3) .checkInTime(LocalTime.of(15, 0, 0)) .checkOutTime(LocalTime.of(11, 0, 0)) - .price(RoomPrice.builder() - .offWeekDaysMinFee(100000) - .offWeekendMinFee(100000) - .peakWeekDaysMinFee(100000) - .peakWeekendMinFee(100000) - .build()) .amount(858) .status(RoomStatus.SELLING) .images(new ArrayList<>()) diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/controller/CouponBackofficeControllerTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/controller/CouponBackofficeControllerTest.java index 652c5934..ef3313cc 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/controller/CouponBackofficeControllerTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/controller/CouponBackofficeControllerTest.java @@ -534,12 +534,6 @@ private Room createRoom( .maxCapacity(3) .checkInTime(LocalTime.of(15, 0, 0)) .checkOutTime(LocalTime.of(11, 0, 0)) - .price(RoomPrice.builder() - .offWeekDaysMinFee(100000) - .offWeekendMinFee(100000) - .peakWeekDaysMinFee(100000) - .peakWeekendMinFee(100000) - .build()) .amount(858) .status(RoomStatus.SELLING) .images(new ArrayList<>()) diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/repository/CouponRepositoryTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/repository/CouponRepositoryTest.java index 5e0314e4..fe53c046 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/repository/CouponRepositoryTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/repository/CouponRepositoryTest.java @@ -4,7 +4,6 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; -import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOwnership; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationOwnershipRepository; @@ -23,9 +22,9 @@ import com.backoffice.upjuyanolja.domain.point.entity.Point; import com.backoffice.upjuyanolja.domain.point.repository.PointRepository; import com.backoffice.upjuyanolja.domain.room.entity.Room; -import com.backoffice.upjuyanolja.domain.room.entity.RoomOption; import com.backoffice.upjuyanolja.domain.room.entity.RoomPrice; import com.backoffice.upjuyanolja.domain.room.entity.RoomStatus; +import com.backoffice.upjuyanolja.domain.room.repository.RoomPriceRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomRepository; import com.backoffice.upjuyanolja.global.config.QueryDslConfig; import jakarta.persistence.EntityManager; @@ -64,6 +63,9 @@ class CouponRepositoryTest { @Autowired private RoomRepository roomRepository; + @Autowired + private RoomPriceRepository roomPriceRepository; + @Autowired private AccommodationRepository accommodationRepository; @@ -83,12 +85,14 @@ class CouponRepositoryTest { Coupon mockCoupon; Point mockPoint; List mockRooms; + List mockRoomPrices; @BeforeEach public void initTest() { clearTable("member"); clearTable("accommodation"); clearTable("room"); + clearTable("room_price"); clearTable("coupon"); clearTable("point"); @@ -99,6 +103,9 @@ public void initTest() { List roomNameSet = List.of("스탠다드", "디럭스", "스위트"); mockRooms = createRooms(mockAccommodation, roomIdSet, roomNameSet); + List roomPriceIdSet = List.of(1L, 2L, 3L); + mockRoomPrices = createRoomPrice(mockRooms, roomPriceIdSet); + List couponIds1 = List.of(1L, 2L, 3L, 4L); List couponIds2 = List.of(5L, 6L, 7L, 8L); List couponIds3 = List.of(9L, 10L, 11L, 12L); @@ -230,7 +237,8 @@ private AccommodationOwnership createAccommodationOwnership() { return ownership; } - private List createRooms(Accommodation mockAccommodation, List roomIds, List roomNames) { + private List createRooms(Accommodation mockAccommodation, List roomIds, + List roomNames) { List rooms = List.of( createRoom(roomIds.get(0), roomNames.get(0), mockAccommodation), createRoom(roomIds.get(1), roomNames.get(1), mockAccommodation), @@ -249,12 +257,6 @@ private Room createRoom(Long roomId, String roomName, Accommodation mockAccommod .maxCapacity(3) .checkInTime(LocalTime.of(15, 0, 0)) .checkOutTime(LocalTime.of(11, 0, 0)) - .price(RoomPrice.builder() - .offWeekDaysMinFee(100000) - .offWeekendMinFee(100000) - .peakWeekDaysMinFee(100000) - .peakWeekendMinFee(100000) - .build()) .amount(858) .status(RoomStatus.SELLING) .images(new ArrayList<>()) @@ -320,6 +322,28 @@ private Coupon saveCoupon( return coupon; } + private List createRoomPrice(List rooms, List roomPriceIdSet) { + List roomPrices = List.of( + createRoomPrice(rooms.get(0), roomPriceIdSet.get(0)), + createRoomPrice(rooms.get(1), roomPriceIdSet.get(1)), + createRoomPrice(rooms.get(2), roomPriceIdSet.get(2)) + ); + roomPriceRepository.saveAll(roomPrices); + + return roomPrices; + } + + private RoomPrice createRoomPrice(Room room, Long id) { + return RoomPrice.builder() + .id(id) + .room(room) + .offWeekDaysMinFee(100000) + .offWeekendMinFee(100000) + .peakWeekDaysMinFee(100000) + .peakWeekendMinFee(100000) + .build(); + } + private Point createPoint(Long pointId, Member member, long amount) { Point point = Point.builder() .id(pointId) diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/service/CouponBackofficeServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/service/CouponBackofficeServiceTest.java index 3d1f2c80..7af0ff94 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/service/CouponBackofficeServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/service/CouponBackofficeServiceTest.java @@ -166,12 +166,6 @@ private Room createRoom( .maxCapacity(3) .checkInTime(LocalTime.of(15, 0, 0)) .checkOutTime(LocalTime.of(11, 0, 0)) - .price(RoomPrice.builder() - .offWeekDaysMinFee(100000) - .offWeekendMinFee(100000) - .peakWeekDaysMinFee(100000) - .peakWeekendMinFee(100000) - .build()) .amount(858) .status(RoomStatus.SELLING) .images(new ArrayList<>()) diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/docs/ReservationControllerDocsTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/docs/ReservationControllerDocsTest.java index feb88c0c..fe28afb5 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/docs/ReservationControllerDocsTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/docs/ReservationControllerDocsTest.java @@ -16,7 +16,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; -import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.member.entity.Authority; import com.backoffice.upjuyanolja.domain.member.entity.Member; @@ -31,7 +30,6 @@ import com.backoffice.upjuyanolja.domain.reservation.entity.ReservationStatus; import com.backoffice.upjuyanolja.domain.reservation.service.ReservationService; import com.backoffice.upjuyanolja.domain.room.entity.Room; -import com.backoffice.upjuyanolja.domain.room.entity.RoomOption; import com.backoffice.upjuyanolja.domain.room.entity.RoomPrice; import com.backoffice.upjuyanolja.domain.room.entity.RoomStatus; import com.backoffice.upjuyanolja.global.security.SecurityUtil; @@ -71,6 +69,7 @@ public class ReservationControllerDocsTest extends RestDocsSupport { static Member mockMember; static Room mockRoom; + static RoomPrice mockRoomPrice; private final ConstraintDescriptions createReservationRequestDescriptions = new ConstraintDescriptions( CreateReservationRequest.class); @@ -79,6 +78,7 @@ public class ReservationControllerDocsTest extends RestDocsSupport { public void initTest() { mockMember = createMember(); mockRoom = createRoom(); + mockRoomPrice = createRoomPrice(); } private static Member createMember() { @@ -122,12 +122,6 @@ private static Room createRoom() { .maxCapacity(3) .checkInTime(LocalTime.of(15, 0, 0)) .checkOutTime(LocalTime.of(11, 0, 0)) - .price(RoomPrice.builder() - .offWeekDaysMinFee(100000) - .offWeekendMinFee(100000) - .peakWeekDaysMinFee(100000) - .peakWeekendMinFee(100000) - .build()) .amount(858) .status(RoomStatus.SELLING) .images(new ArrayList<>()) @@ -135,6 +129,19 @@ private static Room createRoom() { return room; } + private static RoomPrice createRoomPrice() { + RoomPrice roomPrice = RoomPrice.builder() + .id(1L) + .room(mockRoom) + .offWeekDaysMinFee(100000) + .offWeekendMinFee(100000) + .peakWeekDaysMinFee(100000) + .peakWeekendMinFee(100000) + .build(); + + return roomPrice; + } + private Reservation createReservation( LocalDate startDate, LocalDate endDate, @@ -146,7 +153,7 @@ private Reservation createReservation( .room(mockRoom) .startDate(startDate) .endDate(endDate) - .price(mockRoom.getPrice().getOffWeekDaysMinFee()) + .price(mockRoomPrice.getOffWeekDaysMinFee()) .build(); Reservation reservation = Reservation.builder() @@ -167,9 +174,9 @@ private Payment getPayment(Reservation reservation) { .member(mockMember) .reservation(reservation) .payMethod(PayMethod.KAKAO_PAY) - .roomPrice(mockRoom.getPrice().getOffWeekDaysMinFee()) + .roomPrice(mockRoomPrice.getOffWeekDaysMinFee()) .discountAmount(0) - .totalAmount(mockRoom.getPrice().getOffWeekDaysMinFee()) + .totalAmount(mockRoomPrice.getOffWeekDaysMinFee()) .build(); } @@ -181,7 +188,7 @@ private static CreateReservationRequest createRequest(Long couponId) { .visitorPhone("010-1234-5678") .startDate(LocalDate.now()) .endDate(LocalDate.now().plusDays(1)) - .totalPrice(mockRoom.getPrice().getOffWeekDaysMinFee()) + .totalPrice(mockRoomPrice.getOffWeekDaysMinFee()) .payMethod(PayMethod.KAKAO_PAY) .build(); } @@ -193,7 +200,7 @@ private static CreateReservationRequest createRequest(Long couponId) { .startDate(LocalDate.now()) .endDate(LocalDate.now().plusDays(1)) .couponId(couponId) - .totalPrice(mockRoom.getPrice().getOffWeekDaysMinFee()) + .totalPrice(mockRoomPrice.getOffWeekDaysMinFee()) .payMethod(PayMethod.KAKAO_PAY) .build(); } diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/controller/ReservationControllerTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/controller/ReservationControllerTest.java index 06ab15b5..f176ed49 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/controller/ReservationControllerTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/controller/ReservationControllerTest.java @@ -7,7 +7,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; -import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.member.entity.Authority; import com.backoffice.upjuyanolja.domain.member.entity.Member; @@ -23,7 +22,6 @@ import com.backoffice.upjuyanolja.domain.reservation.entity.ReservationStatus; import com.backoffice.upjuyanolja.domain.reservation.service.ReservationService; import com.backoffice.upjuyanolja.domain.room.entity.Room; -import com.backoffice.upjuyanolja.domain.room.entity.RoomOption; import com.backoffice.upjuyanolja.domain.room.entity.RoomPrice; import com.backoffice.upjuyanolja.domain.room.entity.RoomStatus; import com.backoffice.upjuyanolja.global.security.AuthenticationConfig; @@ -82,11 +80,13 @@ class ReservationControllerTest { static Member mockMember; static Room mockRoom; + static RoomPrice mockRoomPrice; @BeforeEach public void initTest() { mockMember = createMember(1L); mockRoom = createRoom(); + mockRoomPrice = createRoomPrice(); } private static Member createMember(Long id) { @@ -130,12 +130,6 @@ private static Room createRoom() { .maxCapacity(3) .checkInTime(LocalTime.of(15, 0, 0)) .checkOutTime(LocalTime.of(11, 0, 0)) - .price(RoomPrice.builder() - .offWeekDaysMinFee(100000) - .offWeekendMinFee(100000) - .peakWeekDaysMinFee(100000) - .peakWeekendMinFee(100000) - .build()) .amount(858) .status(RoomStatus.SELLING) .images(new ArrayList<>()) @@ -143,6 +137,19 @@ private static Room createRoom() { return room; } + private static RoomPrice createRoomPrice() { + RoomPrice roomPrice = RoomPrice.builder() + .id(1L) + .room(mockRoom) + .offWeekDaysMinFee(100000) + .offWeekendMinFee(100000) + .peakWeekDaysMinFee(100000) + .peakWeekendMinFee(100000) + .build(); + + return roomPrice; + } + private Reservation createReservation( LocalDate startDate, LocalDate endDate, @@ -155,7 +162,7 @@ private Reservation createReservation( .room(mockRoom) .startDate(startDate) .endDate(endDate) - .price(mockRoom.getPrice().getOffWeekDaysMinFee()) + .price(mockRoomPrice.getOffWeekDaysMinFee()) .build(); Reservation reservation = Reservation.builder() @@ -176,9 +183,9 @@ private Payment createPayment(Reservation reservation) { .member(mockMember) .reservation(reservation) .payMethod(PayMethod.KAKAO_PAY) - .roomPrice(mockRoom.getPrice().getOffWeekDaysMinFee()) + .roomPrice(mockRoomPrice.getOffWeekDaysMinFee()) .discountAmount(0) - .totalAmount(mockRoom.getPrice().getOffWeekDaysMinFee()) + .totalAmount(mockRoomPrice.getOffWeekDaysMinFee()) .build(); } @@ -194,7 +201,7 @@ private static CreateReservationRequest createRequest(Long couponId) { .visitorPhone("010-1234-5678") .startDate(LocalDate.now()) .endDate(LocalDate.now().plusDays(1)) - .totalPrice(mockRoom.getPrice().getOffWeekDaysMinFee()) + .totalPrice(mockRoomPrice.getOffWeekDaysMinFee()) .payMethod(PayMethod.KAKAO_PAY) .build(); } @@ -206,7 +213,7 @@ private static CreateReservationRequest createRequest(Long couponId) { .startDate(LocalDate.now()) .endDate(LocalDate.now().plusDays(1)) .couponId(couponId) - .totalPrice(mockRoom.getPrice().getOffWeekDaysMinFee()) + .totalPrice(mockRoomPrice.getOffWeekDaysMinFee()) .payMethod(PayMethod.KAKAO_PAY) .build(); } diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/repository/ReservationRepositoryTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/repository/ReservationRepositoryTest.java index a6875db8..6188dba6 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/repository/ReservationRepositoryTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/repository/ReservationRepositoryTest.java @@ -4,7 +4,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; -import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.CategoryRepository; @@ -17,9 +16,9 @@ import com.backoffice.upjuyanolja.domain.reservation.repository.ReservationRepository; import com.backoffice.upjuyanolja.domain.reservation.repository.ReservationRoomRepository; import com.backoffice.upjuyanolja.domain.room.entity.Room; -import com.backoffice.upjuyanolja.domain.room.entity.RoomOption; import com.backoffice.upjuyanolja.domain.room.entity.RoomPrice; import com.backoffice.upjuyanolja.domain.room.entity.RoomStatus; +import com.backoffice.upjuyanolja.domain.room.repository.RoomPriceRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomRepository; import com.backoffice.upjuyanolja.global.config.QueryDslConfig; import jakarta.persistence.EntityManager; @@ -60,6 +59,9 @@ class ReservationRepositoryTest { @Autowired private RoomRepository roomRepository; + @Autowired + private RoomPriceRepository roomPriceRepository; + @Autowired private ReservationRoomRepository reservationRoomRepository; @@ -73,11 +75,14 @@ class ReservationRepositoryTest { static Room room; + static RoomPrice roomPrice; + @BeforeEach public void initTest() { clear("member"); clear("accommodation"); clear("room"); + clear("room_price"); clear("reservation"); member = Member.builder() @@ -92,6 +97,7 @@ public void initTest() { memberRepository.save(member); room = createRoom(); + roomPrice = createRoomPrice(room); } private void clear(String tableName) { @@ -131,12 +137,6 @@ private Room createRoom() { .maxCapacity(3) .checkInTime(LocalTime.of(15, 0, 0)) .checkOutTime(LocalTime.of(11, 0, 0)) - .price(RoomPrice.builder() - .offWeekDaysMinFee(100000) - .offWeekendMinFee(100000) - .peakWeekDaysMinFee(100000) - .peakWeekendMinFee(100000) - .build()) .amount(858) .status(RoomStatus.SELLING) .images(new ArrayList<>()) @@ -147,6 +147,21 @@ private Room createRoom() { return room; } + private RoomPrice createRoomPrice(Room room) { + RoomPrice roomPrice = RoomPrice.builder() + .id(1L) + .room(room) + .offWeekDaysMinFee(100000) + .offWeekendMinFee(100000) + .peakWeekDaysMinFee(100000) + .peakWeekendMinFee(100000) + .build(); + + roomPriceRepository.save(roomPrice); + + return roomPrice; + } + private void setupDummy() { saveReservation(LocalDate.now(), LocalDate.now().plusDays(1), false, ReservationStatus.RESERVED); @@ -168,7 +183,7 @@ private void saveReservation( .room(room) .startDate(startDate) .endDate(endDate) - .price(room.getPrice().getOffWeekDaysMinFee()) + .price(roomPrice.getOffWeekDaysMinFee()) .build(); reservationRoomRepository.save(reservationRoom); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationServiceTest.java index 9fe851ac..5192ddef 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationServiceTest.java @@ -8,7 +8,6 @@ import static org.mockito.Mockito.when; import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; -import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.coupon.entity.Coupon; import com.backoffice.upjuyanolja.domain.coupon.entity.CouponRedeem; @@ -37,7 +36,6 @@ import com.backoffice.upjuyanolja.domain.reservation.service.ReservationService; import com.backoffice.upjuyanolja.domain.reservation.service.ReservationStockService; import com.backoffice.upjuyanolja.domain.room.entity.Room; -import com.backoffice.upjuyanolja.domain.room.entity.RoomOption; import com.backoffice.upjuyanolja.domain.room.entity.RoomPrice; import com.backoffice.upjuyanolja.domain.room.entity.RoomStatus; import com.backoffice.upjuyanolja.domain.room.entity.RoomStock; @@ -102,6 +100,8 @@ class ReservationServiceTest { static Accommodation mockAccommodation; static Room mockRoom; + static RoomPrice mockRoomPrice; + static Coupon mockCoupon; static List mockReservations; @@ -112,10 +112,11 @@ public void initTest() { mockMember = createMember(1L); mockAccommodation = createAccommodation(); mockRoom = createRoom(1L, RoomStatus.SELLING); + mockRoomPrice = createRoomPrice(1L, mockRoom); mockCoupon = createCoupon(1L, mockRoom, CouponStatus.ENABLE, 1); - mockReservations = createReservations(); + mockReservations = createReservations(mockRoomPrice); for (Reservation reservation : mockReservations) { - mockPayments.add(createPayment(reservation)); + mockPayments.add(createPayment(reservation, mockRoomPrice)); } } @@ -163,12 +164,6 @@ private static Room createRoom(Long id, RoomStatus status) { .maxCapacity(3) .checkInTime(LocalTime.of(15, 0, 0)) .checkOutTime(LocalTime.of(11, 0, 0)) - .price(RoomPrice.builder() - .offWeekDaysMinFee(100000) - .offWeekendMinFee(100000) - .peakWeekDaysMinFee(100000) - .peakWeekendMinFee(100000) - .build()) .amount(858) .status(status) .images(new ArrayList<>()) @@ -176,9 +171,23 @@ private static Room createRoom(Long id, RoomStatus status) { return room; } + private RoomPrice createRoomPrice(long id, Room room) { + RoomPrice roomPrice = RoomPrice.builder() + .id(id) + .room(room) + .offWeekDaysMinFee(100000) + .offWeekendMinFee(100000) + .peakWeekDaysMinFee(100000) + .peakWeekendMinFee(100000) + .build(); + + return roomPrice; + } + private Reservation createReservation( LocalDate startDate, LocalDate endDate, + RoomPrice roomPrice, boolean isCouponUsed, ReservationStatus status ) { @@ -187,7 +196,7 @@ private Reservation createReservation( .room(mockRoom) .startDate(startDate) .endDate(endDate) - .price(mockRoom.getPrice().getOffWeekDaysMinFee()) + .price(roomPrice.getOffWeekDaysMinFee()) .build(); Reservation reservation = Reservation.builder() @@ -203,40 +212,40 @@ private Reservation createReservation( return reservation; } - private List createReservations() { + private List createReservations(RoomPrice roomPrice) { List reservations = new ArrayList<>(); reservations.add(createReservation( - LocalDate.now(), LocalDate.now().plusDays(1), + LocalDate.now(), LocalDate.now().plusDays(1), roomPrice, false, ReservationStatus.RESERVED )); reservations.add(createReservation( - LocalDate.now(), LocalDate.now().plusDays(1), + LocalDate.now(), LocalDate.now().plusDays(1), roomPrice, true, ReservationStatus.RESERVED )); reservations.add(createReservation( - LocalDate.now(), LocalDate.now().plusDays(1), + LocalDate.now(), LocalDate.now().plusDays(1), roomPrice, false, ReservationStatus.SERVICED )); reservations.add(createReservation( - LocalDate.now(), LocalDate.now().plusDays(1), + LocalDate.now(), LocalDate.now().plusDays(1), roomPrice, false, ReservationStatus.CANCELLED )); return reservations; } - private Payment createPayment(Reservation reservation) { + private Payment createPayment(Reservation reservation, RoomPrice roomPrice) { return Payment.builder() .member(mockMember) .reservation(reservation) .payMethod(PayMethod.KAKAO_PAY) - .roomPrice(mockRoom.getPrice().getOffWeekDaysMinFee()) + .roomPrice(roomPrice.getOffWeekDaysMinFee()) .discountAmount(0) - .totalAmount(mockRoom.getPrice().getOffWeekDaysMinFee()) + .totalAmount(roomPrice.getOffWeekDaysMinFee()) .build(); } @@ -458,7 +467,7 @@ void PaymentFailureException_notMatchTotalPrice() { .room(mockRoom) .startDate(request.getStartDate()) .endDate(request.getEndDate()) - .price(mockRoom.getPrice().getOffWeekDaysMinFee()) + .price(mockRoomPrice.getOffWeekDaysMinFee()) .build(); when(roomRepository.findById(any(Long.class))).thenReturn( @@ -466,6 +475,7 @@ void PaymentFailureException_notMatchTotalPrice() { when(roomQueryService.getFilteredRoomStocksByDate( any(Room.class), any(LocalDate.class), any(LocalDate.class) )).thenReturn(roomStockList); + when(roomQueryService.findRoomPriceByRoom(mockRoom)).thenReturn(mockRoomPrice); when(couponRepository.findByIdAndRoom(any(Long.class), any(Room.class))).thenReturn(Optional.ofNullable(mockCoupon)); @@ -530,7 +540,7 @@ void NoSuchReservationException_noSuchCouponRedeem() { RoomStock roomStock = createRoomStock(mockRoom, 1); List roomStockList = new ArrayList<>(Arrays.asList(roomStock)); Reservation reservation = createReservation( - LocalDate.now(), LocalDate.now(), + LocalDate.now(), LocalDate.now(), mockRoomPrice, true, ReservationStatus.RESERVED ); @@ -555,7 +565,7 @@ void NoSuchReservationRoomException_noSuchRoomStock() { Coupon coupon = createCoupon(1L, mockRoom, CouponStatus.ENABLE, 1); Reservation reservation = createReservation( - LocalDate.now(), LocalDate.now(), + LocalDate.now(), LocalDate.now(), mockRoomPrice, true, ReservationStatus.RESERVED ); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationStockServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationStockServiceTest.java index 20f8bedd..8259291d 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationStockServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationStockServiceTest.java @@ -119,12 +119,7 @@ private Room createRoom() { .maxCapacity(3) .checkInTime(LocalTime.of(15, 0, 0)) .checkOutTime(LocalTime.of(11, 0, 0)) - .price(RoomPrice.builder() - .offWeekDaysMinFee(100000) - .offWeekendMinFee(100000) - .peakWeekDaysMinFee(100000) - .peakWeekendMinFee(100000) - .build()) + .amount(858) .status(RoomStatus.SELLING) .images(new ArrayList<>()) diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/repository/RoomRepositoryTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/repository/RoomRepositoryTest.java index 8046a688..9671ece6 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/repository/RoomRepositoryTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/repository/RoomRepositoryTest.java @@ -99,12 +99,6 @@ private void saveRoom(Accommodation accommodation) { .maxCapacity(3) .checkInTime(LocalTime.of(15, 0, 0)) .checkOutTime(LocalTime.of(11, 0, 0)) - .price(RoomPrice.builder() - .offWeekDaysMinFee(100000) - .offWeekendMinFee(100000) - .peakWeekDaysMinFee(100000) - .peakWeekendMinFee(100000) - .build()) .amount(858) .status(RoomStatus.SELLING) .images(new ArrayList<>()) diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomCommandServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomCommandServiceTest.java index e63b6c27..5b1fc2d1 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomCommandServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomCommandServiceTest.java @@ -33,6 +33,7 @@ import com.backoffice.upjuyanolja.domain.room.exception.DuplicateRoomNameException; import com.backoffice.upjuyanolja.domain.room.repository.RoomImageRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomOptionRepository; +import com.backoffice.upjuyanolja.domain.room.repository.RoomPriceRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomStockRepository; import com.backoffice.upjuyanolja.domain.room.service.RoomCommandService; @@ -71,6 +72,9 @@ public class RoomCommandServiceTest { @Mock private RoomOptionRepository roomOptionRepository; + @Mock + private RoomPriceRepository roomPriceRepository; + @Mock private RoomImageRepository roomImageRepository; @@ -148,12 +152,6 @@ void _willSuccess() { .maxCapacity(3) .checkInTime(LocalTime.of(15, 0, 0)) .checkOutTime(LocalTime.of(11, 0, 0)) - .price(RoomPrice.builder() - .offWeekDaysMinFee(100000) - .offWeekendMinFee(100000) - .peakWeekDaysMinFee(100000) - .peakWeekendMinFee(100000) - .build()) .amount(858) .status(RoomStatus.SELLING) .images(new ArrayList<>()) @@ -167,6 +165,15 @@ void _willSuccess() { .internet(true) .build(); + RoomPrice roomPrice = RoomPrice.builder() + .id(1L) + .room(room) + .offWeekDaysMinFee(100000) + .offWeekendMinFee(100000) + .peakWeekDaysMinFee(100000) + .peakWeekendMinFee(100000) + .build(); + RoomImage roomImage = RoomImage.builder() .id(1L) .room(room) @@ -181,12 +188,6 @@ void _willSuccess() { .maxCapacity(3) .checkInTime(LocalTime.of(15, 0, 0)) .checkOutTime(LocalTime.of(11, 0, 0)) - .price(RoomPrice.builder() - .offWeekDaysMinFee(100000) - .offWeekendMinFee(100000) - .peakWeekDaysMinFee(100000) - .peakWeekendMinFee(100000) - .build()) .amount(858) .status(RoomStatus.SELLING) .images(List.of(roomImage)) @@ -206,6 +207,7 @@ void _willSuccess() { .willReturn(false); given(roomRepository.save(any(Room.class))).willReturn(room); given(roomOptionRepository.save(any(RoomOption.class))).willReturn(roomOption); + given(roomPriceRepository.save(any(RoomPrice.class))).willReturn(roomPrice); given(roomImageRepository.saveAll(any(List.class))).willReturn(List.of(roomImage)); // when @@ -369,12 +371,6 @@ void _willSuccess() { .maxCapacity(3) .checkInTime(LocalTime.of(15, 0, 0)) .checkOutTime(LocalTime.of(11, 0, 0)) - .price(RoomPrice.builder() - .offWeekDaysMinFee(100000) - .offWeekendMinFee(100000) - .peakWeekDaysMinFee(100000) - .peakWeekendMinFee(100000) - .build()) .amount(858) .status(RoomStatus.SELLING) .images(new ArrayList<>()) @@ -388,6 +384,15 @@ void _willSuccess() { .internet(true) .build(); + RoomPrice roomPrice = RoomPrice.builder() + .id(1L) + .room(room) + .offWeekDaysMinFee(100000) + .offWeekendMinFee(100000) + .peakWeekDaysMinFee(100000) + .peakWeekendMinFee(100000) + .build(); + RoomImage roomImage = RoomImage.builder() .id(1L) .room(room) @@ -402,12 +407,6 @@ void _willSuccess() { .maxCapacity(3) .checkInTime(LocalTime.of(15, 0, 0)) .checkOutTime(LocalTime.of(11, 0, 0)) - .price(RoomPrice.builder() - .offWeekDaysMinFee(100000) - .offWeekendMinFee(100000) - .peakWeekDaysMinFee(100000) - .peakWeekendMinFee(100000) - .build()) .amount(858) .status(RoomStatus.SELLING) .images(List.of(roomImage)) @@ -419,6 +418,7 @@ void _willSuccess() { .willReturn(false); given(roomRepository.save(any(Room.class))).willReturn(room); given(roomOptionRepository.save(any(RoomOption.class))).willReturn(roomOption); + given(roomPriceRepository.save(any(RoomPrice.class))).willReturn(roomPrice); given(roomImageRepository.saveAll(any(List.class))).willReturn(List.of(roomImage)); // when @@ -573,12 +573,6 @@ void _willSuccess() { .maxCapacity(3) .checkInTime(LocalTime.of(15, 0, 0)) .checkOutTime(LocalTime.of(11, 0, 0)) - .price(RoomPrice.builder() - .offWeekDaysMinFee(100000) - .offWeekendMinFee(100000) - .peakWeekDaysMinFee(100000) - .peakWeekendMinFee(100000) - .build()) .amount(858) .status(RoomStatus.SELLING) .images(List.of(roomImage1)) @@ -592,6 +586,15 @@ void _willSuccess() { .internet(true) .build(); + RoomPrice roomPrice = RoomPrice.builder() + .id(1L) + .room(room) + .offWeekDaysMinFee(100000) + .offWeekendMinFee(100000) + .peakWeekDaysMinFee(100000) + .peakWeekendMinFee(100000) + .build(); + RoomImage roomImage2 = RoomImage.builder() .id(2L) .room(room) @@ -611,12 +614,6 @@ void _willSuccess() { .maxCapacity(3) .checkInTime(LocalTime.of(15, 0, 0)) .checkOutTime(LocalTime.of(11, 0, 0)) - .price(RoomPrice.builder() - .offWeekDaysMinFee(200000) - .offWeekendMinFee(200000) - .peakWeekDaysMinFee(200000) - .peakWeekendMinFee(200000) - .build()) .amount(858) .status(RoomStatus.STOP_SELLING) .images(List.of(roomImage2, roomImage3)) @@ -625,6 +622,7 @@ void _willSuccess() { given(memberGetService.getMemberById(any(Long.TYPE))).willReturn(member); given(roomRepository.findById(any(Long.TYPE))).willReturn(Optional.of(room)); given(roomQueryUseCase.findRoomOptionByRoom(any(Room.class))).willReturn(roomOption); + given(roomQueryUseCase.findRoomPriceByRoom(any(Room.class))).willReturn(roomPrice); given(accommodationOwnershipRepository .existsAccommodationOwnershipByMemberAndAccommodation( any(Member.class), @@ -658,6 +656,7 @@ void _willSuccess() { verify(memberGetService, times(1)).getMemberById(any(Long.TYPE)); verify(roomRepository, times(1)).findById(any(Long.TYPE)); verify(roomQueryUseCase, times(1)).findRoomOptionByRoom(room); + verify(roomQueryUseCase, times(1)).findRoomPriceByRoom(room); verify(accommodationOwnershipRepository, times(1)) .existsAccommodationOwnershipByMemberAndAccommodation( any(Member.class), @@ -718,12 +717,6 @@ void _willSuccess() { .maxCapacity(3) .checkInTime(LocalTime.of(15, 0, 0)) .checkOutTime(LocalTime.of(11, 0, 0)) - .price(RoomPrice.builder() - .offWeekDaysMinFee(100000) - .offWeekendMinFee(100000) - .peakWeekDaysMinFee(100000) - .peakWeekendMinFee(100000) - .build()) .amount(858) .status(RoomStatus.SELLING) .images(List.of(roomImage1)) @@ -737,8 +730,18 @@ void _willSuccess() { .internet(true) .build(); + RoomPrice roomPrice = RoomPrice.builder() + .id(1L) + .room(room) + .offWeekDaysMinFee(100000) + .offWeekendMinFee(100000) + .peakWeekDaysMinFee(100000) + .peakWeekendMinFee(100000) + .build(); + given(memberGetService.getMemberById(any(Long.TYPE))).willReturn(member); given(roomQueryUseCase.findRoomOptionByRoom(any(Room.class))).willReturn(roomOption); + given(roomQueryUseCase.findRoomPriceByRoom(any(Room.class))).willReturn(roomPrice); given(roomRepository.findById(any(Long.TYPE))).willReturn(Optional.of(room)); given(accommodationOwnershipRepository .existsAccommodationOwnershipByMemberAndAccommodation( @@ -770,6 +773,7 @@ void _willSuccess() { verify(memberGetService, times(1)).getMemberById(any(Long.TYPE)); verify(roomRepository, times(1)).findById(any(Long.TYPE)); verify(roomQueryUseCase, times(1)).findRoomOptionByRoom(room); + verify(roomQueryUseCase, times(1)).findRoomPriceByRoom(room); verify(accommodationOwnershipRepository, times(1)) .existsAccommodationOwnershipByMemberAndAccommodation( any(Member.class), diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomQueryServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomQueryServiceTest.java index 472c2a2d..d7910916 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomQueryServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomQueryServiceTest.java @@ -29,6 +29,7 @@ import com.backoffice.upjuyanolja.domain.room.entity.RoomPrice; import com.backoffice.upjuyanolja.domain.room.entity.RoomStatus; import com.backoffice.upjuyanolja.domain.room.repository.RoomOptionRepository; +import com.backoffice.upjuyanolja.domain.room.repository.RoomPriceRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomRepository; import com.backoffice.upjuyanolja.domain.room.service.RoomQueryService; import java.time.LocalDate; @@ -69,6 +70,9 @@ public class RoomQueryServiceTest { @Mock private RoomOptionRepository roomOptionRepository; + @Mock + private RoomPriceRepository roomPriceRepository; + @Mock private CouponService couponService; @@ -121,24 +125,11 @@ void _willSuccess() { .maxCapacity(3) .checkInTime(LocalTime.of(15, 0, 0)) .checkOutTime(LocalTime.of(11, 0, 0)) - .price(RoomPrice.builder() - .offWeekDaysMinFee(100000) - .offWeekendMinFee(100000) - .peakWeekDaysMinFee(100000) - .peakWeekendMinFee(100000) - .build()) .amount(858) .status(RoomStatus.SELLING) .images(new ArrayList<>()) .build(); - RoomOption roomOption = RoomOption.builder() - .id(1L) - .room(room) - .airCondition(true) - .tv(true) - .internet(true) - .build(); RoomImage roomImage = RoomImage.builder() .id(1L) @@ -154,12 +145,6 @@ void _willSuccess() { .maxCapacity(3) .checkInTime(LocalTime.of(15, 0, 0)) .checkOutTime(LocalTime.of(11, 0, 0)) - .price(RoomPrice.builder() - .offWeekDaysMinFee(100000) - .offWeekendMinFee(100000) - .peakWeekDaysMinFee(100000) - .peakWeekendMinFee(100000) - .build()) .amount(858) .status(RoomStatus.SELLING) .images(List.of(roomImage)) @@ -173,6 +158,15 @@ void _willSuccess() { .internet(true) .build(); + RoomPrice savedRoomPrice = RoomPrice.builder() + .id(1L) + .room(room) + .offWeekDaysMinFee(100000) + .offWeekendMinFee(100000) + .peakWeekDaysMinFee(100000) + .peakWeekendMinFee(100000) + .build(); + List coupons = List.of( Coupon.builder() .id(1L) @@ -237,17 +231,19 @@ void _willSuccess() { .willReturn(new PageImpl<>(List.of(savedRoom))); given(roomOptionRepository.findByRoom(savedRoom)) .willReturn(Optional.of(savedRoomOption)); + given(roomPriceRepository.findByRoom(savedRoom)) + .willReturn(Optional.of(savedRoomPrice)); given(couponService.getCouponInRoom(any(Room.class))).willReturn(coupons); given(couponService.getSortedDiscountTypeCouponResponseInRoom( any(Room.class), + any((Integer.TYPE)), any(List.class), - eq(DiscountType.FLAT) - )).willReturn(flatCoupons); + eq(DiscountType.FLAT))).willReturn(flatCoupons); given(couponService.getSortedDiscountTypeCouponResponseInRoom( any(Room.class), + any((Integer.TYPE)), any(List.class), - eq(DiscountType.RATE) - )).willReturn(rateCoupons); + eq(DiscountType.RATE))).willReturn(rateCoupons); // when RoomPageResponse result = roomQueryService.getRooms(1L, 1L, roomPageRequest.of()); @@ -284,14 +280,14 @@ void _willSuccess() { verify(couponService, times(1)).getCouponInRoom(any(Room.class)); verify(couponService, times(1)).getSortedDiscountTypeCouponResponseInRoom( any(Room.class), + any((Integer.TYPE)), any(List.class), - eq(DiscountType.FLAT) - ); + eq(DiscountType.FLAT)); verify(couponService, times(1)).getSortedDiscountTypeCouponResponseInRoom( any(Room.class), + any((Integer.TYPE)), any(List.class), - eq(DiscountType.RATE) - ); + eq(DiscountType.RATE)); } } @@ -344,12 +340,6 @@ void _willSuccess() { .maxCapacity(3) .checkInTime(LocalTime.of(15, 0, 0)) .checkOutTime(LocalTime.of(11, 0, 0)) - .price(RoomPrice.builder() - .offWeekDaysMinFee(100000) - .offWeekendMinFee(100000) - .peakWeekDaysMinFee(100000) - .peakWeekendMinFee(100000) - .build()) .amount(858) .status(RoomStatus.SELLING) .images(List.of(roomImage1)) @@ -363,10 +353,21 @@ void _willSuccess() { .internet(true) .build(); + RoomPrice roomPrice = RoomPrice.builder() + .id(1L) + .room(room) + .offWeekDaysMinFee(100000) + .offWeekendMinFee(100000) + .peakWeekDaysMinFee(100000) + .peakWeekendMinFee(100000) + .build(); + given(memberGetService.getMemberById(any(Long.TYPE))).willReturn(member); given(roomRepository.findById(any(Long.TYPE))).willReturn(Optional.of(room)); given(roomOptionRepository.findByRoom(room)) .willReturn(Optional.of(roomOption)); + given(roomPriceRepository.findByRoom(room)) + .willReturn(Optional.of(roomPrice)); given(accommodationOwnershipRepository .existsAccommodationOwnershipByMemberAndAccommodation( any(Member.class), From 86de5108319664bd5b437a984d38d24e817ca930 Mon Sep 17 00:00:00 2001 From: HyunA Date: Sun, 4 Feb 2024 01:37:20 +0900 Subject: [PATCH 12/21] =?UTF-8?q?refactor:=20Accommodation=EA=B3=BC=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=96=91=EB=B0=A9=ED=96=A5=20?= =?UTF-8?q?=EC=97=B0=EA=B4=80=20=EA=B4=80=EA=B3=84=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/AccommodationRegisterRequest.java | 1 - .../response/AccommodationDetailResponse.java | 13 ++++----- .../response/AccommodationInfoResponse.java | 5 ++-- .../accommodation/entity/Accommodation.java | 5 ---- .../AccommodationImageRepository.java | 4 +++ .../service/AccommodationCommandService.java | 10 ++++--- .../service/AccommodationQueryService.java | 29 ++++++++++++------- .../openapi/service/OpenApiService.java | 8 ++--- .../room/repository/RoomRepository.java | 1 + 9 files changed, 41 insertions(+), 35 deletions(-) diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/request/AccommodationRegisterRequest.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/request/AccommodationRegisterRequest.java index b000b5b3..521e42a3 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/request/AccommodationRegisterRequest.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/request/AccommodationRegisterRequest.java @@ -56,7 +56,6 @@ public static Accommodation toEntity( .category(category) .description(request.description()) .thumbnail(request.thumbnail()) - .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationDetailResponse.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationDetailResponse.java index 0ea0c98f..1d92a035 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationDetailResponse.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationDetailResponse.java @@ -1,6 +1,7 @@ package com.backoffice.upjuyanolja.domain.accommodation.dto.response; import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; +import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import com.backoffice.upjuyanolja.domain.room.dto.response.RoomResponse; import java.util.List; import lombok.Builder; @@ -19,8 +20,8 @@ public record AccommodationDetailResponse( ) { public static AccommodationDetailResponse of( - Accommodation accommodation, String mainCoupon, - AccommodationOptionResponse option, List rooms + Accommodation accommodation, String mainCoupon, AccommodationOption option, + List images, List rooms ) { return AccommodationDetailResponse.builder() .id(accommodation.getId()) @@ -32,12 +33,8 @@ public static AccommodationDetailResponse of( .description(accommodation.getDescription()) .category(accommodation.getCategory().getName()) .mainCoupon(mainCoupon) - .images( - accommodation.getImages().stream() - .map(image -> image.getUrl()) - .toList() - ) - .option(option) + .option(AccommodationOptionResponse.of(option)) + .images(images) .rooms(rooms) .build(); } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationInfoResponse.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationInfoResponse.java index 0d195a2b..ff0082fc 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationInfoResponse.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/response/AccommodationInfoResponse.java @@ -1,6 +1,7 @@ package com.backoffice.upjuyanolja.domain.accommodation.dto.response; import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; +import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationImage; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import com.backoffice.upjuyanolja.domain.room.dto.response.RoomInfoResponse; import java.util.List; @@ -19,7 +20,7 @@ public record AccommodationInfoResponse( ) { public static AccommodationInfoResponse of( - Accommodation accommodation, AccommodationOption option, + Accommodation accommodation, AccommodationOption option, List images, List rooms ) { return AccommodationInfoResponse.builder() @@ -30,8 +31,8 @@ public static AccommodationInfoResponse of( .address(accommodation.getAddress() + " " + accommodation.getDetailAddress()) - .images(AccommodationImageResponse.of(accommodation.getImages())) .option(AccommodationOptionResponse.of(option)) + .images(AccommodationImageResponse.of(images)) .rooms(rooms) .build(); } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/entity/Accommodation.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/entity/Accommodation.java index 31441197..334847b3 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/entity/Accommodation.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/entity/Accommodation.java @@ -61,9 +61,6 @@ public class Accommodation extends BaseTime { @Comment("숙소 카테고리") private Category category; - @OneToMany(mappedBy = "accommodation", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) - private List images = new ArrayList<>(); - @OneToMany(mappedBy = "accommodation", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) private List rooms = new ArrayList<>(); @@ -77,7 +74,6 @@ public Accommodation( Category category, String description, String thumbnail, - List images, List rooms ) { this.id = id; @@ -88,7 +84,6 @@ public Accommodation( this.category = category; this.description = description; this.thumbnail = thumbnail; - this.images = images; this.rooms = rooms; } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/repository/AccommodationImageRepository.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/repository/AccommodationImageRepository.java index 1d4c3e65..3dd091b2 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/repository/AccommodationImageRepository.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/repository/AccommodationImageRepository.java @@ -1,8 +1,12 @@ package com.backoffice.upjuyanolja.domain.accommodation.repository; +import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationImage; +import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; public interface AccommodationImageRepository extends JpaRepository { + List findByAccommodation(Accommodation accommodation); + } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java index 493ebb7c..b79c9988 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java @@ -3,8 +3,10 @@ import com.backoffice.upjuyanolja.domain.accommodation.dto.request.AccommodationImageRequest; import com.backoffice.upjuyanolja.domain.accommodation.dto.request.AccommodationOptionRequest; import com.backoffice.upjuyanolja.domain.accommodation.dto.request.AccommodationRegisterRequest; +import com.backoffice.upjuyanolja.domain.accommodation.dto.response.AccommodationImageResponse; import com.backoffice.upjuyanolja.domain.accommodation.dto.response.AccommodationInfoResponse; import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; +import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationImage; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOwnership; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; @@ -63,12 +65,12 @@ public AccommodationInfoResponse createAccommodation( .category(category) .thumbnail(request.thumbnail()) .rooms(new ArrayList<>()) - .images(new ArrayList<>()) .build()); imageValidate(request.images()); - accommodationImageRepository.saveAll(AccommodationImageRequest - .toEntity(accommodation, request.images())); + List images = accommodationImageRepository.saveAll( + AccommodationImageRequest + .toEntity(accommodation, request.images())); accommodationOwnershipRepository.save(AccommodationOwnership.builder() .accommodation(accommodation) @@ -86,7 +88,7 @@ public AccommodationInfoResponse createAccommodation( List room = roomCommandService.getRoomInfoResponses(accommodation); - return AccommodationInfoResponse.of(accommodation, option, room); + return AccommodationInfoResponse.of(accommodation, option, images, room); } public AccommodationOption createAccommodationOption( diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationQueryService.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationQueryService.java index c4626b5e..1ba5c714 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationQueryService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationQueryService.java @@ -7,10 +7,12 @@ import com.backoffice.upjuyanolja.domain.accommodation.dto.response.AccommodationPageResponse; import com.backoffice.upjuyanolja.domain.accommodation.dto.response.AccommodationSummaryResponse; import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; +import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationImage; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOwnership; import com.backoffice.upjuyanolja.domain.accommodation.exception.AccommodationNotFoundException; import com.backoffice.upjuyanolja.domain.accommodation.exception.AccommodationOptionNotFoundException; +import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationImageRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationOptionRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationOwnershipRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationRepository; @@ -47,6 +49,7 @@ public class AccommodationQueryService implements AccommodationQueryUseCase { private final AccommodationRepository accommodationRepository; private final AccommodationOwnershipRepository accommodationOwnershipRepository; private final AccommodationOptionRepository accommodationOptionRepository; + private final AccommodationImageRepository accommodationImageRepository; private final MemberRepository memberRepository; private final CouponService couponService; private final RoomQueryUseCase roomQueryUseCase; @@ -101,13 +104,13 @@ public AccommodationDetailResponse findAccommodationWithRooms( accommodation.getRooms(), startDate, endDate ); - AccommodationOption accommodationOption = - getAccommodationOptionByAccommodation(accommodation); - return AccommodationDetailResponse.of( accommodation, getMainCouponName(accommodationId), - AccommodationOptionResponse.of(accommodationOption), + getAccommodationOptionByAccommodation(accommodation), + getAccommodationImageByAccommodation(accommodation).stream() + .map(image -> image.getUrl()) + .toList(), accommodation.getRooms().stream() .map(room -> { int roomPrice = roomQueryUseCase.findRoomPriceByRoom(room) @@ -155,6 +158,11 @@ public boolean existsById(Long accommodationId) { return accommodationRepository.existsById(accommodationId); } + @Transactional(readOnly = true) + public Accommodation findAccommodationByRoomId(long roomId) { + return roomQueryUseCase.findRoomById(roomId).getAccommodation(); + } + @Transactional(readOnly = true) public List getOwnershipByMember(Member member) { return accommodationOwnershipRepository.findAllByMember(member); @@ -166,6 +174,12 @@ public AccommodationOption getAccommodationOptionByAccommodation(Accommodation a .orElseThrow(AccommodationOptionNotFoundException::new); } + @Transactional(readOnly = true) + public List getAccommodationImageByAccommodation( + Accommodation accommodation) { + return accommodationImageRepository.findByAccommodation(accommodation); + } + private boolean checkCouponAvailability(Accommodation accommodation) { return !couponService.findCouponResponseInAccommodation(accommodation.getId()).isEmpty(); } @@ -173,7 +187,7 @@ private boolean checkCouponAvailability(Accommodation accommodation) { private int getLowestPrice(Long accommodationId) { List rooms = roomQueryUseCase.findByAccommodationId(accommodationId); - PriorityQueue pq = new PriorityQueue<>(Comparator.comparingInt(i -> i)); + PriorityQueue pq = new PriorityQueue<>(); for (Room room : rooms) { pq.offer(roomQueryUseCase.findRoomPriceByRoom(room).getOffWeekDaysMinFee()); @@ -225,11 +239,6 @@ private String getMainCouponName(Long accommodationId) { } - @Transactional(readOnly = true) - public Accommodation findAccommodationByRoomId(long roomId) { - return roomQueryUseCase.findRoomById(roomId).getAccommodation(); - } - private int getDiscountPrice(Room room, int roomPrice) { return couponService.getSortedTotalCouponResponseInRoom(room, roomPrice).stream() diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/openapi/service/OpenApiService.java b/src/main/java/com/backoffice/upjuyanolja/domain/openapi/service/OpenApiService.java index d6d78771..96dada16 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/openapi/service/OpenApiService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/openapi/service/OpenApiService.java @@ -115,8 +115,9 @@ public void getData(int pageSize, int pageNum) throws JSONException { checkIntroItem(introItem); checkStay(stay); - Accommodation accommodation = saveAccommodation(stay, commonItem, introItem); + Accommodation accommodation = saveAccommodation(stay, commonItem); saveOwnership(accommodation, member); + saveAccommodationOption(accommodation, introItem); saveAccommodationImages(accommodation, images); saveRooms(accommodation, introItem, rooms); } catch (InvalidDataException | WrongCategoryException e) { @@ -239,8 +240,7 @@ private boolean hasRoom(JSONArray info) throws JSONException { private Accommodation saveAccommodation( JSONObject base, - JSONObject common, - JSONObject intro + JSONObject common ) throws JSONException { Category category = categoryRepository.findCategoryByNameAndIdGreaterThan( AccommodationType.getByCode(base.getString("cat3")).name(), 4L) @@ -254,11 +254,9 @@ private Accommodation saveAccommodation( .zipCode(common.getString("zipcode")) .description(common.getString("overview")) .thumbnail(base.getString("firstimage")) - .images(new ArrayList<>()) .build(); Accommodation saveAccommodation = accommodationRepository.save(accommodation); - saveAccommodationOption(accommodation, intro); return saveAccommodation; } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomRepository.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomRepository.java index 43bdf350..b45cea78 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomRepository.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomRepository.java @@ -7,4 +7,5 @@ public interface RoomRepository extends JpaRepository, RoomCustomRepository { List findByAccommodationId(long id); + } From 06c16fb71738fe41026add8741fea6d182f2d64a Mon Sep 17 00:00:00 2001 From: HyunA Date: Sun, 4 Feb 2024 01:50:48 +0900 Subject: [PATCH 13/21] =?UTF-8?q?test:=20Accommodation=EA=B3=BC=20Image=20?= =?UTF-8?q?=EC=96=91=EB=B0=A9=ED=96=A5=20=EC=82=AD=EC=A0=9C=EC=97=90=20?= =?UTF-8?q?=EB=94=B0=EB=A5=B8=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=88=98=EC=A0=95=20=EB=B0=8F=20=EB=B9=8C=EB=93=9C?= =?UTF-8?q?=20=ED=99=95=EC=9D=B8=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AccommodationOwnershipRepositoryTest.java | 12 ++++++++++-- .../service/AccommodationCommandServiceTest.java | 2 -- .../unit/service/AccommodationQueryServiceTest.java | 2 -- .../docs/CouponBackofficeControllerDocsTest.java | 1 - .../controller/CouponBackofficeControllerTest.java | 1 - .../coupon/unit/repository/CouponRepositoryTest.java | 1 - .../unit/service/CouponBackofficeServiceTest.java | 1 - .../docs/ReservationControllerDocsTest.java | 1 - .../unit/controller/ReservationControllerTest.java | 1 - .../unit/repository/ReservationRepositoryTest.java | 1 - .../unit/service/ReservationServiceTest.java | 1 - .../unit/service/ReservationStockServiceTest.java | 1 - .../room/unit/repository/RoomRepositoryTest.java | 1 - .../room/unit/service/RoomCommandServiceTest.java | 6 ------ .../room/unit/service/RoomQueryServiceTest.java | 2 -- 15 files changed, 10 insertions(+), 24 deletions(-) diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/repository/AccommodationOwnershipRepositoryTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/repository/AccommodationOwnershipRepositoryTest.java index 1f6d6855..9e1f0603 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/repository/AccommodationOwnershipRepositoryTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/repository/AccommodationOwnershipRepositoryTest.java @@ -6,6 +6,7 @@ import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOwnership; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; +import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationImageRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationOptionRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationOwnershipRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationRepository; @@ -15,7 +16,6 @@ import com.backoffice.upjuyanolja.domain.member.repository.MemberRepository; import com.backoffice.upjuyanolja.domain.room.entity.Room; import com.backoffice.upjuyanolja.domain.room.entity.RoomOption; -import com.backoffice.upjuyanolja.domain.room.entity.RoomPrice; import com.backoffice.upjuyanolja.domain.room.entity.RoomStatus; import com.backoffice.upjuyanolja.domain.room.repository.RoomOptionRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomRepository; @@ -52,6 +52,9 @@ public class AccommodationOwnershipRepositoryTest { @Autowired private AccommodationOptionRepository accommodationOptionRepository; + @Autowired + private AccommodationImageRepository accommodationImageRepository; + @Autowired private CategoryRepository categoryRepository; @@ -73,12 +76,14 @@ public void reset() { accommodationRepository.deleteAll(); accommodationOwnershipRepository.deleteAll(); accommodationOptionRepository.deleteAll(); + accommodationImageRepository.deleteAll(); memberRepository.deleteAll(); entityManager.createNativeQuery("TRUNCATE TABLE room").executeUpdate(); entityManager.createNativeQuery("TRUNCATE TABLE category").executeUpdate(); entityManager.createNativeQuery("TRUNCATE TABLE accommodation").executeUpdate(); entityManager.createNativeQuery("TRUNCATE TABLE accommodation_ownership").executeUpdate(); entityManager.createNativeQuery("TRUNCATE TABLE accommodation_option").executeUpdate(); + entityManager.createNativeQuery("TRUNCATE TABLE accommodation_image").executeUpdate(); entityManager.createNativeQuery("TRUNCATE TABLE member").executeUpdate(); entityManager .createNativeQuery("ALTER TABLE room ALTER COLUMN `id` RESTART WITH 1") @@ -97,6 +102,10 @@ public void reset() { .createNativeQuery( "ALTER TABLE accommodation_option ALTER COLUMN `id` RESTART WITH 1") .executeUpdate(); + entityManager + .createNativeQuery( + "ALTER TABLE accommodation_image ALTER COLUMN `id` RESTART WITH 1") + .executeUpdate(); entityManager .createNativeQuery("ALTER TABLE member ALTER COLUMN `id` RESTART WITH 1") .executeUpdate(); @@ -130,7 +139,6 @@ private Accommodation saveAccommodation() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build()); } diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationCommandServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationCommandServiceTest.java index 7c0aa3ec..a1fcdcb1 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationCommandServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationCommandServiceTest.java @@ -152,7 +152,6 @@ void _willSuccess() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); AccommodationOption accommodationOption = AccommodationOption.builder() @@ -219,7 +218,6 @@ void _willSuccess() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .images(List.of(accommodationImage)) .rooms(List.of(room)) .build(); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationQueryServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationQueryServiceTest.java index a9bc8ae8..1ae89711 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationQueryServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationQueryServiceTest.java @@ -92,7 +92,6 @@ void _willSuccess() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); AccommodationImage accommodationImage = AccommodationImage.builder() @@ -121,7 +120,6 @@ void _willSuccess() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .images(List.of(accommodationImage)) .rooms(List.of(room)) .build(); AccommodationOwnership accommodationOwnership = AccommodationOwnership.builder() diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/docs/CouponBackofficeControllerDocsTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/docs/CouponBackofficeControllerDocsTest.java index d136f168..38717c5e 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/docs/CouponBackofficeControllerDocsTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/docs/CouponBackofficeControllerDocsTest.java @@ -802,7 +802,6 @@ private Accommodation createAccommodation(Long accommodationId) { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); } diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/controller/CouponBackofficeControllerTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/controller/CouponBackofficeControllerTest.java index ef3313cc..23d49062 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/controller/CouponBackofficeControllerTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/controller/CouponBackofficeControllerTest.java @@ -632,7 +632,6 @@ private Accommodation createAccommodation(Long accommodationId) { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); } diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/repository/CouponRepositoryTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/repository/CouponRepositoryTest.java index fe53c046..d458406b 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/repository/CouponRepositoryTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/repository/CouponRepositoryTest.java @@ -211,7 +211,6 @@ private Accommodation createAccommodation(Long accommodationId) { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); accommodationRepository.save(accommodation); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/service/CouponBackofficeServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/service/CouponBackofficeServiceTest.java index 7af0ff94..693741fe 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/service/CouponBackofficeServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/service/CouponBackofficeServiceTest.java @@ -120,7 +120,6 @@ private Accommodation createAccommodation(long accommodationId) { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); return accommodation; diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/docs/ReservationControllerDocsTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/docs/ReservationControllerDocsTest.java index fe28afb5..404d7e62 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/docs/ReservationControllerDocsTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/docs/ReservationControllerDocsTest.java @@ -110,7 +110,6 @@ private static Room createRoom() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/controller/ReservationControllerTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/controller/ReservationControllerTest.java index f176ed49..acdb4151 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/controller/ReservationControllerTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/controller/ReservationControllerTest.java @@ -118,7 +118,6 @@ private static Room createRoom() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/repository/ReservationRepositoryTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/repository/ReservationRepositoryTest.java index 6188dba6..c415cdb7 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/repository/ReservationRepositoryTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/repository/ReservationRepositoryTest.java @@ -124,7 +124,6 @@ private Room createRoom() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationServiceTest.java index 5192ddef..d792c02d 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationServiceTest.java @@ -149,7 +149,6 @@ private static Accommodation createAccommodation() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); return accommodation; diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationStockServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationStockServiceTest.java index 8259291d..08bf5f92 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationStockServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationStockServiceTest.java @@ -106,7 +106,6 @@ private Room createRoom() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); accommodationRepository.save(accommodation); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/repository/RoomRepositoryTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/repository/RoomRepositoryTest.java index 9671ece6..8ffd3b66 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/repository/RoomRepositoryTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/repository/RoomRepositoryTest.java @@ -86,7 +86,6 @@ private Accommodation saveAccommodation() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build()); } diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomCommandServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomCommandServiceTest.java index 5b1fc2d1..c22e53bb 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomCommandServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomCommandServiceTest.java @@ -140,7 +140,6 @@ void _willSuccess() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); @@ -286,7 +285,6 @@ void notOwner_willFail() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); @@ -359,7 +357,6 @@ void _willSuccess() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); @@ -481,7 +478,6 @@ void duplicatedRoomName_willFail() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); @@ -556,7 +552,6 @@ void _willSuccess() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); @@ -700,7 +695,6 @@ void _willSuccess() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomQueryServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomQueryServiceTest.java index d7910916..82f7acd0 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomQueryServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomQueryServiceTest.java @@ -113,7 +113,6 @@ void _willSuccess() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); @@ -323,7 +322,6 @@ void _willSuccess() { .description( "63빌딩의 1.8배 규모인 연면적 30만 3737m2, 높이 169m(38층)를 자랑하는 제주 최대 높이, 최대 규모의 랜드마크이다. 제주 고도제한선(55m)보다 높이 위치한 1,600 올스위트 객실, 월드클래스 셰프들이 포진해 있는 14개의 글로벌 레스토랑 & 바, 인피니티 풀을 포함한 8층 야외풀데크, 38층 스카이데크를 비롯해 HAN컬렉션 K패션 쇼핑몰, 2개의 프리미엄 스파, 8개의 연회장 등 라스베이거스, 싱가포르, 마카오에서나 볼 수 있는 세계적인 수준의 복합리조트이다. 제주국제공항에서 차량으로 10분거리(5km)이며 제주의 강남이라고 불리는 신제주 관광 중심지에 위치하고 있다.") .thumbnail("http://tong.visitkorea.or.kr/cms/resource/83/2876783_image2_1.jpg") - .images(new ArrayList<>()) .rooms(new ArrayList<>()) .build(); From ae58020b9a4018148b72f7736dc71d4f0505cf61 Mon Sep 17 00:00:00 2001 From: HyunA Date: Sun, 4 Feb 2024 02:41:02 +0900 Subject: [PATCH 14/21] =?UTF-8?q?refactor:=20Room=EA=B3=BC=20Image=20?= =?UTF-8?q?=EC=96=91=EB=B0=A9=ED=96=A5=20=EC=97=B0=EA=B4=80=20=EA=B4=80?= =?UTF-8?q?=EA=B3=84=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../accommodation/entity/Accommodation.java | 1 - .../service/AccommodationCommandService.java | 14 ++++----- .../service/AccommodationQueryService.java | 14 ++++++--- .../openapi/service/OpenApiService.java | 1 - .../room/dto/response/RoomInfoResponse.java | 5 ++-- .../room/dto/response/RoomResponse.java | 11 +++---- .../room/dto/response/RoomsInfoResponse.java | 9 +++--- .../upjuyanolja/domain/room/entity/Room.java | 12 +------- .../repository/RoomCustomRepositoryImpl.java | 2 -- .../room/repository/RoomImageRepository.java | 4 +++ .../room/service/RoomCommandService.java | 25 ++++++++-------- .../domain/room/service/RoomQueryService.java | 30 +++++++++++++++---- .../service/usecase/RoomQueryUseCase.java | 5 ++++ .../service/ReservationStockServiceTest.java | 7 +---- 14 files changed, 78 insertions(+), 62 deletions(-) diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/entity/Accommodation.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/entity/Accommodation.java index 334847b3..72f36686 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/entity/Accommodation.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/entity/Accommodation.java @@ -12,7 +12,6 @@ import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; -import jakarta.persistence.OneToOne; import java.util.ArrayList; import java.util.List; import java.util.Objects; diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java index b79c9988..39a501ed 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationCommandService.java @@ -69,25 +69,25 @@ public AccommodationInfoResponse createAccommodation( imageValidate(request.images()); List images = accommodationImageRepository.saveAll( - AccommodationImageRequest - .toEntity(accommodation, request.images())); + AccommodationImageRequest.toEntity(accommodation, request.images()) + ); accommodationOwnershipRepository.save(AccommodationOwnership.builder() .accommodation(accommodation) .member(member) .build()); + AccommodationOption option = createAccommodationOption(accommodation, request.option()); + roomValidate(request.rooms()); request.rooms().forEach( - roomRegisterRequest -> roomCommandService.saveRoom(accommodation, roomRegisterRequest)); - - AccommodationOption option = createAccommodationOption(accommodation, request.option()); + roomRegisterRequest -> roomCommandService.saveRoom(accommodation, roomRegisterRequest) + ); + List room = roomCommandService.getRoomInfoResponses(accommodation); em.refresh(accommodation); em.refresh(option); - List room = roomCommandService.getRoomInfoResponses(accommodation); - return AccommodationInfoResponse.of(accommodation, option, images, room); } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationQueryService.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationQueryService.java index 1ba5c714..ef4ffbae 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationQueryService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/service/AccommodationQueryService.java @@ -108,9 +108,7 @@ public AccommodationDetailResponse findAccommodationWithRooms( accommodation, getMainCouponName(accommodationId), getAccommodationOptionByAccommodation(accommodation), - getAccommodationImageByAccommodation(accommodation).stream() - .map(image -> image.getUrl()) - .toList(), + getAccommodationImageUrlByAccommodation(accommodation), accommodation.getRooms().stream() .map(room -> { int roomPrice = roomQueryUseCase.findRoomPriceByRoom(room) @@ -123,6 +121,7 @@ public AccommodationDetailResponse findAccommodationWithRooms( getDiscountPrice(room, roomPrice), !checkSoldOut(filterRooms, room), getMinFilteredRoomStock(room, startDate, endDate), + roomQueryUseCase.getRoomImageUrlByRoom(room), couponService.getSortedTotalCouponResponseInRoom( room, roomPrice ) @@ -176,10 +175,17 @@ public AccommodationOption getAccommodationOptionByAccommodation(Accommodation a @Transactional(readOnly = true) public List getAccommodationImageByAccommodation( - Accommodation accommodation) { + Accommodation accommodation + ) { return accommodationImageRepository.findByAccommodation(accommodation); } + private List getAccommodationImageUrlByAccommodation(Accommodation accommodation) { + return accommodationImageRepository.findByAccommodation(accommodation).stream() + .map(image -> image.getUrl()) + .toList(); + } + private boolean checkCouponAvailability(Accommodation accommodation) { return !couponService.findCouponResponseInAccommodation(accommodation.getId()).isEmpty(); } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/openapi/service/OpenApiService.java b/src/main/java/com/backoffice/upjuyanolja/domain/openapi/service/OpenApiService.java index 96dada16..d27e1ac5 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/openapi/service/OpenApiService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/openapi/service/OpenApiService.java @@ -322,7 +322,6 @@ private void saveRooms( roomJson.getInt("roommaxcount"))) .checkInTime(checkIn) .checkOutTime(checkOut) - .images(new ArrayList<>()) .amount(Integer.parseInt(roomJson.getString("roomcount"))) .status(RoomStatus.SELLING) .build()); diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomInfoResponse.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomInfoResponse.java index 876fa725..bbe78758 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomInfoResponse.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomInfoResponse.java @@ -1,6 +1,7 @@ package com.backoffice.upjuyanolja.domain.room.dto.response; import com.backoffice.upjuyanolja.domain.room.entity.Room; +import com.backoffice.upjuyanolja.domain.room.entity.RoomImage; import com.backoffice.upjuyanolja.domain.room.entity.RoomOption; import java.time.format.DateTimeFormatter; import java.util.List; @@ -22,7 +23,7 @@ public record RoomInfoResponse( ) { public static RoomInfoResponse of( - Room room, RoomOption option, int price + Room room, RoomOption option, List images, int price ) { return RoomInfoResponse.builder() .id(room.getId()) @@ -34,7 +35,7 @@ public static RoomInfoResponse of( .price(price) .amount(room.getAmount()) .status(room.getStatus().name()) - .images(RoomImageResponse.of(room.getImages())) + .images(RoomImageResponse.of(images)) .option(RoomOptionResponse.of(option)) .build(); } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomResponse.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomResponse.java index d4725db8..51b22c5c 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomResponse.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomResponse.java @@ -26,8 +26,9 @@ public record RoomResponse( ) { public static RoomResponse of( - Room room, RoomOption option, int roomPrice, int discountPrice, - boolean soldOut, int count, List coupons + Room room, RoomOption option, int roomPrice, + int discountPrice, boolean soldOut, int count, + List images, List coupons ) { return RoomResponse.builder() @@ -42,11 +43,7 @@ public static RoomResponse of( .soldOut(soldOut) .count(count) .coupons(coupons) - .images( - room.getImages().stream() - .map(image -> image.getUrl()) - .toList() - ) + .images(images) .roomOption(RoomOptionResponse.of(option)) .build(); } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomsInfoResponse.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomsInfoResponse.java index 6635ddcb..9e89fbe3 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomsInfoResponse.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/dto/response/RoomsInfoResponse.java @@ -2,9 +2,9 @@ import com.backoffice.upjuyanolja.domain.coupon.dto.response.CouponDetailResponse; import com.backoffice.upjuyanolja.domain.room.entity.Room; +import com.backoffice.upjuyanolja.domain.room.entity.RoomImage; import com.backoffice.upjuyanolja.domain.room.entity.RoomOption; import java.time.format.DateTimeFormatter; -import java.util.Comparator; import java.util.List; import java.util.PriorityQueue; import lombok.Builder; @@ -27,9 +27,10 @@ public record RoomsInfoResponse( ) { public static RoomsInfoResponse of( - Room room, RoomOption option, List coupons, int roomPrice + Room room, RoomOption option, List images, + List coupons, int roomPrice ) { - PriorityQueue pq = new PriorityQueue<>(Comparator.comparingInt(i -> i)); + PriorityQueue pq = new PriorityQueue<>(); for (CouponDetailResponse coupon : coupons) { pq.offer(coupon.price()); } @@ -46,7 +47,7 @@ public static RoomsInfoResponse of( .discountPrice(discountPrice) .amount(room.getAmount()) .status(room.getStatus().name()) - .images(RoomImageResponse.of(room.getImages())) + .images(RoomImageResponse.of(images)) .option(RoomOptionResponse.of(option)) .coupons(coupons) .build(); diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/entity/Room.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/entity/Room.java index 31c7c502..68e3d167 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/entity/Room.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/entity/Room.java @@ -4,7 +4,6 @@ import com.backoffice.upjuyanolja.domain.room.service.usecase.RoomCommandUseCase.RoomUpdate; import com.backoffice.upjuyanolja.global.common.entity.BaseTime; import com.backoffice.upjuyanolja.global.util.DateTimeParser; -import jakarta.persistence.CascadeType; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.EnumType; @@ -15,11 +14,8 @@ import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; -import jakarta.persistence.OneToMany; import java.time.LocalDateTime; import java.time.LocalTime; -import java.util.ArrayList; -import java.util.List; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; @@ -70,10 +66,6 @@ public class Room extends BaseTime { @Comment("객실 상태") private RoomStatus status; - @OneToMany(mappedBy = "room", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) - @Comment("객실 이미지 식별자") - private List images = new ArrayList<>(); - @Builder public Room( @@ -85,8 +77,7 @@ public Room( int amount, LocalTime checkInTime, LocalTime checkOutTime, - RoomStatus status, - List images + RoomStatus status ) { this.id = id; this.accommodation = accommodation; @@ -97,7 +88,6 @@ public Room( this.checkInTime = checkInTime; this.checkOutTime = checkOutTime; this.status = status; - this.images = images; } public void updateRoom(RoomUpdate request) { diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomCustomRepositoryImpl.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomCustomRepositoryImpl.java index eec48722..47c17ba2 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomCustomRepositoryImpl.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomCustomRepositoryImpl.java @@ -39,7 +39,6 @@ public Page findAllByAccommodation(long accommodationId, Pageable pageable .select(room) .from(room) .leftJoin(room.accommodation, accommodation).fetchJoin() - .leftJoin(room.images, roomImage).fetchJoin() .where(createSearchConditionsBuilder(accommodationId)) .offset(pageable.getOffset()) .orderBy(getAllOrderSpecifiers().toArray(OrderSpecifier[]::new)) @@ -48,7 +47,6 @@ public Page findAllByAccommodation(long accommodationId, Pageable pageable .select(room) .from(room) .leftJoin(room.accommodation, accommodation).fetchJoin() - .leftJoin(room.images, roomImage).fetchJoin() .where(room.accommodation.id.eq(accommodationId)); List content = query.fetch(); return PageableExecutionUtils.getPage(content, pageable, () -> countQuery.fetch().size()); diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomImageRepository.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomImageRepository.java index 0174c669..1e7dd8c5 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomImageRepository.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/repository/RoomImageRepository.java @@ -1,8 +1,12 @@ package com.backoffice.upjuyanolja.domain.room.repository; +import com.backoffice.upjuyanolja.domain.room.entity.Room; import com.backoffice.upjuyanolja.domain.room.entity.RoomImage; +import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; public interface RoomImageRepository extends JpaRepository { + List findByRoom(Room room); + } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomCommandService.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomCommandService.java index 1e70afd6..b721d21a 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomCommandService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomCommandService.java @@ -90,19 +90,18 @@ public RoomInfoResponse saveRoom(Accommodation accommodation, RoomRegisterReques .checkInTime(DateTimeParser.timeParser(request.checkInTime())) .checkOutTime(DateTimeParser.timeParser(request.checkOutTime())) .amount(request.amount()) - .images(new ArrayList<>()) .build() ); - roomImageRepository.saveAll(RoomImageRequest.toEntity(room, request.images())) - .forEach(roomImage -> room.getImages().add(roomImage)); + List roomImages = + roomImageRepository.saveAll(RoomImageRequest.toEntity(room, request.images())); createRoomStock(room); RoomOption roomOption = saveRoomOption(room, request.option()); RoomPrice roomPrice = saveRoomPrice(room, request.price()); - return RoomInfoResponse.of(room, roomOption, roomPrice.getOffWeekDaysMinFee()); + return RoomInfoResponse.of(room, roomOption, roomImages, roomPrice.getOffWeekDaysMinFee()); } public RoomOption saveRoomOption(Room room, RoomOptionRequest request) { @@ -144,14 +143,14 @@ public RoomInfoResponse modifyRoom(long memberId, long roomId, RoomUpdateRequest updateRoom(room, request); RoomOption roomOption = updateRoomOption(room, request.option().toRoomOptionUpdateDto()); RoomPrice roomPrice = updateRoomPrice(room, request.price()); - + List roomImages = roomQueryUseCase.findRoomImageByRoom(room); em.flush(); em.refresh(room); em.refresh(roomOption); em.refresh(roomPrice); - return RoomInfoResponse.of(room, roomOption, roomPrice.getOffWeekDaysMinFee()); + return RoomInfoResponse.of(room, roomOption, roomImages, roomPrice.getOffWeekDaysMinFee()); } @Override @@ -168,8 +167,9 @@ public RoomInfoResponse deleteRoom(long memberId, long roomId) { roomOption.delete(LocalDateTime.now()); RoomPrice roomPrice = roomQueryUseCase.findRoomPriceByRoom(room); roomPrice.delete(LocalDateTime.now()); + List roomImages = roomQueryUseCase.findRoomImageByRoom(room); - return RoomInfoResponse.of(room, roomOption, roomPrice.getOffWeekDaysMinFee()); + return RoomInfoResponse.of(room, roomOption, roomImages, roomPrice.getOffWeekDaysMinFee()); } @Transactional(readOnly = true) @@ -177,9 +177,10 @@ public List getRoomInfoResponses(Accommodation accommodation) List roomInfoResponses = new ArrayList<>(); accommodation.getRooms() .forEach(room -> { - RoomOption option = roomQueryUseCase.findRoomOptionByRoom(room); - int roomPrice = roomQueryUseCase.findRoomPriceByRoom(room).getOffWeekDaysMinFee(); - roomInfoResponses.add(RoomInfoResponse.of(room, option, roomPrice)); + RoomOption roomOption = roomQueryUseCase.findRoomOptionByRoom(room); + int roomPrice = roomQueryUseCase.findRoomPriceByRoom(room).getOffWeekDaysMinFee(); + List roomImages = roomQueryUseCase.findRoomImageByRoom(room); + roomInfoResponses.add(RoomInfoResponse.of(room, roomOption, roomImages, roomPrice)); } ); @@ -205,7 +206,7 @@ private void updateRoom(Room room, RoomUpdateRequest request) { } room.updateRoom(request.toRoomUpdateDto()); addRoomImages(room, request.addImages()); - roomImageRepository.deleteAll(getRoomImages(request.deleteImages())); + roomImageRepository.deleteAll(deleteRoomImages(request.deleteImages())); } private RoomOption updateRoomOption(Room room, RoomOptionUpdate option) { @@ -239,7 +240,7 @@ private void addRoomImages(Room room, List requests) { roomImageRepository.saveAll(images); } - private List getRoomImages(List requests) { + private List deleteRoomImages(List requests) { List images = new ArrayList<>(); for (RoomImageDeleteRequest request : requests) { images.add(roomImageRepository.findById(request.id()) diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomQueryService.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomQueryService.java index a26a28bd..8020e946 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomQueryService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomQueryService.java @@ -14,6 +14,7 @@ import com.backoffice.upjuyanolja.domain.room.dto.response.RoomPageResponse; import com.backoffice.upjuyanolja.domain.room.dto.response.RoomsInfoResponse; import com.backoffice.upjuyanolja.domain.room.entity.Room; +import com.backoffice.upjuyanolja.domain.room.entity.RoomImage; import com.backoffice.upjuyanolja.domain.room.entity.RoomOption; import com.backoffice.upjuyanolja.domain.room.entity.RoomPrice; import com.backoffice.upjuyanolja.domain.room.entity.RoomStock; @@ -21,6 +22,7 @@ import com.backoffice.upjuyanolja.domain.room.exception.RoomOptionNotFoundException; import com.backoffice.upjuyanolja.domain.room.exception.RoomPriceNotFoundException; import com.backoffice.upjuyanolja.domain.room.exception.RoomStockNotFoundException; +import com.backoffice.upjuyanolja.domain.room.repository.RoomImageRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomOptionRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomPriceRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomRepository; @@ -46,6 +48,7 @@ public class RoomQueryService implements RoomQueryUseCase { private final AccommodationRepository accommodationRepository; private final AccommodationOwnershipRepository accommodationOwnershipRepository; private final RoomRepository roomRepository; + private final RoomImageRepository roomImageRepository; private final RoomOptionRepository roomOptionRepository; private final RoomPriceRepository roomPriceRepository; private final RoomStockRepository roomStockRepository; @@ -75,6 +78,18 @@ public RoomPrice findRoomPriceByRoom(Room room) { .orElseThrow(RoomPriceNotFoundException::new); } + @Override + public List findRoomImageByRoom(Room room) { + return roomImageRepository.findByRoom(room); + } + + @Override + public List getRoomImageUrlByRoom(Room room) { + return roomImageRepository.findByRoom(room).stream() + .map(image -> image.getUrl()) + .toList(); + } + @Override public RoomPageResponse getRooms(long memberId, long accommodationId, Pageable pageable) { Member member = memberGetService.getMemberById(memberId); @@ -86,8 +101,9 @@ public RoomPageResponse getRooms(long memberId, long accommodationId, Pageable p roomPage.get().forEach(room -> { List couponDetails = new ArrayList<>(); List coupons = couponService.getCouponInRoom(room); - RoomOption option = findRoomOptionByRoom(room); + RoomOption roomOption = findRoomOptionByRoom(room); int roomPrice = findRoomPriceByRoom(room).getOffWeekDaysMinFee(); + List roomImage = findRoomImageByRoom(room); couponDetails.addAll(couponService .getSortedDiscountTypeCouponResponseInRoom( @@ -100,8 +116,11 @@ public RoomPageResponse getRooms(long memberId, long accommodationId, Pageable p coupons, DiscountType.RATE) ); - rooms.add(RoomsInfoResponse.of(room, option, couponDetails, - roomPrice)); + rooms.add(RoomsInfoResponse.of( + room, roomOption, roomImage, + couponDetails, roomPrice + ) + ); }); return RoomPageResponse.builder() .pageNum(roomPage.getNumber()) @@ -121,8 +140,9 @@ public RoomInfoResponse getRoom(long memberId, long roomId) { RoomOption option = findRoomOptionByRoom(room); int roomPrice = findRoomPriceByRoom(room).getOffWeekDaysMinFee(); + List roomImage = findRoomImageByRoom(room); - return RoomInfoResponse.of(room, option, roomPrice); + return RoomInfoResponse.of(room, option, roomImage, roomPrice); } @Override @@ -144,7 +164,7 @@ public List getFilteredRoomStocksByDate( public Map getMinRoomPriceWithRoom(List rooms) { Map roomMinPriceMap = new HashMap<>(); - for (Room room: rooms) { + for (Room room : rooms) { int roomPrice = findRoomPriceByRoom(room).getOffWeekDaysMinFee(); roomMinPriceMap.put(room, roomPrice); } diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/usecase/RoomQueryUseCase.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/usecase/RoomQueryUseCase.java index 3775a7ee..bd227a48 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/usecase/RoomQueryUseCase.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/usecase/RoomQueryUseCase.java @@ -3,6 +3,7 @@ import com.backoffice.upjuyanolja.domain.room.dto.response.RoomInfoResponse; import com.backoffice.upjuyanolja.domain.room.dto.response.RoomPageResponse; import com.backoffice.upjuyanolja.domain.room.entity.Room; +import com.backoffice.upjuyanolja.domain.room.entity.RoomImage; import com.backoffice.upjuyanolja.domain.room.entity.RoomOption; import com.backoffice.upjuyanolja.domain.room.entity.RoomPrice; import com.backoffice.upjuyanolja.domain.room.entity.RoomStock; @@ -21,6 +22,10 @@ public interface RoomQueryUseCase { RoomPrice findRoomPriceByRoom(Room room); + List findRoomImageByRoom(Room room); + + List getRoomImageUrlByRoom(Room room); + RoomPageResponse getRooms(long memberId, long accommodationId, Pageable pageable); RoomInfoResponse getRoom(long memberId, long roomId); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationStockServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationStockServiceTest.java index 08bf5f92..4bcb3574 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationStockServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationStockServiceTest.java @@ -3,7 +3,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import com.backoffice.upjuyanolja.domain.accommodation.entity.Accommodation; -import com.backoffice.upjuyanolja.domain.accommodation.entity.AccommodationOption; import com.backoffice.upjuyanolja.domain.accommodation.entity.Category; import com.backoffice.upjuyanolja.domain.accommodation.repository.AccommodationRepository; import com.backoffice.upjuyanolja.domain.accommodation.repository.CategoryRepository; @@ -16,15 +15,12 @@ import com.backoffice.upjuyanolja.domain.reservation.exception.InvalidReservationInfoException; import com.backoffice.upjuyanolja.domain.reservation.service.ReservationStockService; import com.backoffice.upjuyanolja.domain.room.entity.Room; -import com.backoffice.upjuyanolja.domain.room.entity.RoomOption; -import com.backoffice.upjuyanolja.domain.room.entity.RoomPrice; import com.backoffice.upjuyanolja.domain.room.entity.RoomStatus; import com.backoffice.upjuyanolja.domain.room.entity.RoomStock; import com.backoffice.upjuyanolja.domain.room.repository.RoomRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomStockRepository; import jakarta.persistence.EntityManager; import jakarta.persistence.PersistenceContext; -import jakarta.transaction.Transactional; import java.time.LocalDate; import java.time.LocalTime; import java.util.ArrayList; @@ -39,6 +35,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.transaction.annotation.Transactional; @Slf4j @Transactional @@ -118,10 +115,8 @@ private Room createRoom() { .maxCapacity(3) .checkInTime(LocalTime.of(15, 0, 0)) .checkOutTime(LocalTime.of(11, 0, 0)) - .amount(858) .status(RoomStatus.SELLING) - .images(new ArrayList<>()) .build(); roomRepository.save(room); From b59f91a7f4ee2583759366b33639784f17db500c Mon Sep 17 00:00:00 2001 From: HyunA Date: Sun, 4 Feb 2024 03:46:30 +0900 Subject: [PATCH 15/21] =?UTF-8?q?feat:=20room=EC=97=90=20=ED=95=B4?= =?UTF-8?q?=EB=8B=B9=20=ED=95=98=EB=8A=94=20=EB=AA=A8=EB=93=A0=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20DB=EC=97=90=EC=84=9C=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=20=ED=95=98=EB=8A=94=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/room/service/RoomCommandService.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomCommandService.java b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomCommandService.java index b721d21a..d73afd2f 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomCommandService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/room/service/RoomCommandService.java @@ -167,7 +167,7 @@ public RoomInfoResponse deleteRoom(long memberId, long roomId) { roomOption.delete(LocalDateTime.now()); RoomPrice roomPrice = roomQueryUseCase.findRoomPriceByRoom(room); roomPrice.delete(LocalDateTime.now()); - List roomImages = roomQueryUseCase.findRoomImageByRoom(room); + List roomImages = deleteAllRoomImages(room); return RoomInfoResponse.of(room, roomOption, roomImages, roomPrice.getOffWeekDaysMinFee()); } @@ -205,8 +205,10 @@ private void updateRoom(Room room, RoomUpdateRequest request) { updateRoomStock(room, request.amount() - room.getAmount()); } room.updateRoom(request.toRoomUpdateDto()); + addRoomImages(room, request.addImages()); - roomImageRepository.deleteAll(deleteRoomImages(request.deleteImages())); + deleteRoomImages(request.deleteImages()); + } private RoomOption updateRoomOption(Room room, RoomOptionUpdate option) { @@ -240,12 +242,20 @@ private void addRoomImages(Room room, List requests) { roomImageRepository.saveAll(images); } - private List deleteRoomImages(List requests) { + private void deleteRoomImages(List requests) { List images = new ArrayList<>(); for (RoomImageDeleteRequest request : requests) { images.add(roomImageRepository.findById(request.id()) .orElseThrow(RoomImageNotFoundException::new)); } + + roomImageRepository.deleteAll(images); + } + + private List deleteAllRoomImages(Room room) { + List images = roomQueryUseCase.findRoomImageByRoom(room); + roomImageRepository.deleteAll(images); + return images; } From 934d74295803a139247f6d0162c01eb26af13fbe Mon Sep 17 00:00:00 2001 From: HyunA Date: Sun, 4 Feb 2024 03:47:22 +0900 Subject: [PATCH 16/21] =?UTF-8?q?test:=20Room=EA=B3=BC=20Image=20=EC=96=91?= =?UTF-8?q?=EB=B0=A9=ED=96=A5=20=EC=82=AD=EC=A0=9C=EC=97=90=20=EB=94=B0?= =?UTF-8?q?=EB=A5=B8=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EB=B0=8F=20=EB=B9=8C=EB=93=9C=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AccommodationOwnershipRepositoryTest.java | 1 - .../unit/service/AccommodationCommandServiceTest.java | 1 - .../unit/service/AccommodationQueryServiceTest.java | 1 - .../docs/CouponBackofficeControllerDocsTest.java | 1 - .../controller/CouponBackofficeControllerTest.java | 1 - .../coupon/unit/repository/CouponRepositoryTest.java | 1 - .../unit/service/CouponBackofficeServiceTest.java | 1 - .../docs/ReservationControllerDocsTest.java | 1 - .../unit/controller/ReservationControllerTest.java | 1 - .../unit/repository/ReservationRepositoryTest.java | 1 - .../unit/service/ReservationServiceTest.java | 1 - .../room/unit/repository/RoomRepositoryTest.java | 1 - .../room/unit/service/RoomCommandServiceTest.java | 10 ++-------- .../domain/room/unit/service/RoomQueryServiceTest.java | 10 ++++++---- 14 files changed, 8 insertions(+), 24 deletions(-) diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/repository/AccommodationOwnershipRepositoryTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/repository/AccommodationOwnershipRepositoryTest.java index 9e1f0603..87f4251c 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/repository/AccommodationOwnershipRepositoryTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/repository/AccommodationOwnershipRepositoryTest.java @@ -180,7 +180,6 @@ private Room saveRoom(Accommodation accommodation) { .checkOutTime(LocalTime.of(11, 0, 0)) .amount(858) .status(RoomStatus.SELLING) - .images(new ArrayList<>()) .build()); } diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationCommandServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationCommandServiceTest.java index a1fcdcb1..72b185a9 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationCommandServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationCommandServiceTest.java @@ -206,7 +206,6 @@ void _willSuccess() { .checkOutTime(LocalTime.of(11, 0, 0)) .amount(858) .status(RoomStatus.SELLING) - .images(new ArrayList<>()) .build(); Accommodation savedAccommodation = Accommodation.builder() .id(1L) diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationQueryServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationQueryServiceTest.java index 1ae89711..caddf368 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationQueryServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/unit/service/AccommodationQueryServiceTest.java @@ -109,7 +109,6 @@ void _willSuccess() { .checkOutTime(LocalTime.of(11, 0, 0)) .amount(858) .status(RoomStatus.SELLING) - .images(new ArrayList<>()) .build(); Accommodation savedAccommodation = Accommodation.builder() .id(1L) diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/docs/CouponBackofficeControllerDocsTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/docs/CouponBackofficeControllerDocsTest.java index 38717c5e..bfb5df80 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/docs/CouponBackofficeControllerDocsTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/docs/CouponBackofficeControllerDocsTest.java @@ -732,7 +732,6 @@ private Room createRoom( .checkOutTime(LocalTime.of(11, 0, 0)) .amount(858) .status(RoomStatus.SELLING) - .images(new ArrayList<>()) .build(); } diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/controller/CouponBackofficeControllerTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/controller/CouponBackofficeControllerTest.java index 23d49062..e20b8a5a 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/controller/CouponBackofficeControllerTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/controller/CouponBackofficeControllerTest.java @@ -536,7 +536,6 @@ private Room createRoom( .checkOutTime(LocalTime.of(11, 0, 0)) .amount(858) .status(RoomStatus.SELLING) - .images(new ArrayList<>()) .build(); } diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/repository/CouponRepositoryTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/repository/CouponRepositoryTest.java index d458406b..ab960aee 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/repository/CouponRepositoryTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/repository/CouponRepositoryTest.java @@ -258,7 +258,6 @@ private Room createRoom(Long roomId, String roomName, Accommodation mockAccommod .checkOutTime(LocalTime.of(11, 0, 0)) .amount(858) .status(RoomStatus.SELLING) - .images(new ArrayList<>()) .build(); } diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/service/CouponBackofficeServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/service/CouponBackofficeServiceTest.java index 693741fe..f020bcfe 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/service/CouponBackofficeServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/coupon/unit/service/CouponBackofficeServiceTest.java @@ -167,7 +167,6 @@ private Room createRoom( .checkOutTime(LocalTime.of(11, 0, 0)) .amount(858) .status(RoomStatus.SELLING) - .images(new ArrayList<>()) .build(); } } diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/docs/ReservationControllerDocsTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/docs/ReservationControllerDocsTest.java index 404d7e62..48249c84 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/docs/ReservationControllerDocsTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/docs/ReservationControllerDocsTest.java @@ -123,7 +123,6 @@ private static Room createRoom() { .checkOutTime(LocalTime.of(11, 0, 0)) .amount(858) .status(RoomStatus.SELLING) - .images(new ArrayList<>()) .build(); return room; } diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/controller/ReservationControllerTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/controller/ReservationControllerTest.java index acdb4151..38fcddcd 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/controller/ReservationControllerTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/controller/ReservationControllerTest.java @@ -131,7 +131,6 @@ private static Room createRoom() { .checkOutTime(LocalTime.of(11, 0, 0)) .amount(858) .status(RoomStatus.SELLING) - .images(new ArrayList<>()) .build(); return room; } diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/repository/ReservationRepositoryTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/repository/ReservationRepositoryTest.java index c415cdb7..b8954eb2 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/repository/ReservationRepositoryTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/repository/ReservationRepositoryTest.java @@ -138,7 +138,6 @@ private Room createRoom() { .checkOutTime(LocalTime.of(11, 0, 0)) .amount(858) .status(RoomStatus.SELLING) - .images(new ArrayList<>()) .build(); roomRepository.save(room); diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationServiceTest.java index d792c02d..533f1c67 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/reservation/unit/service/ReservationServiceTest.java @@ -165,7 +165,6 @@ private static Room createRoom(Long id, RoomStatus status) { .checkOutTime(LocalTime.of(11, 0, 0)) .amount(858) .status(status) - .images(new ArrayList<>()) .build(); return room; } diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/repository/RoomRepositoryTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/repository/RoomRepositoryTest.java index 8ffd3b66..1de47725 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/repository/RoomRepositoryTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/repository/RoomRepositoryTest.java @@ -100,7 +100,6 @@ private void saveRoom(Accommodation accommodation) { .checkOutTime(LocalTime.of(11, 0, 0)) .amount(858) .status(RoomStatus.SELLING) - .images(new ArrayList<>()) .build()); } diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomCommandServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomCommandServiceTest.java index c22e53bb..2d5af020 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomCommandServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomCommandServiceTest.java @@ -153,7 +153,6 @@ void _willSuccess() { .checkOutTime(LocalTime.of(11, 0, 0)) .amount(858) .status(RoomStatus.SELLING) - .images(new ArrayList<>()) .build(); RoomOption roomOption = RoomOption.builder() @@ -189,7 +188,6 @@ void _willSuccess() { .checkOutTime(LocalTime.of(11, 0, 0)) .amount(858) .status(RoomStatus.SELLING) - .images(List.of(roomImage)) .build(); given(memberGetService.getMemberById(any(Long.TYPE))).willReturn(member); @@ -370,7 +368,6 @@ void _willSuccess() { .checkOutTime(LocalTime.of(11, 0, 0)) .amount(858) .status(RoomStatus.SELLING) - .images(new ArrayList<>()) .build(); RoomOption roomOption = RoomOption.builder() @@ -406,7 +403,6 @@ void _willSuccess() { .checkOutTime(LocalTime.of(11, 0, 0)) .amount(858) .status(RoomStatus.SELLING) - .images(List.of(roomImage)) .build(); given(roomRepository.existsRoomByNameAndAccommodation( @@ -570,7 +566,6 @@ void _willSuccess() { .checkOutTime(LocalTime.of(11, 0, 0)) .amount(858) .status(RoomStatus.SELLING) - .images(List.of(roomImage1)) .build(); RoomOption roomOption = RoomOption.builder() @@ -611,7 +606,6 @@ void _willSuccess() { .checkOutTime(LocalTime.of(11, 0, 0)) .amount(858) .status(RoomStatus.STOP_SELLING) - .images(List.of(roomImage2, roomImage3)) .build(); given(memberGetService.getMemberById(any(Long.TYPE))).willReturn(member); @@ -713,7 +707,6 @@ void _willSuccess() { .checkOutTime(LocalTime.of(11, 0, 0)) .amount(858) .status(RoomStatus.SELLING) - .images(List.of(roomImage1)) .build(); RoomOption roomOption = RoomOption.builder() @@ -734,9 +727,10 @@ void _willSuccess() { .build(); given(memberGetService.getMemberById(any(Long.TYPE))).willReturn(member); + given(roomRepository.findById(any(Long.TYPE))).willReturn(Optional.of(room)); + given(roomQueryUseCase.findRoomImageByRoom(room)).willReturn(List.of(roomImage1)); given(roomQueryUseCase.findRoomOptionByRoom(any(Room.class))).willReturn(roomOption); given(roomQueryUseCase.findRoomPriceByRoom(any(Room.class))).willReturn(roomPrice); - given(roomRepository.findById(any(Long.TYPE))).willReturn(Optional.of(room)); given(accommodationOwnershipRepository .existsAccommodationOwnershipByMemberAndAccommodation( any(Member.class), diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomQueryServiceTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomQueryServiceTest.java index 82f7acd0..4fad3744 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomQueryServiceTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/room/unit/service/RoomQueryServiceTest.java @@ -28,6 +28,7 @@ import com.backoffice.upjuyanolja.domain.room.entity.RoomOption; import com.backoffice.upjuyanolja.domain.room.entity.RoomPrice; import com.backoffice.upjuyanolja.domain.room.entity.RoomStatus; +import com.backoffice.upjuyanolja.domain.room.repository.RoomImageRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomOptionRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomPriceRepository; import com.backoffice.upjuyanolja.domain.room.repository.RoomRepository; @@ -67,6 +68,9 @@ public class RoomQueryServiceTest { @Mock private RoomRepository roomRepository; + @Mock + private RoomImageRepository roomImageRepository; + @Mock private RoomOptionRepository roomOptionRepository; @@ -126,10 +130,8 @@ void _willSuccess() { .checkOutTime(LocalTime.of(11, 0, 0)) .amount(858) .status(RoomStatus.SELLING) - .images(new ArrayList<>()) .build(); - RoomImage roomImage = RoomImage.builder() .id(1L) .room(room) @@ -146,7 +148,6 @@ void _willSuccess() { .checkOutTime(LocalTime.of(11, 0, 0)) .amount(858) .status(RoomStatus.SELLING) - .images(List.of(roomImage)) .build(); RoomOption savedRoomOption = RoomOption.builder() @@ -228,6 +229,7 @@ void _willSuccess() { .willReturn(true); given(roomRepository.findAllByAccommodation(any(Long.TYPE), any(Pageable.class))) .willReturn(new PageImpl<>(List.of(savedRoom))); + given(roomImageRepository.findByRoom(any(Room.class))).willReturn(List.of(roomImage)); given(roomOptionRepository.findByRoom(savedRoom)) .willReturn(Optional.of(savedRoomOption)); given(roomPriceRepository.findByRoom(savedRoom)) @@ -340,7 +342,6 @@ void _willSuccess() { .checkOutTime(LocalTime.of(11, 0, 0)) .amount(858) .status(RoomStatus.SELLING) - .images(List.of(roomImage1)) .build(); RoomOption roomOption = RoomOption.builder() @@ -362,6 +363,7 @@ void _willSuccess() { given(memberGetService.getMemberById(any(Long.TYPE))).willReturn(member); given(roomRepository.findById(any(Long.TYPE))).willReturn(Optional.of(room)); + given(roomImageRepository.findByRoom(room)).willReturn(List.of(roomImage1)); given(roomOptionRepository.findByRoom(room)) .willReturn(Optional.of(roomOption)); given(roomPriceRepository.findByRoom(room)) From 40d79aa2d258f2fe6962a97f2baa832f6c16b4db Mon Sep 17 00:00:00 2001 From: HyunA Date: Sun, 4 Feb 2024 19:44:05 +0900 Subject: [PATCH 17/21] =?UTF-8?q?other:=20=EC=A3=BC=EC=84=9D=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=ED=95=9C=20redis=20=EB=8B=A4=EC=8B=9C=20=EB=B3=B5?= =?UTF-8?q?=EC=9B=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/service/MemberAuthService.java | 52 +++++++++---------- .../member/service/OwnerAuthService.java | 32 ++++++------ 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/member/service/MemberAuthService.java b/src/main/java/com/backoffice/upjuyanolja/domain/member/service/MemberAuthService.java index 8d4865bd..12749132 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/member/service/MemberAuthService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/member/service/MemberAuthService.java @@ -37,7 +37,7 @@ public class MemberAuthService implements AuthServiceProvider Date: Tue, 6 Feb 2024 00:39:26 +0900 Subject: [PATCH 18/21] =?UTF-8?q?fix:=20=EC=88=99=EC=86=8C=20=EC=8B=9D?= =?UTF-8?q?=EB=B3=84=EC=9E=90=EB=8A=94=20=EB=B0=9B=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20DTO=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../accommodation/dto/request/AccommodationOptionRequest.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/request/AccommodationOptionRequest.java b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/request/AccommodationOptionRequest.java index bf85d6ed..028b890c 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/request/AccommodationOptionRequest.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/accommodation/dto/request/AccommodationOptionRequest.java @@ -7,10 +7,6 @@ @Builder public record AccommodationOptionRequest( - - @NotNull(message = "숙소 ID를 입력하세요.") - Long AccommodationId, - @NotNull(message = "객실 내 취사 여부를 입력하세요.") boolean cooking, From 9d1d12d83d45eb17fb6d7d189b7288716c0ec566 Mon Sep 17 00:00:00 2001 From: JeongUijeong Date: Tue, 6 Feb 2024 00:40:18 +0900 Subject: [PATCH 19/21] =?UTF-8?q?refactor:=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=EC=BD=94=EB=93=9C=EB=8A=94=20=EC=88=9C?= =?UTF-8?q?=EC=B0=A8=EC=A0=81=EC=9C=BC=EB=A1=9C=20=EC=9E=91=EC=84=B1?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/exception/ErrorCode.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/backoffice/upjuyanolja/global/exception/ErrorCode.java b/src/main/java/com/backoffice/upjuyanolja/global/exception/ErrorCode.java index 310effb4..720e54fa 100644 --- a/src/main/java/com/backoffice/upjuyanolja/global/exception/ErrorCode.java +++ b/src/main/java/com/backoffice/upjuyanolja/global/exception/ErrorCode.java @@ -25,24 +25,24 @@ public enum ErrorCode { // Accommodation ACCOMMODATION_NOT_FOUND(HttpStatus.NOT_FOUND, 2000, "숙소 정보를 찾을 수 없습니다."), - ACCOMMODATION_OPTION_NOT_FOUND(HttpStatus.NOT_FOUND, 2001, "숙소 옵션 정보를 찾을 수 없습니다."), - RESERVATION_NOT_POSSIBLE(HttpStatus.BAD_REQUEST, 2002, "예약이 불가능한 방입니다."), - WRONG_CATEGORY(HttpStatus.BAD_REQUEST, 2003, "알맞지 않은 카테고리입니다."), - ACCOMMODATION_IMAGE_NOT_EXISTS(HttpStatus.BAD_REQUEST, 2004, "숙소 이미지를 1개 이상 등록해야 합니다."), - FAILED_SAVE_IMAGE(HttpStatus.BAD_REQUEST, 2005, "이미지 저장에 실패했습니다."), + RESERVATION_NOT_POSSIBLE(HttpStatus.BAD_REQUEST, 2001, "예약이 불가능한 방입니다."), + WRONG_CATEGORY(HttpStatus.BAD_REQUEST, 2002, "알맞지 않은 카테고리입니다."), + ACCOMMODATION_IMAGE_NOT_EXISTS(HttpStatus.BAD_REQUEST, 2003, "숙소 이미지를 1개 이상 등록해야 합니다."), + FAILED_SAVE_IMAGE(HttpStatus.BAD_REQUEST, 2004, "이미지 저장에 실패했습니다."), + ACCOMMODATION_OPTION_NOT_FOUND(HttpStatus.NOT_FOUND, 2005, "숙소 옵션 정보를 찾을 수 없습니다."), // Room ROOM_NOT_FOUND(HttpStatus.NOT_FOUND, 3000, "객실 정보를 찾을 수 없습니다."), - ROOM_OPTION_NOT_FOUND(HttpStatus.NOT_FOUND, 3001, "객실 옵션 정보를 찾을 수 없습니다."), - ROOM_PRICE_NOT_FOUND(HttpStatus.NOT_FOUND, 3002, "객실 가격 정보를 찾을 수 없습니다."), - DUPLICATED_ROOM_NAME(HttpStatus.BAD_REQUEST, 3003, "중복된 객실 이름입니다."), - INVALID_TIME_FORMAT(HttpStatus.BAD_REQUEST, 3004, "올바르지 않은 형식의 시간입니다.(HH:mm)"), - INVALID_ROOM_STATUS(HttpStatus.BAD_REQUEST, 3005, "올바르지 않은 형식의 객실 상태입니다."), - ROOM_STOCK_NOT_FOUND(HttpStatus.NOT_FOUND, 3006, "객실 재고 정보를 찾을 수 없습니다."), - ROOM_IMAGE_NOT_FOUND(HttpStatus.NOT_FOUND, 3007, "객실 이미지 정보를 찾을 수 없습니다."), - ROOM_NOT_EXISTS(HttpStatus.BAD_REQUEST, 3008, "객실을 1개 이상 등록해야 합니다."), - ROOM_IMAGE_NOT_EXISTS(HttpStatus.BAD_REQUEST, 3009, "객실 이미지를 1개 이상 등록해야 합니다."), - LAST_ROOM(HttpStatus.BAD_REQUEST, 3010, "마지막 객실은 삭제할 수 없습니다."), + DUPLICATED_ROOM_NAME(HttpStatus.BAD_REQUEST, 3001, "중복된 객실 이름입니다."), + INVALID_TIME_FORMAT(HttpStatus.BAD_REQUEST, 3002, "올바르지 않은 형식의 시간입니다.(HH:mm)"), + INVALID_ROOM_STATUS(HttpStatus.BAD_REQUEST, 3003, "올바르지 않은 형식의 객실 상태입니다."), + ROOM_STOCK_NOT_FOUND(HttpStatus.NOT_FOUND, 3004, "객실 재고 정보를 찾을 수 없습니다."), + ROOM_IMAGE_NOT_FOUND(HttpStatus.NOT_FOUND, 3005, "객실 이미지 정보를 찾을 수 없습니다."), + ROOM_NOT_EXISTS(HttpStatus.BAD_REQUEST, 3006, "객실을 1개 이상 등록해야 합니다."), + ROOM_IMAGE_NOT_EXISTS(HttpStatus.BAD_REQUEST, 3007, "객실 이미지를 1개 이상 등록해야 합니다."), + LAST_ROOM(HttpStatus.BAD_REQUEST, 3008, "마지막 객실은 삭제할 수 없습니다."), + ROOM_OPTION_NOT_FOUND(HttpStatus.NOT_FOUND, 3009, "객실 옵션 정보를 찾을 수 없습니다."), + ROOM_PRICE_NOT_FOUND(HttpStatus.NOT_FOUND, 3010, "객실 가격 정보를 찾을 수 없습니다."), // Reservation RESERVATION_PAYMENT_FAILED(HttpStatus.BAD_REQUEST, 4000, "결제에 실패 했습니다."), From 7f3a94949437b88d03071ea29e4889fc7a45ea24 Mon Sep 17 00:00:00 2001 From: JeongUijeong Date: Tue, 6 Feb 2024 00:43:52 +0900 Subject: [PATCH 20/21] =?UTF-8?q?test:=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EC=97=90=EC=84=9C=EB=8F=84=20=EC=88=99=EC=86=8C=20=EC=98=B5?= =?UTF-8?q?=EC=85=98=20DTO=EC=97=90=EC=84=9C=20=EC=88=99=EC=86=8C=20?= =?UTF-8?q?=EC=8B=9D=EB=B3=84=EC=9E=90=EB=A5=BC=20=EB=B0=9B=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../docs/AccommodationBackofficeControllerDocsTest.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/docs/AccommodationBackofficeControllerDocsTest.java b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/docs/AccommodationBackofficeControllerDocsTest.java index 996d6936..f50c7f98 100644 --- a/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/docs/AccommodationBackofficeControllerDocsTest.java +++ b/src/test/java/com/backoffice/upjuyanolja/domain/accommodation/docs/AccommodationBackofficeControllerDocsTest.java @@ -199,10 +199,6 @@ void registerAccommodation() throws Exception { .value(accommodationImageRequestDescriptions.descriptionsForProperty( "url"))), fieldWithPath("option").description("숙소 옵션"), - fieldWithPath("option.AccommodationId").description("숙소 식별자") - .attributes(key("constraints") - .value(accommodationOptionRequestDescriptions.descriptionsForProperty( - "AccommodationId"))), fieldWithPath("option.cooking").description("객실 내 취사 여부") .attributes(key("constraints") .value(accommodationOptionRequestDescriptions.descriptionsForProperty( From 9b620022de4d374ad982fc55dcfa43799ac8809e Mon Sep 17 00:00:00 2001 From: chaewon12 Date: Tue, 6 Feb 2024 19:49:28 +0900 Subject: [PATCH 21/21] =?UTF-8?q?refactor:=20roomPrice=20=EC=BF=BC?= =?UTF-8?q?=EB=A6=AC=20=EC=A4=91=EB=B3=B5=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/ReservationService.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/backoffice/upjuyanolja/domain/reservation/service/ReservationService.java b/src/main/java/com/backoffice/upjuyanolja/domain/reservation/service/ReservationService.java index f0ab9878..1bb1ab7c 100644 --- a/src/main/java/com/backoffice/upjuyanolja/domain/reservation/service/ReservationService.java +++ b/src/main/java/com/backoffice/upjuyanolja/domain/reservation/service/ReservationService.java @@ -26,9 +26,6 @@ import com.backoffice.upjuyanolja.domain.room.entity.RoomStatus; import com.backoffice.upjuyanolja.domain.room.entity.RoomStock; import com.backoffice.upjuyanolja.domain.room.repository.RoomRepository; -import com.backoffice.upjuyanolja.domain.room.service.RoomCommandService; -import com.backoffice.upjuyanolja.domain.room.service.RoomQueryService; -import com.backoffice.upjuyanolja.domain.room.service.usecase.RoomCommandUseCase; import com.backoffice.upjuyanolja.domain.room.service.usecase.RoomQueryUseCase; import java.time.LocalDate; import java.time.Period; @@ -73,8 +70,8 @@ public void create(Member currentMember, CreateReservationRequest request) { Coupon coupon = (request.getCouponId() == null) ? null : getValidCoupon(request, room); // 할인 금액 계산 - int totalAmount = getValidTotalAmount(request.getTotalPrice(), - roomQueryUseCase.findRoomPriceByRoom(room).getOffWeekDaysMinFee(), coupon); + int roomPrice = roomQueryUseCase.findRoomPriceByRoom(room).getOffWeekDaysMinFee(); + int totalAmount = getValidTotalAmount(request.getTotalPrice(), roomPrice, coupon); /* * 객실 재고 차감 @@ -99,7 +96,7 @@ public void create(Member currentMember, CreateReservationRequest request) { * 예외 발생 시 보상트랜잭션(재고 롤백) 수행 * */ try { - createOrder(currentMember, request, room, coupon, totalAmount); + createOrder(currentMember, request, room, coupon, roomPrice, totalAmount); } catch (Exception e) { for (RoomStock roomStock : roomStocks) { stockService.increaseRoomStock(roomStock.getId()); //lock @@ -177,12 +174,13 @@ private void decreaseRoomStocks(List roomStocks) { } private void createOrder( - Member member, CreateReservationRequest request, Room room, Coupon coupon, int totalAmount + Member member, CreateReservationRequest request, Room room, Coupon coupon, + int roomPrice, int totalAmount ) { /* * 예약 객실 저장 * */ - ReservationRoom reservationRoom = saveReservationRoom(request, room); + ReservationRoom reservationRoom = saveReservationRoom(request, room, roomPrice); /* * 예약 저장 @@ -203,12 +201,13 @@ private void createOrder( } } - private ReservationRoom saveReservationRoom(CreateReservationRequest request, Room room) { + private ReservationRoom saveReservationRoom(CreateReservationRequest request, Room room, + int roomPrice) { return reservationRoomRepository.save(ReservationRoom.builder() .room(room) .startDate(request.getStartDate()) .endDate(request.getEndDate()) - .price(roomQueryUseCase.findRoomPriceByRoom(room).getOffWeekDaysMinFee()) + .price(roomPrice) .build()); }