generated from pricelees/issue-pr-template
refactor: 공통 응답 DTO를 정상 / 에러로 구분하고 companion object 제거
This commit is contained in:
parent
a876516296
commit
0679365803
@ -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