Get Account

- add AccountController
- add AccountEntity toAccountResponse in Mapping.kt
- add AccountService
- add AccountRepository
- add AccountEntity
This commit is contained in:
2024-12-29 07:07:44 +01:00
parent 573b4bd6fe
commit 6aee16c4a2
12 changed files with 330 additions and 0 deletions

View 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)))
}