From e153c4427f0cd17c402a313b4197ae94efde9632 Mon Sep 17 00:00:00 2001 From: mjkhan21 Date: Thu, 12 Dec 2024 13:44:13 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9D=91=EB=8B=B5=20=ED=95=84=EB=93=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../foundation/component/ServiceResponse.java | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/src/main/java/cokr/xit/foundation/component/ServiceResponse.java b/src/main/java/cokr/xit/foundation/component/ServiceResponse.java index 25fdc5b..5e2e109 100644 --- a/src/main/java/cokr/xit/foundation/component/ServiceResponse.java +++ b/src/main/java/cokr/xit/foundation/component/ServiceResponse.java @@ -11,4 +11,85 @@ import cokr.xit.foundation.AbstractComponent; */ public abstract class ServiceResponse extends AbstractComponent implements Serializable { private static final long serialVersionUID = 1L; + + private String + code, + message; + private Throwable throwable; + private Boolean success; + + /**결과코드를 반환한다. + * @return 결과코드 + */ + public String getCode() { + return code; + } + + /**결과코드를 설정한다. + * @param 응답 타입 + * @param code 결과코드 + * @return 현재 응답 + */ + public T setCode(String code) { + this.code = code; + return self(); + } + + /**결과메시지를 반환한다. + * @return 결과메시지 + */ + public String getMessage() { + return message; + } + + /**결과메시지를 설정한다. + * @param 응답 타입 + * @param message 결과메시지 + * @return 현재 응답 + */ + public T setMessage(String message) { + this.message = message; + return self(); + } + + /**오류를 반환한다. + * @return 오류 + */ + public Throwable getThrowable() { + return throwable; + } + + /**오류를 설정한다. + * @param 응답 타입 + * @param throwable 오류 + * @return 현재 응답 + */ + public T setThrowable(Throwable throwable) { + this.throwable = throwable; + return self(); + } + + /**성공여부를 반환한다. + * @return 성공여부 + *
  • 디폴트는 true
  • + *
  • 오류가 설정되어 있으면 false
  • + *
  • 설정된 성공여부
  • + *
+ */ + public boolean isSuccess() { + if (throwable != null) + return false; + + return ifEmpty(success, Boolean.TRUE); + } + + /**성공여부(디폴트는 true)를 설정한다. + * @param 응답 타입 + * @param success 성공여부 + * @return 현재 응답 + */ + public T setSuccess(boolean success) { + this.success = success; + return self(); + } } \ No newline at end of file