Skip to content

Commit

Permalink
Api-v0.2.3-4
Browse files Browse the repository at this point in the history
Api-v0.2.3-4
  • Loading branch information
ImNM authored Feb 27, 2023
2 parents db26a58 + 839c468 commit 31bc469
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.lang.Nullable;
Expand Down Expand Up @@ -43,7 +44,7 @@ public class CreateTicketItemRequest {
@Schema(defaultValue = "0", nullable = false, example = "4000")
private Long price;

@NotNull
@Positive
@Schema(nullable = false, example = "100")
private Long supplyCount;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ public TicketItem(
this.supplyCount = supplyCount;
this.purchaseLimit = purchaseLimit;
this.type = type;
this.accountInfo = AccountInfoVo.valueOf(bankName, accountNumber, accountHolder);
this.accountInfo =
payType.equals(TicketPayType.DUDOONG_TICKET)
? AccountInfoVo.valueOf(bankName, accountNumber, accountHolder)
: null;
this.isQuantityPublic = isQuantityPublic;
this.isSellable = isSellable;
this.saleStartAt = saleStartAt;
Expand All @@ -117,6 +120,14 @@ public void addItemOptionGroup(OptionGroup optionGroup) {
throw ForbiddenOptionChangeException.EXCEPTION;
}

// 무료티켓에 유료 옵션 적용 불가
if (this.payType.equals(TicketPayType.FREE_TICKET)
&& optionGroup.getOptions().stream()
.anyMatch(
option -> option.getAdditionalPrice().isGreaterThan(Money.ZERO))) {
throw ForbiddenOptionPriceException.EXCEPTION;
}

// 중복 체크
if (this.hasItemOptionGroup(optionGroup.getId())) {
throw DuplicatedItemOptionGroupException.EXCEPTION;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package band.gosrock.domain.domains.ticket_item.exception;


import band.gosrock.common.exception.DuDoongCodeException;

public class ForbiddenOptionPriceException extends DuDoongCodeException {

public static final DuDoongCodeException EXCEPTION = new ForbiddenOptionPriceException();

private ForbiddenOptionPriceException() {
super(TicketItemErrorCode.FORBIDDEN_OPTION_PRICE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ public enum TicketItemErrorCode implements BaseErrorCode {
@ExplainError("제휴되지 않은 호스트가 유료티켓 생성을 요청했을때 발생하는 오류입니다.")
INVALID_PARTNER(BAD_REQUEST, "Ticket_Item_400_3", "제휴된 호스트가 아닙니다."),
@ExplainError("해당 티켓상품에 적용되지 않은 옵션을 취소 시도할 경우 발생하는 오류입니다.")
NOT_APPLIED_ITEM_OPTION_GROUP(BAD_REQUEST, "Item_Option_Group_400_3", "적용되지 않은 옵션입니다.");
NOT_APPLIED_ITEM_OPTION_GROUP(BAD_REQUEST, "Item_Option_Group_400_3", "적용되지 않은 옵션입니다."),
@ExplainError("무료 티켓에 유료 옵션을 적용하려고 했을 때 발생하는 오류입니다.")
FORBIDDEN_OPTION_PRICE(BAD_REQUEST, "Item_Option_Group_400_4", "유료 옵션을 적용할 수 없습니다.");

private Integer status;
private String code;
Expand Down

0 comments on commit 31bc469

Please sign in to comment.