Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

@Repository
public interface UserRepository extends JpaRepository<User, Long> {
User findByUserId(String userId);
User findByUserIdAndIsDeleted(String userId, boolean isDeleted);

Optional<User> findByUserName(String nickname);

long countByUserIdAndIsDeleted(String userId, boolean b);
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ public class LibraryService {
private final ReadingRecordRepository readingRecordRepository;

public User getUser(String userId) {
User user = userRepository.findByUserId(userId);
if(user.getIsDeleted()) throw new GeneralException(Code.USER_ALREADY_WITHDRAWN);
User user = userRepository.findByUserIdAndIsDeleted(userId, false);
if(user == null) {
//탈퇴한 적 있는 회원
if(userRepository.countByUserIdAndIsDeleted(userId, true) > 0) throw new GeneralException(Code.USER_ALREADY_WITHDRAWN);
else throw new GeneralException(Code.USER_NOT_FOUND);
}
return user;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ public class MyPageService {
private final NoteRepository noteRepository;

public User getUser(String userId) {
User user = userRepository.findByUserId(userId);
if(user.getIsDeleted()) throw new GeneralException(Code.USER_ALREADY_WITHDRAWN);
User user = userRepository.findByUserIdAndIsDeleted(userId, false);
if(user == null) {
//탈퇴한 적 있는 회원
if(userRepository.countByUserIdAndIsDeleted(userId, true) > 0) throw new GeneralException(Code.USER_ALREADY_WITHDRAWN);
else throw new GeneralException(Code.USER_NOT_FOUND);
}
return user;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,13 @@ public void deleteNote(Long recordId, Long noteId, String userId) {


//== 사용할 기타 메소드

public User getUser(String userId) {
User user = userRepository.findByUserId(userId);
if(user.getIsDeleted()) throw new GeneralException(Code.USER_ALREADY_WITHDRAWN);
User user = userRepository.findByUserIdAndIsDeleted(userId, false);
if(user == null) {
//탈퇴한 적 있는 회원
if(userRepository.countByUserIdAndIsDeleted(userId, true) > 0) throw new GeneralException(Code.USER_ALREADY_WITHDRAWN);
else throw new GeneralException(Code.USER_NOT_FOUND);
}
return user;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ public class ReadingRecordService {
private final BookService bookService;

public User getUser(String userId) {
User user = userRepository.findByUserId(userId);
if(user.getIsDeleted()) throw new GeneralException(Code.USER_ALREADY_WITHDRAWN);
User user = userRepository.findByUserIdAndIsDeleted(userId, false);
if(user == null) {
//탈퇴한 적 있는 회원
if(userRepository.countByUserIdAndIsDeleted(userId, true) > 0) throw new GeneralException(Code.USER_ALREADY_WITHDRAWN);
else throw new GeneralException(Code.USER_NOT_FOUND);
}
return user;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ public class SearchLogService {
private final UserRepository userRepository;

public User getUser(String userId) {
User user = userRepository.findByUserId(userId);
if(user.getIsDeleted()) throw new GeneralException(Code.USER_ALREADY_WITHDRAWN);
User user = userRepository.findByUserIdAndIsDeleted(userId, false);
if(user == null) {
//탈퇴한 적 있는 회원
if(userRepository.countByUserIdAndIsDeleted(userId, true) > 0) throw new GeneralException(Code.USER_ALREADY_WITHDRAWN);
else throw new GeneralException(Code.USER_NOT_FOUND);
}
return user;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ public class UserService {
private final UserRefreshTokenRepository userRefreshTokenRepository;

public User getUser(String userId) {
User user = userRepository.findByUserId(userId);
if(user.getIsDeleted()) throw new GeneralException(Code.USER_ALREADY_WITHDRAWN);
User user = userRepository.findByUserIdAndIsDeleted(userId, false);
if(user == null) {
//탈퇴한 적 있는 회원
if(userRepository.countByUserIdAndIsDeleted(userId, true) > 0) throw new GeneralException(Code.USER_ALREADY_WITHDRAWN);
else throw new GeneralException(Code.USER_NOT_FOUND);
}
return user;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ public class UserSettingsService {
private final UserRepository userRepository;

public User getUser(String userId) {
User user = userRepository.findByUserId(userId);
if(user.getIsDeleted()) throw new GeneralException(Code.USER_ALREADY_WITHDRAWN);
User user = userRepository.findByUserIdAndIsDeleted(userId, false);
if(user == null) {
//탈퇴한 적 있는 회원
if(userRepository.countByUserIdAndIsDeleted(userId, true) > 0) throw new GeneralException(Code.USER_ALREADY_WITHDRAWN);
else throw new GeneralException(Code.USER_NOT_FOUND);
}
return user;
}

Expand Down