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

pull/122/head
凌莞~(=^▽^=) 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 // 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 } ?: -1
/** /**

View File

@ -34,15 +34,11 @@ class CardService(val cardRepo: CardRepository)
/** /**
* Find a card by its access code * 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 * @param accessCode String represent of an access code
* @return Optional of a Card * @return Optional of a Card
*/ */
fun getCardByAccessCode(accessCode: String?): Optional<Card> = Optional.ofNullable( fun getCardByAccessCode(accessCode: String?): Optional<Card> = Optional.ofNullable(
cardRepo.findByLuid(accessCode).getOrNull()?.let { cardRepo.findByLuid(accessCode).getOrNull()
it.aquaUser?.ghostCard ?: it
}
) )
/** /**