-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
caa2463
commit f0629e7
Showing
2 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
spring/src/main/java/umc/spring/apiPayload/code/status/ErrorStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package umc.spring.apiPayload.code.status; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
import umc.spring.apiPayload.code.BaseErrorCode; | ||
import umc.spring.apiPayload.code.ErrorReasonDTO; | ||
@Getter | ||
@AllArgsConstructor | ||
public enum ErrorStatus implements BaseErrorCode { | ||
// 가장 일반적인 응답 | ||
_INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "COMMON500", "서버 에러, 관리자에게 문의 바랍니다."), | ||
_BAD_REQUEST(HttpStatus.BAD_REQUEST,"COMMON400","잘못된 요청입니다."), | ||
_UNAUTHORIZED(HttpStatus.UNAUTHORIZED,"COMMON401","인증이 필요합니다."), | ||
_FORBIDDEN(HttpStatus.FORBIDDEN, "COMMON403", "금지된 요청입니다."), | ||
|
||
// For test | ||
TEMP_EXCEPTION(HttpStatus.BAD_REQUEST, "TEMP4001", "이거는 테스트"), | ||
|
||
// Member Error | ||
MEMBER_NOT_FOUND(HttpStatus.BAD_REQUEST, "MEMBER4001", "사용자가 없습니다."), | ||
NICKNAME_NOT_EXIST(HttpStatus.BAD_REQUEST, "MEMBER4002", "닉네임은 필수 입니다."), | ||
|
||
// Article Error | ||
ARTICLE_NOT_FOUND(HttpStatus.NOT_FOUND, "ARTICLE4001", "게시글이 없습니다."); | ||
|
||
private final HttpStatus httpStatus; | ||
private final String code; | ||
private final String message; | ||
|
||
@Override | ||
public ErrorReasonDTO getReason() { | ||
return ErrorReasonDTO.builder() | ||
.message(message) | ||
.code(code) | ||
.isSuccess(false) | ||
.build(); | ||
} | ||
@Override | ||
public ErrorReasonDTO getReasonHttpStatus() { | ||
return ErrorReasonDTO.builder() | ||
.message(message) | ||
.code(code) | ||
.isSuccess(false) | ||
.httpStatus(httpStatus) | ||
.build() | ||
; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
spring/src/main/java/umc/spring/apiPayload/code/status/SuccessStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package umc.spring.apiPayload.code.status; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
import umc.spring.apiPayload.code.BaseCode; | ||
import umc.spring.apiPayload.code.ReasonDTO; | ||
@Getter | ||
@AllArgsConstructor | ||
public enum SuccessStatus implements BaseCode { | ||
// 일반적인 응답 | ||
_OK(HttpStatus.OK, "COMMON200", "성공입니다."); | ||
// 멤버 관련 응답 | ||
// ~~~ 관련 응답 | ||
private final HttpStatus httpStatus; | ||
private final String code; | ||
private final String message; | ||
@Override | ||
public ReasonDTO getReason() { | ||
return ReasonDTO.builder() | ||
.message(message) | ||
.code(code) | ||
.isSuccess(true) | ||
.build(); | ||
} | ||
@Override | ||
public ReasonDTO getReasonHttpStatus() { | ||
return ReasonDTO.builder() | ||
.message(message) | ||
.code(code) | ||
.isSuccess(true) | ||
.httpStatus(httpStatus) | ||
.build() | ||
; | ||
} | ||
} |