Skip to content

Commit

Permalink
Fix - Transaction Rollback Error
Browse files Browse the repository at this point in the history
  • Loading branch information
yongbin1 committed Jul 9, 2023
1 parent 2f338a2 commit fa95217
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ public class LoginService {
private final JwtTokenProvider jwtTokenProvider;
private final UserRepository userRepository;

@Transactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class, noRollbackFor = UserNotFoundException.class)
public TokenResponse execute(LoginRequest request) {
User user = userFacade.findUserByUserId(request.getUserId());
LocalDateTime now = LocalDateTime.now();
LocalDateTime lastActivity = user.getModifiedDateTime();
if (user.getStatus() == UserStatus.DEACTIVATED) {
if (ChronoUnit.DAYS.between(lastActivity, now) >= 30) {
user.updateStatus(UserStatus.DELETED);
userRepository.save(user);
throw UserNotFoundException.EXCEPTION;
} else {
throw UserIsDeactivateException.EXCEPTION;
Expand All @@ -48,6 +47,7 @@ public TokenResponse execute(LoginRequest request) {
.userId(user.getUserId())
.build();
}

throw UserNotFoundException.EXCEPTION;
}

Expand Down

0 comments on commit fa95217

Please sign in to comment.