[F] Fix duplicate uploads

pull/110/head
Azalea 2025-01-17 10:25:04 -05:00
parent 762f0ef445
commit 1421d55a56
2 changed files with 13 additions and 0 deletions

View File

@ -43,6 +43,14 @@ class UploadUserPlaylogHandler(
).increment()
}
// Check duplicate
val isDup = playlogRepo.findByUser_Card_ExtIdAndMusicIdAndUserPlayDate(
req.userId,
req.userPlaylog.musicId,
req.userPlaylog.userPlayDate
).size > 0
if (isDup) return """{"returnCode":1,"apiName":"com.sega.maimai2servlet.api.UploadUserPlaylogApi"}"""
// Save if the user is registered
val u = userDataRepository.findByCardExtId(req.userId).getOrNull()
if (u != null) playlogRepo.save(req.userPlaylog.apply { user = u })

View File

@ -99,6 +99,11 @@ interface Mai2UserOptionRepo : Mai2UserLinked<Mai2UserOption>
interface Mai2UserPlaylogRepo : GenericPlaylogRepo<Mai2UserPlaylog>, Mai2UserLinked<Mai2UserPlaylog> {
fun findByUser_Card_ExtIdAndMusicIdAndLevel(userId: Long, musicId: Int, level: Int): List<Mai2UserPlaylog>
fun findByUser_Card_ExtIdAndMusicIdAndUserPlayDate(
userCardExtId: Long,
musicId: Int,
userPlayDate: String
): MutableList<Mai2UserPlaylog>
}
interface Mai2UserPrintDetailRepo : JpaRepository<Mai2UserPrintDetail, Long>