From c4dfbab05ef0d8ca40a3068ba679be0ffd0c6004 Mon Sep 17 00:00:00 2001 From: st-yclee Date: Wed, 28 Aug 2024 10:26:17 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=A0=9C=EA=B1=B02?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kr/co/mcmp/api/response/ResponseCode.java | 72 ------------------- .../co/mcmp/api/response/ResponseWrapper.java | 42 ----------- 2 files changed, 114 deletions(-) delete mode 100644 src/main/java/kr/co/mcmp/api/response/ResponseCode.java delete mode 100644 src/main/java/kr/co/mcmp/api/response/ResponseWrapper.java diff --git a/src/main/java/kr/co/mcmp/api/response/ResponseCode.java b/src/main/java/kr/co/mcmp/api/response/ResponseCode.java deleted file mode 100644 index 2c7037a..0000000 --- a/src/main/java/kr/co/mcmp/api/response/ResponseCode.java +++ /dev/null @@ -1,72 +0,0 @@ -package kr.co.mcmp.api.response; - -import kr.co.mcmp.exception.McmpException; -import lombok.Getter; - -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -@Getter -public enum ResponseCode { - - OK(200, "정상처리 되었습니다."), - - /* common */ - BAD_REQUEST(400, "BAD REQUEST"), - UNAUTHORIZED(401, "UNAUTHORIZED"), - FORBIDDEN(403, "FORBIDDEN"), - NOT_FOUND(404, "NOT FOUND"), - METHOD_NOT_ALLOWED(405,"METHOD NOT ALLOWED"), - CLIENT_ERROR(408,"CLIENT_ERROR"), - CONFLICT(409,"CONFLICT"), - INTERNAL_SERVER_ERROR(500,"INTERNAL SERVER ERROR"), - - /* 공통 코드 */ - COMMON_CODE_EXISTS(9001, "EXISTS COMMON CODE"), - COMMON_CODE_DELETE_NOT_ALLOWED(9002,"DELETE NOT ALLOWED COMMON CODE"), - - /* Exception */ - UNKNOWN_ERROR(9999, "Unknown error"), - - /* GitLab-Project */ - ALREADY_EXISTS(1001, "ALREADY EXISTS"), - CREATE_FAILED_PROJECT_SOURCE(1003, "CREATE FAILED PROJECT SOURCE"), - - /* Jenkins */ - CREATE_FAILED_JENKINS_JOB(1103, "CREATE FAILED JENKINS JOB"), - EXISTS_JENKINS_JOB(1104, "EXISTS JENKINS JOB"), - NOT_EXISTS_JENKINS_JOB(1105, "NOT EXISTS JENKINS JOB"), - ERROR_JENKINS_API(1106, "ERROR JENKINS API"), - - /* Workload Deploy */ - RUN_FAILED_DEPLOY(1201, "RUN FAILED DEPLOY"), - - /* Catalog Deploy */ - CREATE_FAILED_APPLICATION(1301, "CREATE FAILED APPLICATION"), - NOT_EXISTS_APPLICATION(1302, "NOT EXISTS APPLICATION"), - EXISTS_APPLICATION(1303, "EXISTS APPLICATION"), - - /* K8S Client */ - CONNECTION_FAILED_CLUSTER(1401, "CONNECTION FAILED CLUSTER"), - - /* OSS */ - IN_USE_OSS(1501, "OSS IN USE CANNOT BE DELETED"), - IS_NOT_MAPPED_OSS(1502, "IS NOT MAPPED OSS TO SERVICE GROUP."); - - private final int code; - private final String message; - - ResponseCode(int code, String message) { - this.code = code; - this.message = message; - } - - private static final Map map = - Stream.of(values()).collect(Collectors.toMap(ResponseCode::getCode, e -> e)); - - public static ResponseCode findByCode(int code) { - return Optional.ofNullable(map.get(code)).orElseThrow(() -> new McmpException(String.valueOf(ResponseCode.UNKNOWN_ERROR))); - } -} diff --git a/src/main/java/kr/co/mcmp/api/response/ResponseWrapper.java b/src/main/java/kr/co/mcmp/api/response/ResponseWrapper.java deleted file mode 100644 index b81a2dc..0000000 --- a/src/main/java/kr/co/mcmp/api/response/ResponseWrapper.java +++ /dev/null @@ -1,42 +0,0 @@ -package kr.co.mcmp.api.response; - -import lombok.Getter; - -import java.io.Serializable; - -@Getter -public class ResponseWrapper implements Serializable { - - private static final long serialVersionUID = -1745006582949878939L; - - private int code; - private String message; - private String detail; - private T data; - - public ResponseWrapper() { - this(ResponseCode.OK); - } - - public ResponseWrapper(ResponseCode status){ - this.code = status.getCode(); - this.message = status.getMessage(); - } - - public ResponseWrapper(T data) { - this(); - this.data = data; - } - - public ResponseWrapper(ResponseCode status, String detail){ - this(status); - this.detail = detail; - } - - public ResponseWrapper(int code, String message, String detail){ - this.code = code; - this.message = message; - this.detail = detail; - } - -}