Get Account
- add AccountController - add AccountEntity toAccountResponse in Mapping.kt - add AccountService - add AccountRepository - add AccountEntity
This commit is contained in:
24
src/main/kotlin/ltd/hlaeja/service/AccountService.kt
Normal file
24
src/main/kotlin/ltd/hlaeja/service/AccountService.kt
Normal file
@@ -0,0 +1,24 @@
|
||||
package ltd.hlaeja.service
|
||||
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import java.util.UUID
|
||||
import ltd.hlaeja.entity.AccountEntity
|
||||
import ltd.hlaeja.repository.AccountRepository
|
||||
import org.springframework.http.HttpStatus
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.web.server.ResponseStatusException
|
||||
import reactor.core.publisher.Mono
|
||||
|
||||
private val log = KotlinLogging.logger {}
|
||||
|
||||
@Service
|
||||
class AccountService(
|
||||
private val accountRepository: AccountRepository,
|
||||
) {
|
||||
|
||||
fun getUserById(
|
||||
uuid: UUID,
|
||||
): Mono<AccountEntity> = accountRepository.findById(uuid)
|
||||
.doOnNext { log.debug { "Get account ${it.id}" } }
|
||||
.switchIfEmpty(Mono.error(ResponseStatusException(HttpStatus.NOT_FOUND)))
|
||||
}
|
||||
Reference in New Issue
Block a user