-
Notifications
You must be signed in to change notification settings - Fork 0
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
[feat][#1] 사용자 관련 API 구현 #4
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
확인하였습니다!
@ExceptionHandler(BaseException.class) | ||
public ResponseEntity<ErrorResponse> handleBaseException(BaseException ex) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍👍👍 exception 처리 아주 좋네요. 나중에 기능들 세분화 되면서 더 발전된 처리과정 되는걸 기대합니다!
public List<UserResponseDTO> findAllUsers() { | ||
return userRepository.findAll() | ||
.stream() | ||
.map(UserResponseDTO::new) | ||
.toList(); | ||
} | ||
|
||
public UserResponseDTO findUserById(Long id) { | ||
UserEntity user = userRepository.findById(id) | ||
.orElseThrow(UserNotFoundException::new); | ||
return new UserResponseDTO(user); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 메서드들은 @Transactional(readOnly = true)
를 붙이지 않은 이유가 있나요?
위쪽 조회 메서드는 붙어있는데, 해당 메서드들은 @Transactional(readOnly = true)
의 트레이드 오프를 생각하시고 빼신걸까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
단일 엔티티 조회라서 readOnly 속성을 제거하려고 했었는데, 제대로 확인하지 못했습니다. 제거하고 다시 올리겠습니다!
@Override | ||
public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException { | ||
UserEntity userEntity = userRepository.findByEmail(email) | ||
.orElseThrow(() -> new UsernameNotFoundException("유저를 찾을 수 없습니다.")); | ||
|
||
if (!userEntity.isActive()) { | ||
throw new UsernameNotFoundException("비활성화된 계정입니다. 관리자에게 문의하세요."); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍👍👍
|
관련 이슈
resolve : #1
작업 내용
참고사항
회원 삭제 방식 변경
회원 삭제 시
PATCH
메서드를 사용해서isActive
필드를 업데이트하도록 변경하였습니다.1.1. PATCH 메서드 선택 이유
- 기존에는
DELETE
메서드를 사용할지 고민했으나, 회원 데이터를 완전히 삭제하는 대신 비활성화하는 방식을 적용하기 위해PATCH
메서드를 선택하였습니다.- 이를 통해 회원 데이터를 유지하면서 복구가 가능하도록 하였습니다.
1.2. 비활성화된 회원 처리 방식
-
isActive = false
상태인 사용자는 로그인 등 주요 기능이 제한됩니다.