[F] Card access time is not correctly set (#120)

v1-dev
凌莞~(=^▽^=) 2025-03-02 05:31:39 +08:00 committed by GitHub
parent 5caeaccec8
commit 3da92de951
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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()
)
/**