-
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
67000d2
commit 13b2e94
Showing
11 changed files
with
101 additions
and
84 deletions.
There are no files selected for viewing
15 changes: 8 additions & 7 deletions
15
...star/softwarelab/exception/ErrorCode.java → .../com/blackstar/softwarelab/bean/Code.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 |
---|---|---|
@@ -1,25 +1,26 @@ | ||
package com.blackstar.softwarelab.exception; | ||
package com.blackstar.softwarelab.bean; | ||
|
||
import com.fasterxml.jackson.annotation.JsonValue; | ||
|
||
public enum ErrorCode { | ||
public enum Code { | ||
|
||
SUCCESS(-1), | ||
GENERAL(2), | ||
AUTHENTICATION(10), | ||
JWT_TOKEN_EXPIRED(11), | ||
PERMISSION_DENIED(20), | ||
INVALID_ARGUMENTS(30), | ||
BAD_REQUEST_PARAMS(31); | ||
|
||
private int errorCode; | ||
private int code; | ||
|
||
ErrorCode(int errorCode) { | ||
this.errorCode = errorCode; | ||
Code(int code) { | ||
this.code = code; | ||
} | ||
|
||
@JsonValue | ||
public int getErrorCode() { | ||
return errorCode; | ||
public int getCode() { | ||
return code; | ||
} | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
src/main/java/com/blackstar/softwarelab/bean/Response.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,60 @@ | ||
package com.blackstar.softwarelab.bean; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
import java.util.Date; | ||
|
||
public class Response { | ||
|
||
// General message | ||
private final String message; | ||
|
||
// code | ||
private final Code code; | ||
|
||
private final Object data; | ||
|
||
private final Date timestamp; | ||
|
||
protected Response(final String message, final Code code) { | ||
this.message = message; | ||
this.code = code; | ||
this.timestamp = new java.util.Date(); | ||
this.data = null; | ||
} | ||
|
||
protected Response(final String message, final Code code, Object data) { | ||
this.message = message; | ||
this.code = code; | ||
this.timestamp = new java.util.Date(); | ||
this.data = data; | ||
} | ||
|
||
public static Response of(final String message, final Code code) { | ||
return new Response(message, code); | ||
} | ||
|
||
public static Response of(final String message, final Code code, Object data) { | ||
return new Response(message, code, data); | ||
} | ||
|
||
public static Response ofSuccess(Object data){ | ||
return new Response(null, Code.SUCCESS, data); | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public Code getCode() { | ||
return code; | ||
} | ||
|
||
public Date getTimestamp() { | ||
return timestamp; | ||
} | ||
|
||
public Object getData() { | ||
return data; | ||
} | ||
} |
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
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
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
2 changes: 1 addition & 1 deletion
2
...ain/java/com/blackstar/softwarelab/config/rest/RestAwareAuthenticationFailureHandler.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
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
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
45 changes: 0 additions & 45 deletions
45
src/main/java/com/blackstar/softwarelab/exception/ErrorResponse.java
This file was deleted.
Oops, something went wrong.
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
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