-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from fingersdanny/feat-member
[refactor] controller 수정 및 커스텀 코드를 위한 ServiceStatus 및 모든 RepsonseEntity 생성 통일을 위한 ResponseEntityFactory 생성
- Loading branch information
Showing
18 changed files
with
201 additions
and
162 deletions.
There are no files selected for viewing
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
12 changes: 0 additions & 12 deletions
12
src/main/java/com/kernel360/kernelsquare/domain/member/dto/UpdateMemberResponse.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
13 changes: 13 additions & 0 deletions
13
src/main/java/com/kernel360/kernelsquare/global/common_response/ResponseEntityFactory.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,13 @@ | ||
package com.kernel360.kernelsquare.global.common_response; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
|
||
public class ResponseEntityFactory { | ||
public static ResponseEntity<ApiResponse> toResponseEntity(StatusCode statusCode) { | ||
return ResponseEntity.status(statusCode.getStatus()).body(ApiResponse.of(statusCode)); | ||
} | ||
|
||
public static <T> ResponseEntity<ApiResponse<T>> toResponseEntity(StatusCode statusCode, T data) { | ||
return ResponseEntity.status(statusCode.getStatus()).body(ApiResponse.of(statusCode, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,7 @@ | |
public interface StatusCode { | ||
HttpStatus getStatus(); | ||
|
||
Integer getCode(); | ||
|
||
String getMsg(); | ||
} |
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
64 changes: 36 additions & 28 deletions
64
...main/java/com/kernel360/kernelsquare/global/common_response/error/code/AuthErrorCode.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,28 +1,36 @@ | ||
package com.kernel360.kernelsquare.global.common_response.error.code; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
public enum AuthErrorCode implements ErrorCode { | ||
INVALID_ACCOUNT(HttpStatus.UNAUTHORIZED, "계정정보가 일치하지 않습니다."), | ||
INVALID_PASSWORD(HttpStatus.UNAUTHORIZED, "비밀번호가 일치하지 않습니다."), | ||
ALREADY_SAVED_NICKNAME(HttpStatus.CONFLICT, "사용 중인 닉네임입니다."), | ||
ALREADY_SAVED_EMAIL(HttpStatus.CONFLICT, "사용 중인 이메일입니다."), | ||
ALREADY_SOCIAL_LOGIN(HttpStatus.CONFLICT, "소셜로 가입한 회원입니다. 소셜로 로그인 해주세요."); | ||
|
||
private final HttpStatus code; | ||
private final String msg; | ||
|
||
@Override | ||
public HttpStatus getStatus() { | ||
return code; | ||
} | ||
|
||
@Override | ||
public String getMsg() { | ||
return msg; | ||
} | ||
} | ||
|
||
// package com.kernel360.kernelsquare.global.common_response.error.code; | ||
// | ||
// import org.springframework.http.HttpStatus; | ||
// | ||
// import com.kernel360.kernelsquare.global.common_response.service.code.ServiceStatus; | ||
// | ||
// import lombok.RequiredArgsConstructor; | ||
// | ||
// @RequiredArgsConstructor | ||
// public enum AuthErrorCode implements ErrorCode { | ||
// INVALID_ACCOUNT(HttpStatus.UNAUTHORIZED, "계정정보가 일치하지 않습니다."), | ||
// INVALID_PASSWORD(HttpStatus.UNAUTHORIZED, "비밀번호가 일치하지 않습니다."), | ||
// ALREADY_SAVED_NICKNAME(HttpStatus.CONFLICT, "사용 중인 닉네임입니다."), | ||
// ALREADY_SAVED_EMAIL(HttpStatus.CONFLICT, "사용 중인 이메일입니다."), | ||
// ALREADY_SOCIAL_LOGIN(HttpStatus.CONFLICT, "소셜로 가입한 회원입니다. 소셜로 로그인 해주세요."); | ||
// | ||
// private final HttpStatus code; | ||
// private final ServiceStatus serviceStatus; | ||
// private final String msg; | ||
// | ||
// @Override | ||
// public HttpStatus getStatus() { | ||
// return code; | ||
// } | ||
// | ||
// @Override | ||
// public Integer getCode() { | ||
// return serviceStatus.getServiceStatus(); | ||
// } | ||
// | ||
// @Override | ||
// public String getMsg() { | ||
// return msg; | ||
// } | ||
// } | ||
// |
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
15 changes: 0 additions & 15 deletions
15
src/main/java/com/kernel360/kernelsquare/global/common_response/error/dto/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
19 changes: 19 additions & 0 deletions
19
...a/com/kernel360/kernelsquare/global/common_response/service/code/MemberServiceStatus.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,19 @@ | ||
package com.kernel360.kernelsquare.global.common_response.service.code; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
public enum MemberServiceStatus implements ServiceStatus { | ||
MEMBER_NOT_FOUND(1201), | ||
MEMBER_FOUND(1240), | ||
MEMBER_PASSWORD_UPDATED(1241), | ||
MEMBER_INFO_UPDATED(1242), | ||
MEMBER_DELETED(1243); | ||
|
||
private final Integer code; | ||
|
||
@Override | ||
public Integer getServiceStatus() { | ||
return code; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...in/java/com/kernel360/kernelsquare/global/common_response/service/code/ServiceStatus.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,5 @@ | ||
package com.kernel360.kernelsquare.global.common_response.service.code; | ||
|
||
public interface ServiceStatus { | ||
Integer getServiceStatus(); | ||
} |
Oops, something went wrong.