Skip to content

Commit

Permalink
Refactor. baseprice 사용 로직 AccommodationEntity의 메서드 사용
Browse files Browse the repository at this point in the history
  • Loading branch information
Miensoap committed Jun 25, 2024
1 parent f19b303 commit aebbb9c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void createProduct(@RequestBody ProductCreateRequest request) {
}

@Tag(name = "Host")
@Operation(summary = "상품 생성")
@Operation(summary = "기간 중 다중 상품 생성")
@PostMapping("/range")
@ResponseStatus(CREATED)
public void createProductRange(@RequestBody ProductRangeCreateRequest request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ public void addPicture(String url) {
pictures.add(new Pictures(this, url));
}

public void addProduct(LocalDate date, int price) {
products.add(ProductEntity.ofOpen(this, date, price));
public void addProduct(LocalDate date, Integer price) {
if(price != null) products.add(ProductEntity.ofOpen(this, date, price));
else addProduct(date);
}

public void addProduct(LocalDate date) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ public void createRangeProduct(Long accommodationId, LocalDate startDate, LocalD
Period between = Period.between(startDate, endDate);
for (int i = 0; i <= between.getDays(); i++) {
LocalDate nowDate = startDate.plusDays(i);
int price = requestPrice == null ? accommodation.getBasePricePerDay() : requestPrice;
accommodation.addProduct(nowDate, price);
accommodation.addProduct(nowDate, requestPrice);
}
}

Expand Down

0 comments on commit aebbb9c

Please sign in to comment.