[+] Backend card linking

pull/14/head
Azalea 2024-02-22 22:45:24 -05:00
parent 1d4e1a8be2
commit eccdd73908
1 changed files with 8 additions and 1 deletions

View File

@ -33,10 +33,17 @@ class CardService(val cardRepo: CardRepository)
/**
* Find a card by its access code
*
* If the card is linked to a user, return the user's ghost card instead
*
* @param accessCode String represent of an access code
* @return Optional of a Card
*/
fun getCardByAccessCode(accessCode: String?): Optional<Card> = cardRepo.findByLuid(accessCode)
fun getCardByAccessCode(accessCode: String?): Optional<Card> = Optional.ofNullable(
cardRepo.findByLuid(accessCode).getOrNull()?.let {
it.aquaUser?.ghostCard ?: it
}
)
/**
* Register a new card with access code