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

[♻️ refactor/#121]: AuthServiceImpl 리팩토링: 메서드 명명 일관성 및 트랜잭션 관리 개선 #130

Merged
merged 2 commits into from
Sep 11, 2024

Conversation

jsoonworld
Copy link
Contributor

📄 Work Description

  • 토큰 생성 메서드명을 getToken()에서 getFullToken()으로 변경하여 명확성을 높였습니다.
  • findUser() 메서드를 findUserById()findUserByRefreshToken()으로 각각 변경하여 메서드 명명 규칙을 일관되게 유지했습니다.
  • 메서드의 접근 제어자를 수정하여 필요한 경우 protected로 변경해 캡슐화를 개선했습니다.
  • 데이터베이스 상태를 변경하는 메서드들에 @Transactional을 추가하여 트랜잭션 관리가 제대로 이루어지도록 수정했습니다.

⚙️ ISSUE

📷 Screenshot

Swagger 200

스크린샷 2024-09-09 오후 10 11 38

💬 To Reviewers

  • 메서드 명명 변경 및 트랜잭션 처리가 코드 흐름에 잘 맞는지 중점적으로 리뷰 부탁드립니다.
  • 추가적으로 캡슐화 관련 접근 제어자 변경이 적절한지 확인해 주시면 감사하겠습니다.

🔗 Reference

- 토큰 생성 메서드명을 `getToken()`에서 `getFullToken()`으로 변경하여 명확성 향상
- `findUser()`를 `findUserById()`와 `findUserByRefreshToken()`으로 변경하여 메서드 명명 일관성 확보
- 몇몇 메서드의 접근 제어자를 수정하여 캡슐화 개선
- 데이터베이스 상태를 수정하는 메서드에 `@Transactional` 애너테이션 추가로 트랜잭션 관리 강화
@jsoonworld jsoonworld requested review from junggyo1020 and JungYoonShin and removed request for junggyo1020 September 9, 2024 13:13
@jsoonworld jsoonworld self-assigned this Sep 9, 2024
@jsoonworld jsoonworld added ♻️ refactor 코드 리팩토링 ex) 형식변경 🦊장순🦊 labels Sep 9, 2024
Copy link
Member

@JungYoonShin JungYoonShin left a comment

Choose a reason for hiding this comment

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

수고하셨습니다! 메서드명도 깔끔하게 바뀌고 좋은 것 같아요 :)

Comment on lines 131 to 135
@Transactional
protected Token getFullToken(User user) {
String accessToken = createAccessToken(new UserAuthentication(user.getId(), null, null));
String refreshToken = createRefreshToken(new UserAuthentication(user.getId(), null, null));

Copy link
Member

@JungYoonShin JungYoonShin Sep 9, 2024

Choose a reason for hiding this comment

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

해당 메서드는 protected로 선언이 되어있어서 트랜잭션이 정상적으로 적용되지 않을 것 같아요..!!

  • 트랜잭션은 프록시 기반으로 작동하여, private이나 protected로 선언할 경우 프록시 객체를 생성 후 메서드에 접근할 수가 없어서 트랜잭션이 적용되지 않는다고 합니다!
  • 또한 해당 getFullToken()을 호출하는 상위메서드인 signUp()에 트랜잭션이 걸려있기 때문에 트랙잭션 전파를 통해 하위 메서드에서도 상위 트랜잭션을 사용하게 되어 해당 메서드에서는 따로 트랜잭션을 걸지 않아도 될 것 같습니다!

👉 제가 참고한 블로그 첨부드립니다:)

  1. 외부 메서드, 내부 메서드에 대한 @Transactional 트랜잭션 적용 결과 테스트
  2. @Transactional 바르게 알고 사용하기

… private으로 변경

- 내부에서만 사용되는 getFullToken 메서드를 private으로 수정.
- 캡슐화 및 접근 제한을 위해 deleteUser 메서드를 private으로 변경.
- 해당 메서드에서 불필요한 @transactional 어노테이션 제거.
@jsoonworld jsoonworld merged commit 3c20eeb into develop Sep 11, 2024
1 check passed
@jsoonworld jsoonworld deleted the refactor/#121 branch October 10, 2024 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
♻️ refactor 코드 리팩토링 ex) 형식변경 🦊장순🦊
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants