feat: Add ktlint to backend and format all files

This commit is contained in:
2025-10-31 10:25:12 +01:00
parent be5017fcd4
commit 841341857d
53 changed files with 496 additions and 402 deletions

View File

@@ -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