From fc3a372a31eb33ebdb20a5b0239bde30c3b19a7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=85=B8=EA=B2=BD=EB=AF=BC?= Date: Fri, 17 Feb 2023 02:02:32 +0900 Subject: [PATCH] =?UTF-8?q?refactor=20:=20=EA=B3=B5=EC=97=B0=20=EA=B8=B0?= =?UTF-8?q?=EB=B3=B8=20=EC=A0=95=EB=B3=B4=20=EC=88=98=EC=A0=95=20=EC=A0=95?= =?UTF-8?q?=EC=B1=85=20=EB=B3=80=EA=B2=BD=20(#368)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gosrock/domain/domains/event/domain/Event.java | 14 +++++++------- .../exception/CannotModifyEventBasicException.java | 13 ------------- .../exception/CannotModifyOpenEventException.java | 13 +++++++++++++ .../domains/event/exception/EventErrorCode.java | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) delete mode 100644 DuDoong-Domain/src/main/java/band/gosrock/domain/domains/event/exception/CannotModifyEventBasicException.java create mode 100644 DuDoong-Domain/src/main/java/band/gosrock/domain/domains/event/exception/CannotModifyOpenEventException.java diff --git a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/event/domain/Event.java b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/event/domain/Event.java index 12f37456..4ad45c36 100644 --- a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/event/domain/Event.java +++ b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/event/domain/Event.java @@ -39,8 +39,6 @@ public class Event extends BaseTimeEntity { @Enumerated(EnumType.STRING) private EventStatus status = PREPARING; - private Boolean isUpdated = false; - public LocalDateTime getStartAt() { if (this.eventBasic == null) { return null; @@ -72,10 +70,7 @@ public Boolean isPreparing() { } public void setEventBasic(EventBasic eventBasic) { - if (isUpdated) { - throw CannotModifyEventBasicException.EXCEPTION; - } - this.isUpdated = true; + this.validateOpenStatus(); this.eventBasic = eventBasic; } @@ -85,7 +80,7 @@ public void setEventDetail(EventDetail eventDetail) { } public void setEventPlace(EventPlace eventPlace) { - // 정보 한 번 등록시 변경 불가 + this.validateOpenStatus(); this.eventPlace = eventPlace; } @@ -96,6 +91,11 @@ public Event(Long hostId, String name, LocalDateTime startAt, Long runTime) { Events.raise(EventCreationEvent.of(hostId, name)); } + public void validateOpenStatus() { + if (status == OPEN) throw CannotModifyOpenEventException.EXCEPTION; + // todo : 오픈 전과 후 검증 로직 이름 변경 + } + public void validateStatusOpen() { if (status != OPEN) { throw EventNotOpenException.EXCEPTION; diff --git a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/event/exception/CannotModifyEventBasicException.java b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/event/exception/CannotModifyEventBasicException.java deleted file mode 100644 index ec962bc2..00000000 --- a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/event/exception/CannotModifyEventBasicException.java +++ /dev/null @@ -1,13 +0,0 @@ -package band.gosrock.domain.domains.event.exception; - - -import band.gosrock.common.exception.DuDoongCodeException; - -public class CannotModifyEventBasicException extends DuDoongCodeException { - - public static final DuDoongCodeException EXCEPTION = new CannotModifyEventBasicException(); - - private CannotModifyEventBasicException() { - super(EventErrorCode.CANNOT_MODIFY_EVENT_BASIC); - } -} diff --git a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/event/exception/CannotModifyOpenEventException.java b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/event/exception/CannotModifyOpenEventException.java new file mode 100644 index 00000000..c4e5ad4c --- /dev/null +++ b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/event/exception/CannotModifyOpenEventException.java @@ -0,0 +1,13 @@ +package band.gosrock.domain.domains.event.exception; + + +import band.gosrock.common.exception.DuDoongCodeException; + +public class CannotModifyOpenEventException extends DuDoongCodeException { + + public static final DuDoongCodeException EXCEPTION = new CannotModifyOpenEventException(); + + private CannotModifyOpenEventException() { + super(EventErrorCode.CANNOT_MODIFY_OPEN_EVENT); + } +} diff --git a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/event/exception/EventErrorCode.java b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/event/exception/EventErrorCode.java index 803bea2e..86ab67ef 100644 --- a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/event/exception/EventErrorCode.java +++ b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/event/exception/EventErrorCode.java @@ -19,7 +19,7 @@ public enum EventErrorCode implements BaseErrorCode { HOST_NOT_AUTH_EVENT(BAD_REQUEST, "Event_400_1", "Host Not Auth Event."), EVENT_CANNOT_END_BEFORE_START(BAD_REQUEST, "Event_400_2", "시작 시각은 종료 시각보다 빨라야 합니다."), EVENT_URL_NAME_ALREADY_EXIST(BAD_REQUEST, "Event_400_3", "중복된 URL 표시 이름입니다."), - CANNOT_MODIFY_EVENT_BASIC(BAD_REQUEST, "Event_400_4", "이벤트 기본 정보는 수정할 수 없습니다."), + CANNOT_MODIFY_OPEN_EVENT(BAD_REQUEST, "Event_400_4", "오픈된 이벤트 정보는 수정할 수 없습니다."), EVENT_NOT_OPEN(BAD_REQUEST, "Event_400_5", "아직 오픈되지 않은 이벤트에는 접근할 수 없습니다."), EVENT_TICKETING_TIME_IS_PASSED(BAD_REQUEST, "Event_400_6", "이벤트 시작시간이 지나 티켓팅을 할 수 없습니다."), CANNOT_OPEN_EVENT(BAD_REQUEST, "Event_400_7", "이벤트 오픈 조건을 충족하지 않았습니다."),