generated from pricelees/issue-pr-template
[#7] API 응답 형식 재정의 및 Swagger-UI 관련 코드 패키지 분리 #8
@ -0,0 +1,14 @@
|
||||
package roomescape.common.dto.response
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude
|
||||
import roomescape.common.exception.ErrorType
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
data class CommonApiResponse<T>(
|
||||
val data: T? = null,
|
||||
)
|
||||
|
||||
data class CommonErrorResponse(
|
||||
val errorType: ErrorType,
|
||||
val message: String = errorType.description
|
||||
)
|
||||
@ -1,33 +0,0 @@
|
||||
package roomescape.common.dto.response
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude
|
||||
import roomescape.common.exception.ErrorType
|
||||
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
data class RoomescapeApiResponseKT<T>(
|
||||
val success: Boolean,
|
||||
val data: T? = null,
|
||||
val errorType: ErrorType? = null,
|
||||
val message: String? = null,
|
||||
) {
|
||||
companion object {
|
||||
|
||||
@JvmStatic
|
||||
fun <T> success(data: T? = null): RoomescapeApiResponseKT<T> {
|
||||
return RoomescapeApiResponseKT(
|
||||
success = true,
|
||||
data = data,
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun <T> fail(errorType: ErrorType, message: String? = null): RoomescapeApiResponseKT<T> {
|
||||
return RoomescapeApiResponseKT(
|
||||
success = false,
|
||||
errorType = errorType,
|
||||
message = message ?: errorType.description
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user