|
|
|
@ -16,6 +16,8 @@ import org.springframework.security.core.userdetails.UserDetails;
|
|
|
|
|
import org.springframework.security.core.userdetails.UsernameNotFoundException; |
|
|
|
|
import org.springframework.security.oauth2.provider.OAuth2Authentication; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import java.util.Collection; |
|
|
|
|
import java.util.List; |
|
|
|
@ -30,6 +32,7 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
private UserRepository userRepository; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true) |
|
|
|
|
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { |
|
|
|
|
User user = userRepository.findByUsername(username); |
|
|
|
|
if (user == null || user.archived()) { |
|
|
|
@ -40,6 +43,7 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true) |
|
|
|
|
public UserJsonDto loadCurrentUserJsonDto() { |
|
|
|
|
final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); |
|
|
|
|
final Object principal = authentication.getPrincipal(); |
|
|
|
@ -54,6 +58,7 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true) |
|
|
|
|
public UserOverviewDto loadUserOverviewDto(UserOverviewDto overviewDto) { |
|
|
|
|
List<User> users = userRepository.findUsersByUsername(overviewDto.getUsername()); |
|
|
|
|
overviewDto.setUserDtos(UserDto.toDtos(users)); |
|
|
|
@ -61,12 +66,14 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true) |
|
|
|
|
public boolean isExistedUsername(String username) { |
|
|
|
|
final User user = userRepository.findByUsername(username); |
|
|
|
|
return user != null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(propagation = Propagation.REQUIRED) |
|
|
|
|
public String saveUser(UserFormDto formDto) { |
|
|
|
|
User user = formDto.newUser(); |
|
|
|
|
userRepository.saveUser(user); |
|
|
|
|