-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor: Reservation QueryParameter 리팩토링 (#175)
- Loading branch information
1 parent
f6686e4
commit ff6c44a
Showing
9 changed files
with
89 additions
and
15 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
src/main/java/com/livable/server/core/exception/GlobalErrorCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.livable.server.core.exception; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum GlobalErrorCode implements ErrorCode { | ||
|
||
INVALID_TYPE(HttpStatus.BAD_REQUEST, "입력 형식이 올바르지 않습니다"); | ||
|
||
private final HttpStatus httpStatus; | ||
private final String message; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/java/com/livable/server/reservation/domain/ReservationErrorCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.livable.server.reservation.domain; | ||
|
||
import com.livable.server.core.exception.ErrorCode; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum ReservationErrorCode implements ErrorCode { | ||
|
||
INVALID_DATE_RANGE(HttpStatus.BAD_REQUEST, "날짜 범위가 올바르지 않습니다"); | ||
|
||
private final HttpStatus httpStatus; | ||
private final String message; | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/livable/server/reservation/domain/ReservationRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.livable.server.reservation.domain; | ||
|
||
import com.livable.server.core.exception.GlobalRuntimeException; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDate; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class ReservationRequest { | ||
|
||
|
||
@Getter | ||
public static class DateQuery { | ||
|
||
private final LocalDate startDate; | ||
private final LocalDate endDate; | ||
|
||
public DateQuery(LocalDate startDate, LocalDate endDate) { | ||
validateRange(startDate, endDate); | ||
this.startDate = startDate; | ||
this.endDate = endDate; | ||
} | ||
|
||
private void validateRange(LocalDate startDate, LocalDate endDate) { | ||
if (startDate.isAfter(endDate)) { | ||
throw new GlobalRuntimeException(ReservationErrorCode.INVALID_DATE_RANGE); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters