Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature :: 회원가입, 로그인 리팩터링 (#67, #68, #77) #78

Merged

Conversation

gunsight1
Copy link
Collaborator

@gunsight1 gunsight1 commented Jan 19, 2024

💡 Motivation and Context

여기에 왜 이 PR이 필요했는지, PR을 통해 무엇이 바뀌는지에 대해서 설명해 주세요


🔨 Modified

여기에 무엇이 크게 바뀌었는지 설명해 주세요

  • 컨트롤러에서 ResponseEntity의 대한 방식을 신규 방식으로 바꾸었습니다.

image

  • 회원가입 및 로그인시 성별, 연령대의 대한 데이터를 enum 타입으로 처리하도록 바꾸었습니다.

  • 성별은 DTO (String) -> enum.ordinal -> entity (int) :: entity -> enum.name-> DTO(String) 로 처리합니다.

  • 나이는 DTO (String) -> enum.ordinal -> entity (int) :: entity -> enum.value -> DTO(String) 로 처리합니다.

  • 성별을 예로 들어 회원가입시 아래와 같은 양식으로 보낸다 했을 때 (나이 엘리멘트 VALUE는 "AGE_xx" 형태로 보내야 됩니다.
    (enum타입은 숫자가 먼저 올 수 없음.)

image

DB에는 다음과 같이 enum의 대한 index 값이 반입됩니다.
image

Entity의 자료형은 enum 값이 많지 않으므로 int형으로 하였습니다.
image

회원가입 결과 화면은 다음과 같이 나옵니다.
image

로그인 성공시 다음과 같이 나옵니다. 프론트엔드에서 성별과 나이의 대한 값을 가입시에 사용했던 값 그대로 쓸 수 있도록 하였습니다.
image


🌟 More

  • 변동사항의 대한 쿼리 정리 후 업데이트


📋 커밋 전 체크리스트

  • 추가/변경에 대한 단위 테스트를 완료하였습니다.
  • 컨벤션에 맞게 작성하였습니다.

🤟🏻 PR로 완료된 이슈

closes #67, #68 , #77

gunsight1 and others added 3 commits January 18, 2024 19:31
Controller return Response Entity 신규 양식으로 변경
가입, 로그인시 발생하는 위험요소에 대한 Exception 처리
@gunsight1 gunsight1 added 🖥️ BackEnd 서버 관련 🔨 Refactor 이 코드는 아주 약간 더 클린코드에 가까워졌습니다... labels Jan 19, 2024
public String getMessage() {
return message;
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code snippet you provided appears to be a code review request for a Java enum class MemberBusinessCode that implements the BusinessCode interface. Here are some observations and suggestions:

  1. Make sure the package name (com.kernel360.member.code) is correct and aligns with your project structure.

  2. The @RequiredArgsConstructor annotation suggests that there are other fields in this enum class that are not shown in the code snippet. Ensure those fields are appropriately initialized.

  3. It's generally good practice to use uppercase letters and underscores for enum constants. For example, you could rename SUCCESS_REQUEST_JOIN_MEMBER_CREATED to SUCCESS_REQUEST_JOIN_MEMBER_CREATED.

  4. Consider adding comments to document the purpose and usage of the enum values and any specific implementation details, if necessary.

  5. Verify that the HttpStatus import is correctly referencing the desired class.

  6. Since the enum implements the BusinessCode interface, ensure that the interface is also defined correctly and captures the required functionality related to business codes.

Overall, based on the code snippet provided, it looks like a simple and straightforward implementation of an enum class representing business codes. However, a comprehensive review would require examining the rest of the relevant code files and understanding their context and usage.

@gunsight1 gunsight1 closed this Jan 19, 2024
@gunsight1 gunsight1 deleted the feature_joinMember_add_gender_and_age branch January 19, 2024 10:23
@gunsight1 gunsight1 restored the feature_joinMember_add_gender_and_age branch January 19, 2024 10:26
@gunsight1 gunsight1 reopened this Jan 19, 2024
public String getMessage() {
return message;
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code you've provided appears to be a Java enum class called MemberBusinessCode. Here's a brief review:

  1. It seems like the class is implementing the BusinessCode interface, which defines three methods: getStatus(), getCode(), and getMessage(). This suggests that MemberBusinessCode is meant to represent specific business codes with associated status, code, and message values.

  2. The constructor is annotated with @RequiredArgsConstructor, indicating that it generates a constructor with all final fields. Since the fields (status, code, and message) are final, they can only be set through this constructor.

  3. The enum values defined in the enum appear to represent different types of business codes for member-related actions. Each value has a corresponding HTTP status value, code, and message.

Improvement suggestions:

  1. It would be helpful to have more context about how this MemberBusinessCode enum class is used within your application. Without that information, it's challenging to provide specific improvement suggestions.

  2. Consider adding additional meaningful codes that represent different scenarios or error conditions specific to your application's member module. This could help in providing detailed feedback to users or developers in case of errors or exceptions.

  3. Ensure that the usage of HTTP status codes aligns with the actual responses returned by your APIs. Make sure these codes accurately reflect the response status expected from the server.

  4. Depending on your project's requirements, you might want to consider making the enum values uppercase to follow naming conventions (e.g., SUCCESS_REQUEST_JOIN_MEMBER_CREATED would become SUCCESS_REQUEST_JOIN_MEMBER_CREATED).

Please note that without further details on the context and usage of this enum class, it's difficult to provide a comprehensive review or identify potential bugs or risks.

Copy link
Collaborator

@chan99k chan99k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


return new ResponseEntity<>("", HttpStatus.CREATED);
return ApiResponse.toResponseEntity(SUCCESS_REQUEST_JOIN_MEMBER_CREATED);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

return String.valueOf(age.value);
}
}
throw new BusinessException(MemberErrorCode.FAILED_NOT_MAPPING_ORDINAL_TO_VALUE);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

Comment on lines +10 to +12
SUCCESS_REQUEST_JOIN_MEMBER_CREATED(HttpStatus.CREATED.value(), "BMC001", "회원가입 성공"),
SUCCESS_REQUEST_LOGIN_MEMBER(HttpStatus.OK.value(), "BMC002", "로그인 성공");

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

바뀐 코드 확인했습니다.

Copy link
Collaborator

@linglong67 linglong67 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인했습니다~!
LGTM 👍

@gunsight1 gunsight1 merged commit 22382d7 into Kernel360:develop Jan 19, 2024
1 check passed
Copy link
Collaborator

@HyunJunSon HyunJunSon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gunsight1 gunsight1 changed the title Feature :: 회원가입, 로그인 리팩터링 (#68, #77) Feature :: 회원가입, 로그인 리팩터링 (#67, #68, #77) Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🖥️ BackEnd 서버 관련 🔨 Refactor 이 코드는 아주 약간 더 클린코드에 가까워졌습니다...
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refactor :: 공통코드 API 데이터의 value를 DB에서 enum으로 받도록 변경
4 participants