refactor: 공통 응답 DTO를 정상 / 에러로 구분하고 companion object 제거

This commit is contained in:
이상진 2025-07-15 11:22:29 +09:00
parent a876516296
commit 0679365803
2 changed files with 14 additions and 33 deletions

View File

@ -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
)

View File

@ -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
)
}
}
}