generated from pricelees/issue-pr-template
refactor: API / 에러 응답 객체 코틀린 전환
This commit is contained in:
parent
2e200354e7
commit
06db248bc5
@ -1,15 +1,21 @@
|
|||||||
package roomescape.common.dto.response;
|
package roomescape.common.dto.response
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema
|
||||||
import roomescape.common.exception.ErrorType;
|
import roomescape.common.exception.ErrorType
|
||||||
|
|
||||||
@Schema(name = "예외 응답", description = "예외 발생 시 응답에 사용됩니다.")
|
@Schema(name = "예외 응답", description = "예외 발생 시 응답에 사용됩니다.")
|
||||||
public record ErrorResponse(
|
@JvmRecord
|
||||||
@Schema(description = "발생한 예외의 종류", example = "INVALID_REQUEST_DATA") ErrorType errorType,
|
data class ErrorResponse(
|
||||||
@Schema(description = "예외 메시지", example = "요청 데이터 값이 올바르지 않습니다.") String message
|
@field:Schema(description = "발생한 예외의 종류", example = "INVALID_REQUEST_DATA")
|
||||||
) {
|
val errorType: ErrorType,
|
||||||
|
|
||||||
public static ErrorResponse of(ErrorType errorType, String message) {
|
@field:Schema(description = "예외 메시지", example = "요청 데이터 값이 올바르지 않습니다.")
|
||||||
return new ErrorResponse(errorType, message);
|
val message: String
|
||||||
}
|
) {
|
||||||
|
companion object {
|
||||||
|
@JvmStatic
|
||||||
|
fun of(errorType: ErrorType, message: String): ErrorResponse {
|
||||||
|
return ErrorResponse(errorType, message)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,20 +1,27 @@
|
|||||||
package roomescape.common.dto.response;
|
package roomescape.common.dto.response
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema
|
||||||
|
|
||||||
@Schema(description = "API 응답 시에 사용합니다.")
|
@Schema(description = "API 응답 시에 사용합니다.")
|
||||||
public record RoomEscapeApiResponse<T>(
|
@JvmRecord
|
||||||
@Schema(description = "응답 메시지", defaultValue = SUCCESS_MESSAGE) String message,
|
data class RoomEscapeApiResponse<T>(
|
||||||
@Schema(description = "응답 바디") T data
|
@field:Schema(description = "응답 메시지", defaultValue = SUCCESS_MESSAGE)
|
||||||
|
val message: String,
|
||||||
|
|
||||||
|
@field:Schema(description = "응답 바디")
|
||||||
|
val data: T? = null
|
||||||
) {
|
) {
|
||||||
|
companion object {
|
||||||
|
private const val SUCCESS_MESSAGE = "요청이 성공적으로 수행되었습니다."
|
||||||
|
|
||||||
private static final String SUCCESS_MESSAGE = "요청이 성공적으로 수행되었습니다.";
|
@JvmStatic
|
||||||
|
fun <T> success(data: T): RoomEscapeApiResponse<T> {
|
||||||
|
return RoomEscapeApiResponse(SUCCESS_MESSAGE, data)
|
||||||
|
}
|
||||||
|
|
||||||
public static <T> RoomEscapeApiResponse<T> success(T data) {
|
@JvmStatic
|
||||||
return new RoomEscapeApiResponse<>(SUCCESS_MESSAGE, data);
|
fun success(): RoomEscapeApiResponse<Void> {
|
||||||
}
|
return RoomEscapeApiResponse(SUCCESS_MESSAGE, null)
|
||||||
|
}
|
||||||
public static <T> RoomEscapeApiResponse<T> success() {
|
}
|
||||||
return new RoomEscapeApiResponse<>(SUCCESS_MESSAGE, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user