feat: Add ktlint to backend and format all files
This commit is contained in:
@@ -11,14 +11,14 @@ import org.springframework.stereotype.Service
|
||||
@Service
|
||||
class UserService(
|
||||
private val userRepository: UserRepository,
|
||||
private val userMapper: UserMapper
|
||||
private val userMapper: UserMapper,
|
||||
) {
|
||||
|
||||
fun getCurrentUser(): User {
|
||||
val principal = SecurityContextHolder.getContext().authentication.principal as CustomJwtTokenPrincipal
|
||||
val userId = principal.id ?: throw IllegalStateException("User ID not found")
|
||||
|
||||
return userRepository.findById(userId)
|
||||
return userRepository
|
||||
.findById(userId)
|
||||
.orElseThrow { UserNotFoundException(userId) }
|
||||
}
|
||||
|
||||
@@ -42,24 +42,27 @@ class UserService(
|
||||
throw UserAlreadyExistsException(userDto.keycloakId)
|
||||
}
|
||||
|
||||
val user = User(
|
||||
keycloakId = userDto.keycloakId,
|
||||
name = userDto.name,
|
||||
organizationId = userDto.organizationId
|
||||
)
|
||||
val user =
|
||||
User(
|
||||
keycloakId = userDto.keycloakId,
|
||||
name = userDto.name,
|
||||
organizationId = userDto.organizationId,
|
||||
)
|
||||
|
||||
return userRepository.save(user)
|
||||
}
|
||||
|
||||
fun getUserById(userId: String): User {
|
||||
return userRepository.findById(userId)
|
||||
fun getUserById(userId: String): User =
|
||||
userRepository
|
||||
.findById(userId)
|
||||
.orElseThrow { UserNotFoundException(userId) }
|
||||
}
|
||||
|
||||
@Transactional
|
||||
fun updateUser(userDto: UserDto): User {
|
||||
val user = userRepository.findById(userDto.keycloakId)
|
||||
.orElseThrow { UserNotFoundException(userDto.keycloakId) }
|
||||
val user =
|
||||
userRepository
|
||||
.findById(userDto.keycloakId)
|
||||
.orElseThrow { UserNotFoundException(userDto.keycloakId) }
|
||||
|
||||
user.name = userDto.name
|
||||
// Only update organization if it's not already set
|
||||
|
||||
Reference in New Issue
Block a user