[+] Insert Kaleidx on upsert

pull/110/head
Azalea 2025-01-17 08:19:04 -05:00
parent 1075256f21
commit 4328ca3280
3 changed files with 13 additions and 0 deletions

View File

@ -208,6 +208,8 @@ val <T> List<T>.mut get() = toMutableList()
val <K, V> Map<K, V>.mut get() = toMutableMap()
val <T> Set<T>.mut get() = toMutableSet()
fun <T> List<T>.unique(fn: (T) -> Any) = distinctBy(fn).ifEmpty { null }
// Optionals
operator fun <T> Optional<T>.invoke(): T? = orElse(null)
fun <T> Optional<T>.expect(message: Str = "Value is not present") = orElseGet { (400 - message) }

View File

@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.JsonProcessingException
import ext.invoke
import ext.mapApply
import ext.minus
import ext.unique
import icu.samnyan.aqua.sega.general.BaseHandler
import icu.samnyan.aqua.sega.general.service.CardService
import icu.samnyan.aqua.sega.maimai2.handler.UploadUserPlaylogHandler.Companion.playBacklog
@ -127,6 +128,11 @@ class UpsertUserAllHandler(
repos.userFavorite.saveAll(news.mapApply {
id = repos.userFavorite.findByUserAndItemKind(u, itemKind)()?.id ?: 0 }) }
// Added on 1.50
req.userKaleidxScopeList?.unique { it.gateId }?.let { lst ->
repos.userKaleidx.saveAll(lst.mapApply {
id = repos.userKaleidx.findByUserAndGateId(u, gateId)?.id ?: 0 }) }
// 2024/10/31 Found some user data findByUserAndKindAndActivityId is not unique
// I think userActivityList is not important, so I will ignore it
try {

View File

@ -109,6 +109,10 @@ interface Mai2UserPrintDetailRepo : JpaRepository<Mai2UserPrintDetail, Long>
interface Mai2UserUdemaeRepo : Mai2UserLinked<Mai2UserUdemae>
interface MAi2UserKaleidxRepo : Mai2UserLinked<Mai2UserKaleidx> {
fun findByUserAndGateId(user: Mai2UserDetail, gateId: Int): Mai2UserKaleidx?
}
interface Mai2GameChargeRepo : JpaRepository<Mai2GameCharge, Long>
interface Mai2GameEventRepo : JpaRepository<Mai2GameEvent, Int> {
@ -138,6 +142,7 @@ class Mai2Repos(
val userPlaylog: Mai2UserPlaylogRepo,
val userPrintDetail: Mai2UserPrintDetailRepo,
val userUdemae: Mai2UserUdemaeRepo,
val userKaleidx: MAi2UserKaleidxRepo,
val gameCharge: Mai2GameChargeRepo,
val gameEvent: Mai2GameEventRepo,
val gameSellingCard: Mai2GameSellingCardRepo