generated from pricelees/issue-pr-template
[#5]: 공통 기능 코틀린 마이그레이션 및 패키지 분리 #6
@ -1,15 +1,21 @@
|
||||
package roomescape.common.dto.response;
|
||||
package roomescape.common.dto.response
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import roomescape.common.exception.ErrorType;
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
import roomescape.common.exception.ErrorType
|
||||
|
||||
@Schema(name = "예외 응답", description = "예외 발생 시 응답에 사용됩니다.")
|
||||
public record ErrorResponse(
|
||||
@Schema(description = "발생한 예외의 종류", example = "INVALID_REQUEST_DATA") ErrorType errorType,
|
||||
@Schema(description = "예외 메시지", example = "요청 데이터 값이 올바르지 않습니다.") String message
|
||||
) {
|
||||
@JvmRecord
|
||||
data class ErrorResponse(
|
||||
@field:Schema(description = "발생한 예외의 종류", example = "INVALID_REQUEST_DATA")
|
||||
val errorType: ErrorType,
|
||||
|
||||
public static ErrorResponse of(ErrorType errorType, String message) {
|
||||
return new ErrorResponse(errorType, message);
|
||||
}
|
||||
@field:Schema(description = "예외 메시지", example = "요청 데이터 값이 올바르지 않습니다.")
|
||||
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 응답 시에 사용합니다.")
|
||||
public record RoomEscapeApiResponse<T>(
|
||||
@Schema(description = "응답 메시지", defaultValue = SUCCESS_MESSAGE) String message,
|
||||
@Schema(description = "응답 바디") T data
|
||||
@JvmRecord
|
||||
data class RoomEscapeApiResponse<T>(
|
||||
@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) {
|
||||
return new RoomEscapeApiResponse<>(SUCCESS_MESSAGE, data);
|
||||
}
|
||||
|
||||
public static <T> RoomEscapeApiResponse<T> success() {
|
||||
return new RoomEscapeApiResponse<>(SUCCESS_MESSAGE, null);
|
||||
}
|
||||
@JvmStatic
|
||||
fun success(): RoomEscapeApiResponse<Void> {
|
||||
return RoomEscapeApiResponse(SUCCESS_MESSAGE, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user