[#18] 코드 정리 및 일부 컨벤션 통일 #19

Merged
pricelees merged 24 commits from refactor/#18 into main 2025-07-22 09:05:31 +00:00
5 changed files with 4 additions and 58 deletions
Showing only changes of commit f52a511495 - Show all commits

View File

@ -1,9 +1,5 @@
package roomescape.common.exception package roomescape.common.exception
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
import org.springframework.http.HttpStatus
enum class ErrorType( enum class ErrorType(
val description: String val description: String
) { ) {
@ -54,18 +50,4 @@ enum class ErrorType(
PAYMENT_ERROR("결제(취소)에 실패했습니다. 결제(취소) 정보를 확인해주세요."), PAYMENT_ERROR("결제(취소)에 실패했습니다. 결제(취소) 정보를 확인해주세요."),
PAYMENT_SERVER_ERROR("결제 서버에서 에러가 발생하였습니다. 잠시 후 다시 시도해주세요.") PAYMENT_SERVER_ERROR("결제 서버에서 에러가 발생하였습니다. 잠시 후 다시 시도해주세요.")
; ;
companion object {
@JvmStatic
@JsonCreator
fun from(@JsonProperty("errorType") errorType: String): ErrorType {
return entries.toTypedArray()
.firstOrNull { it.name == errorType }
?: throw RoomescapeException(
INVALID_REQUEST_DATA,
"[ErrorType: ${errorType}]",
HttpStatus.BAD_REQUEST
)
}
}
} }

View File

@ -15,14 +15,7 @@ data class MemberResponse(
@field:Schema(description = "회원의 이름") @field:Schema(description = "회원의 이름")
val name: String val name: String
) { )
companion object {
@JvmStatic
fun fromEntity(member: MemberEntity): MemberResponse {
return MemberResponse(member.id!!, member.name)
}
}
}
@Schema(name = "회원 목록 조회 응답", description = "모든 회원의 정보 조회 응답시 사용됩니다.") @Schema(name = "회원 목록 조회 응답", description = "모든 회원의 정보 조회 응답시 사용됩니다.")
data class MembersResponse( data class MembersResponse(

View File

@ -67,21 +67,7 @@ data class ReservationResponse(
@field:Schema(description = "예약 상태", type = "string") @field:Schema(description = "예약 상태", type = "string")
val status: ReservationStatus val status: ReservationStatus
) {
companion object {
@JvmStatic
fun from(reservation: ReservationEntity): ReservationResponse {
return ReservationResponse(
reservation.id!!,
reservation.date,
reservation.member.toResponse(),
reservation.reservationTime.toResponse(),
reservation.theme.toResponse(),
reservation.reservationStatus
) )
}
}
}
fun ReservationEntity.toResponse(): ReservationResponse = ReservationResponse( fun ReservationEntity.toResponse(): ReservationResponse = ReservationResponse(
id = this.id!!, id = this.id!!,

View File

@ -17,15 +17,7 @@ data class ReservationTimeResponse(
@field:Schema(description = "예약 시간", type = "string", example = "09:00") @field:Schema(description = "예약 시간", type = "string", example = "09:00")
val startAt: LocalTime val startAt: LocalTime
) { )
companion object {
@JvmStatic
fun from(reservationTime: ReservationTimeEntity): ReservationTimeResponse {
return ReservationTimeResponse(reservationTime.id!!, reservationTime.startAt)
}
}
}
fun ReservationTimeEntity.toResponse(): ReservationTimeResponse = ReservationTimeResponse( fun ReservationTimeEntity.toResponse(): ReservationTimeResponse = ReservationTimeResponse(
this.id!!, this.startAt this.id!!, this.startAt

View File

@ -37,14 +37,7 @@ data class ThemeResponse(
@field:Schema(description = "테마 썸네일 이미지 URL") @field:Schema(description = "테마 썸네일 이미지 URL")
val thumbnail: String val thumbnail: String
) { )
companion object {
@JvmStatic
fun from(themeEntity: ThemeEntity): ThemeResponse {
return ThemeResponse(themeEntity.id!!, themeEntity.name, themeEntity.description, themeEntity.thumbnail)
}
}
}
fun ThemeEntity.toResponse(): ThemeResponse = ThemeResponse( fun ThemeEntity.toResponse(): ThemeResponse = ThemeResponse(
id = this.id!!, id = this.id!!,