[F] Card access time is not correctly set

pull/120/head
Clansty 2025-03-02 03:02:23 +08:00
parent 122a6776a2
commit 390c54bc3c
No known key found for this signature in database
GPG Key ID: 3A6BE8BAF2EDE134
2 changed files with 5 additions and 7 deletions

View File

@ -115,9 +115,11 @@ class AimeDB(
}
}
fun getCard(accessCode: String) = cardService.getCardByAccessCode(accessCode).getOrNull()?.let {
fun getCard(accessCode: String) = cardService.getCardByAccessCode(accessCode).getOrNull()?.let { card ->
// Update card access time
cardService.cardRepo.save(it.apply { accessTime = LocalDateTime.now() }).extId
cardService.cardRepo.save(card.apply { accessTime = LocalDateTime.now() }).let {
it.aquaUser?.ghostCard ?: it
}?.extId
} ?: -1
/**

View File

@ -34,15 +34,11 @@ 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> = Optional.ofNullable(
cardRepo.findByLuid(accessCode).getOrNull()?.let {
it.aquaUser?.ghostCard ?: it
}
cardRepo.findByLuid(accessCode).getOrNull()
)
/**