mirror of
https://github.com/MewoLab/AquaDX.git
synced 2025-10-25 12:02:40 +00:00
[O] Optional should not exist in kt
This commit is contained in:
parent
e7b96d4b24
commit
b2aef08c01
@ -4,6 +4,7 @@ import ext.*
|
||||
import icu.samnyan.aqua.net.db.AquaUserServices
|
||||
import icu.samnyan.aqua.net.utils.SUCCESS
|
||||
import icu.samnyan.aqua.sega.chusan.model.Chu3Repos
|
||||
import icu.samnyan.aqua.sega.general.model.Card
|
||||
import icu.samnyan.aqua.sega.general.model.CardStatus
|
||||
import icu.samnyan.aqua.sega.general.model.sensitiveInfo
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2Repos
|
||||
@ -52,7 +53,7 @@ class BotController(
|
||||
secret.checkSecret()
|
||||
|
||||
// 1. Find user card
|
||||
val oc = (us.cardRepo.findByLuid(card)() ?: (404 - "Card not found")).maybeGhost()
|
||||
val oc = (us.cardRepo.findByLuid(card) ?: (404 - "Card not found")).maybeGhost()
|
||||
|
||||
// 2. Change the status to migrated
|
||||
us.cardRepo.save(oc.apply {
|
||||
@ -66,7 +67,7 @@ class BotController(
|
||||
fun clearMigrateFlag(@RP secret: Str, @RP card: Str): Any {
|
||||
secret.checkSecret()
|
||||
|
||||
val oc = (us.cardRepo.findByLuid(card)() ?: (404 - "Card not found")).maybeGhost()
|
||||
val oc = (us.cardRepo.findByLuid(card) ?: (404 - "Card not found")).maybeGhost()
|
||||
|
||||
us.cardRepo.save(oc.apply {
|
||||
status = CardStatus.NORMAL
|
||||
@ -82,14 +83,14 @@ class BotController(
|
||||
secret.checkSecret()
|
||||
|
||||
// 1. Check if the card exist
|
||||
var cards = listOfNotNull(
|
||||
us.cardRepo.findByLuid(cardId)(),
|
||||
var cards: MutableList<Card> = listOfNotNull(
|
||||
us.cardRepo.findByLuid(cardId),
|
||||
).mut
|
||||
|
||||
cardId.toLongOrNull()?.let {
|
||||
cards += listOfNotNull(
|
||||
us.cardRepo.findById(it)(),
|
||||
us.cardRepo.findByExtId(it)(),
|
||||
us.cardRepo.findByExtId(it),
|
||||
)
|
||||
|
||||
cards += listOfNotNull(
|
||||
@ -110,8 +111,8 @@ class BotController(
|
||||
|
||||
return cards.map { card ->
|
||||
// Find all games played by this card
|
||||
val chu3 = chu3Db.userData.findByCard_ExtId(card.extId)()
|
||||
val mai2 = mai2Db.userData.findByCard_ExtId(card.extId)()
|
||||
val chu3 = chu3Db.userData.findByCard_ExtId(card.extId)
|
||||
val mai2 = mai2Db.userData.findByCard_ExtId(card.extId)
|
||||
val gamesDict = listOfNotNull(chu3, mai2).map {
|
||||
// Find the keychip owner
|
||||
val keychip = it.lastClientId
|
||||
|
||||
@ -238,7 +238,7 @@ class CardGameService(
|
||||
"chu3" to getSummaryFor(chusan, card),
|
||||
"ongeki" to getSummaryFor(ongeki, card),
|
||||
"wacca" to getSummaryFor(wacca, card),
|
||||
"diva" to diva.findByPdId(card.extId).getOrNull()?.let {
|
||||
"diva" to diva.findByPdId(card.extId)()?.let {
|
||||
mapOf(
|
||||
"name" to it.playerName,
|
||||
"rating" to it.level,
|
||||
|
||||
@ -165,7 +165,7 @@ class Fedy(
|
||||
data class DataPullRes(val error: FedyErr? = null, val result: Any? = null)
|
||||
@API("/data/pull")
|
||||
fun handleDataPull(@RH(KEY_HEADER) key: Str, @RT(REQ_PART) req: DataPullReq): DataPullRes = handleFedy(key) {
|
||||
val card = cardRepo.findByExtId(req.extId).orElse(null)
|
||||
val card = cardRepo.findByExtId(req.extId)
|
||||
?: (404 - "Card with extId ${req.extId} not found")
|
||||
{
|
||||
DataPullRes(result = when (req.game) {
|
||||
@ -181,10 +181,9 @@ class Fedy(
|
||||
fun handleDataPush(@RH(KEY_HEADER) key: Str, @RT(REQ_PART) req: DataPushReq): Any = handleFedy(key) {
|
||||
val extId = req.extId
|
||||
fun<UserData : IUserData, UserRepo : GenericUserDataRepo<UserData>> removeOldData(repo: UserRepo) {
|
||||
val oldData = repo.findByCard_ExtId(extId)
|
||||
if (oldData.isPresent) {
|
||||
repo.findByCard_ExtId(extId)?.let { oldData ->
|
||||
log.info("Fedy: Deleting old data for $extId (${req.game})")
|
||||
repo.delete(oldData.get());
|
||||
repo.delete(oldData);
|
||||
repo.flush()
|
||||
}
|
||||
}
|
||||
@ -281,7 +280,7 @@ class Fedy(
|
||||
fun onCardLinked(luid: Str, oldExtId: Long?, ghostExtId: Long, migratedGames: List<Str>) = maybeNotifyAsync(FedyEvent(cardLinked = CardLinkedEvent(luid, oldExtId, ghostExtId, migratedGames)))
|
||||
fun onCardUnlinked(luid: Str) = maybeNotifyAsync(FedyEvent(cardUnlinked = CardUnlinkedEvent(luid)))
|
||||
fun onDataUpdated(extId: Long, game: Str, removeOldData: Bool) = maybeNotifyAsync({
|
||||
val card = cardRepo.findByExtId(extId).orElse(null) ?: return@maybeNotifyAsync null // Card not found, nothing to do
|
||||
val card = cardRepo.findByExtId(extId) ?: return@maybeNotifyAsync null // Card not found, nothing to do
|
||||
FedyEvent(dataUpdated = DataUpdatedEvent(extId, card.isGhost, game, removeOldData))
|
||||
})
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ class Frontier(
|
||||
|
||||
if (accessCode.length != 20) 400 - "Invalid access code"
|
||||
// if (!accessCode.startsWith("9900")) 400 - "Frontier access code must start with 9900"
|
||||
if (async { cardService.cardRepo.findByLuid(accessCode) }.isPresent) 400 - "Card already registered"
|
||||
if (async { cardService.cardRepo.findByLuid(accessCode) } != null) 400 - "Card already registered"
|
||||
|
||||
val card = async { cardService.registerByAccessCode(accessCode) }
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package icu.samnyan.aqua.net
|
||||
|
||||
import ext.JACKSON
|
||||
import ext.invoke
|
||||
import ext.logger
|
||||
import ext.parse
|
||||
import icu.samnyan.aqua.net.db.AquaNetUserRepo
|
||||
@ -24,7 +23,7 @@ class Migrations(
|
||||
|
||||
@PostConstruct
|
||||
fun migrate() {
|
||||
val db = props.findByPropertyKey("migrations")() ?: PropertyEntry("migrations", "[]")
|
||||
val db = props.findByPropertyKey("migrations") ?: PropertyEntry("migrations", "[]")
|
||||
val p = JACKSON.parse<ArrayList<String>>(db.propertyValue)
|
||||
val old = p.size
|
||||
|
||||
@ -47,7 +46,7 @@ class Migrations(
|
||||
if (c.extId > max) {
|
||||
var new = c.extId and max
|
||||
log.info("Removing signed bit: {${c.extId} -> $new} for ${c.luid}")
|
||||
while (cardRepo.findByExtId(new).isPresent) {
|
||||
while (cardRepo.findByExtId(new) != null) {
|
||||
log.error("> Conflicting card found for ${c.luid}: $new")
|
||||
new++
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ class AquaUserServices(
|
||||
|
||||
suspend fun cardByName(username: Str) =
|
||||
if (username.startsWith("user")) username.substring(4).toLongOrNull()
|
||||
?.let { cardRepo.findById(it).getOrNull() } ?: (404 - "Card not found")
|
||||
?.let { cardRepo.findById(it)() } ?: (404 - "Card not found")
|
||||
else byName(username) { it.ghostCard }
|
||||
|
||||
suspend fun <T> cardByName(username: Str, callback: suspend (Card) -> T) = callback(cardByName(username))
|
||||
|
||||
@ -118,7 +118,7 @@ abstract class GameApiController<T : IUserData>(val name: String, userDataClass:
|
||||
}
|
||||
|
||||
@API("playlog")
|
||||
fun playlog(@RP id: Long): IGenericGamePlaylog = playlogRepo.findById(id).getOrNull() ?: (404 - "Playlog not found")
|
||||
fun playlog(@RP id: Long): IGenericGamePlaylog = playlogRepo.findById(id)() ?: (404 - "Playlog not found")
|
||||
|
||||
val userDetailFields by lazy { userDataClass.gettersMap().let { vm ->
|
||||
(settableFields.keys.toSet() + gettableFields)
|
||||
|
||||
@ -14,7 +14,6 @@ import org.springframework.data.repository.NoRepositoryBean
|
||||
import org.springframework.transaction.PlatformTransactionManager
|
||||
import org.springframework.transaction.support.TransactionTemplate
|
||||
import java.time.LocalDateTime
|
||||
import java.util.*
|
||||
import kotlin.io.path.Path
|
||||
import kotlin.io.path.writeText
|
||||
import kotlin.reflect.KClass
|
||||
@ -43,7 +42,7 @@ interface IExportClass<UserModel: IUserData> {
|
||||
@NoRepositoryBean
|
||||
interface IUserRepo<UserModel, ThisModel>: JpaRepository<ThisModel, Long> {
|
||||
fun findByUser(user: UserModel): List<ThisModel>
|
||||
fun findSingleByUser(user: UserModel): Optional<ThisModel>
|
||||
fun findSingleByUser(user: UserModel): ThisModel?
|
||||
}
|
||||
|
||||
/**
|
||||
@ -89,7 +88,7 @@ abstract class ImportController<ExportModel: IExportClass<UserModel>, UserModel:
|
||||
userData = userDataRepo.findByCard(c) ?: (404 - "User not found")
|
||||
exportRepos.forEach { (f, u) ->
|
||||
if (f returns List::class) f.set(this, u.findByUser(userData))
|
||||
else u.findSingleByUser(userData)()?.let { f.set(this, it) }
|
||||
else u.findSingleByUser(userData)?.let { f.set(this, it) }
|
||||
}
|
||||
customExporters.forEach { (f, exporter) ->
|
||||
exporter(userData, options)?.let { f.set(this, it) }
|
||||
|
||||
@ -125,7 +125,7 @@ open class BaseEntity(
|
||||
@NoRepositoryBean
|
||||
interface GenericUserDataRepo<T : IUserData> : JpaRepository<T, Long> {
|
||||
fun findByCard(card: Card): T?
|
||||
fun findByCard_ExtId(extId: Long): Optional<T>
|
||||
fun findByCard_ExtId(extId: Long): T?
|
||||
|
||||
@Query("select e from #{#entityName} e where e.card.rankingBanned = false")
|
||||
fun findAllNonBanned(): List<T>
|
||||
|
||||
@ -14,6 +14,7 @@ import icu.samnyan.aqua.sega.maimai2.model.userdata.*
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import kotlin.reflect.full.declaredMembers
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
@RestController
|
||||
@API("api/v2/game/mai2")
|
||||
class Mai2Import(
|
||||
@ -61,7 +62,7 @@ class Mai2Import(
|
||||
}
|
||||
},
|
||||
Maimai2DataExport::userFavoriteMusicList to { user: Mai2UserDetail, _: ExportOptions ->
|
||||
repos.userGeneralData.findByUserAndPropertyKey(user, "favorite_music").orElse(null)
|
||||
repos.userGeneralData.findByUserAndPropertyKey(user, "favorite_music")
|
||||
?.propertyValue
|
||||
?.takeIf { it.isNotEmpty() }
|
||||
?.split(",")
|
||||
@ -78,7 +79,7 @@ class Mai2Import(
|
||||
if (favoriteMusicList.isNotEmpty()) {
|
||||
val key = "favorite_music"
|
||||
// This field always imports as incremental, since the userGeneralData field (for backwards compatibility) is processed before this
|
||||
val data = repos.userGeneralData.findByUserAndPropertyKey(user, key).orElse(null)
|
||||
val data = repos.userGeneralData.findByUserAndPropertyKey(user, key)
|
||||
?: Mai2UserGeneralData().apply { this.user = user; propertyKey = key }
|
||||
repos.userGeneralData.save(data.apply {
|
||||
propertyValue = favoriteMusicList.sortedBy { it.orderId }.map { it.id }.joinToString(",")
|
||||
|
||||
@ -20,24 +20,18 @@ class Mai2MusicDetailImport(
|
||||
@PostMapping("import-music-detail")
|
||||
suspend fun importMusicDetail(@RP token: String, @RB data: List<Mai2UserMusicDetail>) = us.jwt.auth(token) { u ->
|
||||
us.cardByName(u.username) { card ->
|
||||
val user = repos.userData.findByCardExtId(card.extId).orElse(null) ?: (404 - "User not found")
|
||||
val user = repos.userData.findByCardExtId(card.extId) ?: (404 - "User not found")
|
||||
data.forEach { newMusic ->
|
||||
val musicRec = repos.userMusicDetail.findByUserAndMusicIdAndLevel(user, newMusic.musicId, newMusic.level)
|
||||
if (musicRec.isPresent) {
|
||||
val music = musicRec.get()
|
||||
newMusic.user = user
|
||||
repos.userMusicDetail.findByUserAndMusicIdAndLevel(user, newMusic.musicId, newMusic.level)?.let { m ->
|
||||
newMusic.apply {
|
||||
id = music.id
|
||||
this.user = user
|
||||
achievement = achievement.coerceAtLeast(music.achievement)
|
||||
scoreRank = scoreRank.coerceAtLeast(music.scoreRank)
|
||||
comboStatus = comboStatus.coerceAtLeast(music.comboStatus)
|
||||
syncStatus = syncStatus.coerceAtLeast(music.syncStatus)
|
||||
deluxscoreMax = deluxscoreMax.coerceAtLeast(music.deluxscoreMax)
|
||||
playCount = playCount.coerceAtLeast(music.playCount)
|
||||
}
|
||||
} else {
|
||||
newMusic.apply {
|
||||
this.user = user
|
||||
id = m.id
|
||||
achievement = achievement.coerceAtLeast(m.achievement)
|
||||
scoreRank = scoreRank.coerceAtLeast(m.scoreRank)
|
||||
comboStatus = comboStatus.coerceAtLeast(m.comboStatus)
|
||||
syncStatus = syncStatus.coerceAtLeast(m.syncStatus)
|
||||
deluxscoreMax = deluxscoreMax.coerceAtLeast(m.deluxscoreMax)
|
||||
playCount = playCount.coerceAtLeast(m.playCount)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,9 +63,9 @@ class Maimai2(
|
||||
us.jwt.auth(t) { u ->
|
||||
if (u.username == username) return@auth null
|
||||
us.cardByName(u.username) { myCard ->
|
||||
val user = repos.userData.findByCardExtId(card.extId).orElse(null) ?: (404 - "User not found")
|
||||
val myRival = repos.userGeneralData.findByUser_Card_ExtIdAndPropertyKey(myCard.extId, "favorite_rival")
|
||||
.map { it.propertyValue.split(',') }.orElse(emptyList()).filter { it.isNotEmpty() }.map { it.long() }
|
||||
val user = repos.userData.findByCardExtId(card.extId) ?: (404 - "User not found")
|
||||
val myRival = (repos.userGeneralData.findByUser_Card_ExtIdAndPropertyKey(myCard.extId, "favorite_rival")?.propertyValue?.split(',') ?: emptyList())
|
||||
.filter { it.isNotEmpty() }.map { it.long() }
|
||||
myRival.contains(user.id)
|
||||
}
|
||||
}
|
||||
@ -137,7 +137,7 @@ class Maimai2(
|
||||
if (loginBonus.none { it.bonusId == bonusId }) {
|
||||
// create one
|
||||
val newBonus = Mai2UserLoginBonus().apply {
|
||||
user = repos.userData.findByCardExtId(card.extId).orElse(null) ?: (404 - "User not found")
|
||||
user = repos.userData.findByCardExtId(card.extId) ?: (404 - "User not found")
|
||||
this.bonusId = bonusId
|
||||
isCurrent = true
|
||||
}
|
||||
@ -159,10 +159,10 @@ class Maimai2(
|
||||
suspend fun setRival(@RP token: String, @RP rivalUserName: String, @RP isAdd: Boolean) = us.jwt.auth(token) { u ->
|
||||
us.cardByName(u.username) { myCard ->
|
||||
val rivalCard = us.cardByName(rivalUserName) { it }
|
||||
val rivalUser = repos.userData.findByCardExtId(rivalCard.extId).orElse(null) ?: (404 - "User not found")
|
||||
val myRival = repos.userGeneralData.findByUser_Card_ExtIdAndPropertyKey(myCard.extId, "favorite_rival").orElse(null)
|
||||
val rivalUser = repos.userData.findByCardExtId(rivalCard.extId) ?: (404 - "User not found")
|
||||
val myRival = repos.userGeneralData.findByUser_Card_ExtIdAndPropertyKey(myCard.extId, "favorite_rival")
|
||||
?: Mai2UserGeneralData().apply {
|
||||
user = repos.userData.findByCardExtId(myCard.extId).orElse(null) ?: (404 - "User not found")
|
||||
user = repos.userData.findByCardExtId(myCard.extId) ?: (404 - "User not found")
|
||||
propertyKey = "favorite_rival"
|
||||
}
|
||||
val myRivalList = myRival.propertyValue.split(',').filter { it.isNotEmpty() }.mut
|
||||
|
||||
@ -37,7 +37,7 @@ class Wacca(
|
||||
|
||||
val data = userDataRepo.findByCard_ExtId(card.extId)
|
||||
|
||||
genericUserSummary(card, mapOf(), null, if (data.isPresent) data.get().favoriteSongs else null)
|
||||
genericUserSummary(card, mapOf(), null, data?.favoriteSongs)
|
||||
}
|
||||
|
||||
override val shownRanks: List<Pair<Int, String>> = waccaScores.filter { it.first > 85 * 10000 }
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package icu.samnyan.aqua.sega.aimedb
|
||||
|
||||
import ext.invoke
|
||||
import ext.logger
|
||||
import ext.toHex
|
||||
import icu.samnyan.aqua.net.Fedy
|
||||
@ -127,7 +126,7 @@ class AimeDB(
|
||||
}
|
||||
}
|
||||
|
||||
fun getCard(accessCode: String) = us.cardRepo.findByLuid(accessCode)()?.maybeGhost()?.let { card ->
|
||||
fun getCard(accessCode: String) = us.cardRepo.findByLuid(accessCode)?.maybeGhost()?.let { card ->
|
||||
// Update card access time and return the extId
|
||||
us.cardRepo.save(card.apply { accessTime = LocalDateTime.now() }).extId
|
||||
} ?: -1
|
||||
@ -198,7 +197,7 @@ class AimeDB(
|
||||
var status = 0
|
||||
var aimeId = 0L
|
||||
|
||||
if (us.cardRepo.findByLuid(luid).isEmpty) {
|
||||
if (us.cardRepo.findByLuid(luid) == null) {
|
||||
val card: Card = cardService.registerByAccessCode(luid)
|
||||
|
||||
status = 1
|
||||
|
||||
@ -58,7 +58,7 @@ fun ChusanController.chusanInit() {
|
||||
"GetUserRecMusic".paged("userRecMusicList") {
|
||||
// musicId: int, recMusicList: string
|
||||
// musicId cannot be the same with the id in recMusicList
|
||||
val u = db.userData.findByCard_ExtId(uid)() ?: return@paged empty
|
||||
val u = db.userData.findByCard_ExtId(uid) ?: return@paged empty
|
||||
val list = (chusan.recommendedMusic[u.id] ?: ls()).filter { it != 1 }
|
||||
|
||||
if (list.isEmpty()) empty
|
||||
@ -87,8 +87,8 @@ fun ChusanController.chusanInit() {
|
||||
|
||||
// Net battle data
|
||||
"GetUserNetBattleData" api@ {
|
||||
val u = db.userData.findByCard_ExtId(uid)() ?: return@api null
|
||||
val misc = db.userMisc.findSingleByUser(u)()
|
||||
val u = db.userData.findByCard_ExtId(uid) ?: return@api null
|
||||
val misc = db.userMisc.findSingleByUser(u)
|
||||
val recent = db.netBattleLog.findTop20ByUserOrderByIdDesc(u)
|
||||
mapOf("userId" to uid, "userNetBattleData" to mapOf(
|
||||
"recentNBSelectMusicList" to (misc?.recentNbSelect ?: empty),
|
||||
@ -106,7 +106,7 @@ fun ChusanController.chusanInit() {
|
||||
)
|
||||
}
|
||||
|
||||
db.userData.findByCard_ExtId(uid)()?.card?.aquaUser?.gameOptions?.run {
|
||||
db.userData.findByCard_ExtId(uid)?.card?.aquaUser?.gameOptions?.run {
|
||||
listOf(chusanSymbolChat1, chusanSymbolChat2, chusanSymbolChat3, chusanSymbolChat4)
|
||||
.flatMapIndexed { i, sym -> sym?.makeSymbols(i) ?: empty }
|
||||
} ?: empty
|
||||
@ -114,10 +114,10 @@ fun ChusanController.chusanInit() {
|
||||
|
||||
// User handlers
|
||||
"GetUserData" {
|
||||
db.userData.findByCard_ExtId(uid)()?.let{ u -> mapOf("userId" to uid, "userData" to u) }
|
||||
db.userData.findByCard_ExtId(uid)?.let{ u -> mapOf("userId" to uid, "userData" to u) }
|
||||
}
|
||||
"GetUserOption" {
|
||||
val userGameOption = db.userGameOption.findSingleByUser_Card_ExtId(uid)() ?: (400 - "User not found")
|
||||
val userGameOption = db.userGameOption.findSingleByUser_Card_ExtId(uid) ?: (400 - "User not found")
|
||||
mapOf("userId" to uid, "userGameOption" to userGameOption)
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ fun ChusanController.chusanInit() {
|
||||
parsing { UserCMissionResp().apply {
|
||||
missionId = parsing { data["missionId"]!!.int }
|
||||
} }.apply {
|
||||
db.userCMission.findByUser_Card_ExtIdAndMissionId(uid, missionId)()?.let {
|
||||
db.userCMission.findByUser_Card_ExtIdAndMissionId(uid, missionId)?.let {
|
||||
point = it.point
|
||||
userCMissionProgressList = db.userCMissionProgress.findByUser_Card_ExtIdAndMissionId(uid, missionId)
|
||||
}
|
||||
@ -151,7 +151,7 @@ fun ChusanController.chusanInit() {
|
||||
// Introduced in LMN+
|
||||
"GetUserCMissionList" api@ {
|
||||
val missions = parsing { (data["userCMissionList"] as List<JDict>).map { it["missionId"]!!.int } }
|
||||
val u = db.userData.findByCard_ExtId(uid)() ?: return@api null
|
||||
val u = db.userData.findByCard_ExtId(uid) ?: return@api null
|
||||
|
||||
db.userCMission.findByUserAndMissionIdIn(u, missions).map {
|
||||
UserCMissionResp().apply {
|
||||
@ -190,7 +190,7 @@ fun ChusanController.chusanInit() {
|
||||
val items = db.userItem.findAllByUser_Card_ExtIdAndItemKind(uid, kind).mut
|
||||
|
||||
// Check game options
|
||||
db.userData.findByCard_ExtId(uid)()?.card?.aquaUser?.gameOptions?.let {
|
||||
db.userData.findByCard_ExtId(uid)?.card?.aquaUser?.gameOptions?.let {
|
||||
if (it.chusanInfinitePenguins && kind == 5) {
|
||||
items.removeAll { it.itemId in penguins }
|
||||
items.addAll(penguins.map { Chu3UserItem(kind, it, 999, true) })
|
||||
@ -207,7 +207,7 @@ fun ChusanController.chusanInit() {
|
||||
"GetUserFavoriteItem".pagedWithKind("userFavoriteItemList") {
|
||||
val kind = parsing { data["kind"]!!.int }
|
||||
mapOf("kind" to kind) grabs {
|
||||
val misc = db.userMisc.findSingleByUser_Card_ExtId(uid)()
|
||||
val misc = db.userMisc.findSingleByUser_Card_ExtId(uid)
|
||||
when (kind) {
|
||||
1 -> misc?.favMusic ?: empty
|
||||
3 -> empty // TODO: Favorite character
|
||||
@ -220,9 +220,9 @@ fun ChusanController.chusanInit() {
|
||||
"lastDataVersion,trophyId,classEmblemMedal,classEmblemBase,battleRankId").split(',').toSet()
|
||||
|
||||
"GetUserPreview" api@ {
|
||||
val user = db.userData.findByCard_ExtId(uid)() ?: return@api null
|
||||
val user = db.userData.findByCard_ExtId(uid) ?: return@api null
|
||||
val chara = db.userCharacter.findByUserAndCharacterId(user, user.characterId)
|
||||
val option = db.userGameOption.findSingleByUser(user)()
|
||||
val option = db.userGameOption.findSingleByUser(user)
|
||||
val userDict = user.toJson().jsonMap().filterKeys { it in userPreviewKeys }
|
||||
|
||||
val res = mutableMapOf(
|
||||
@ -262,7 +262,7 @@ fun ChusanController.chusanInit() {
|
||||
}
|
||||
|
||||
"GetUserRecentRating".paged("userRecentRatingList") {
|
||||
db.userGeneralData.findByUser_Card_ExtIdAndPropertyKey(uid, "recent_rating_list")()
|
||||
db.userGeneralData.findByUser_Card_ExtIdAndPropertyKey(uid, "recent_rating_list")
|
||||
?.propertyValue?.some
|
||||
?.split(',')?.dropLastWhile { it.isEmpty() }?.map { it.split(':') }
|
||||
?.map { (musicId, level, score) -> UserRecentRating(musicId.int, level.int, "2000001", score.int) }
|
||||
@ -278,7 +278,7 @@ fun ChusanController.chusanInit() {
|
||||
|
||||
"GetUserTeam" {
|
||||
val playDate = parsing { data["playDate"] as String }
|
||||
val team = db.userData.findByCard_ExtId(uid)()?.card?.aquaUser?.gameOptions?.chusanTeamName?.some
|
||||
val team = db.userData.findByCard_ExtId(uid)?.card?.aquaUser?.gameOptions?.chusanTeamName?.some
|
||||
?: props.teamName?.some ?: "一緒に歌おう!"
|
||||
|
||||
mapOf(
|
||||
@ -349,7 +349,7 @@ fun ChusanController.chusanInit() {
|
||||
// TODO: Test login bonus
|
||||
"GameLogin" {
|
||||
// fun process() {
|
||||
// val u = db.userData.findByCard_ExtId(uid)() ?: return
|
||||
// val u = db.userData.findByCard_ExtId(uid) ?: return
|
||||
// db.userData.save(u.apply { lastLoginDate = LocalDateTime.now() })
|
||||
//
|
||||
// if (!props.loginBonusEnable) return
|
||||
@ -357,7 +357,7 @@ fun ChusanController.chusanInit() {
|
||||
//
|
||||
// bonusList.forEach { preset ->
|
||||
// // Check if a user already has some progress and if not, add the login bonus entry
|
||||
// val bonus = db.userLoginBonus.findLoginBonus(uid.int, 1, preset.id)()
|
||||
// val bonus = db.userLoginBonus.findLoginBonus(uid.int, 1, preset.id)
|
||||
// ?: UserLoginBonus(1, uid.int, preset.id).let { db.userLoginBonus.save(it) }
|
||||
// if (bonus.isFinished) return@forEach
|
||||
//
|
||||
@ -377,10 +377,10 @@ fun ChusanController.chusanInit() {
|
||||
// if (preset.id < 3000) bCount = 1
|
||||
// else finished = true
|
||||
// }
|
||||
// db.gameLoginBonus.findByRequiredDays(1, preset.id, bCount)()?.let {
|
||||
// db.gameLoginBonus.findByRequiredDays(1, preset.id, bCount)?.let {
|
||||
// db.userItem.save(UserItem(6, it.presentId, it.itemNum).apply { user = u })
|
||||
// }
|
||||
// val toSave = db.userLoginBonus.findLoginBonus(uid.int, 1, preset.id)()
|
||||
// val toSave = db.userLoginBonus.findLoginBonus(uid.int, 1, preset.id)
|
||||
// ?: UserLoginBonus().apply { user = uid.int; presetId = preset.id; version = 1 }
|
||||
//
|
||||
// db.userLoginBonus.save(toSave.apply {
|
||||
@ -394,7 +394,7 @@ fun ChusanController.chusanInit() {
|
||||
// }
|
||||
// process()
|
||||
|
||||
val user = db.userData.findByCard_ExtId(uid)()
|
||||
val user = db.userData.findByCard_ExtId(uid)
|
||||
|
||||
if (user?.card?.status == CardStatus.MIGRATED_TO_MINATO) {
|
||||
"""{"returnCode":"0"}"""
|
||||
|
||||
@ -14,20 +14,20 @@ fun ChusanController.cmApiInit() {
|
||||
|
||||
// CardMaker (TODO: Somebody test this, I don't have a card maker)
|
||||
"CMGetUserData" {
|
||||
val user = db.userData.findByCard_ExtId(uid)() ?: (400 - "User not found")
|
||||
val user = db.userData.findByCard_ExtId(uid) ?: (400 - "User not found")
|
||||
user.userEmoney = UserEmoney()
|
||||
mapOf("userId" to uid, "userData" to user, "userEmoney" to user.userEmoney)
|
||||
}
|
||||
|
||||
"CMGetUserPreview" {
|
||||
val user = db.userData.findByCard_ExtId(uid)() ?: (400 - "User not found")
|
||||
val user = db.userData.findByCard_ExtId(uid) ?: (400 - "User not found")
|
||||
mapOf("userName" to user.userName, "level" to user.level, "medal" to user.medal, "lastDataVersion" to user.lastDataVersion, "isLogin" to false)
|
||||
}
|
||||
|
||||
"CMUpsertUserGacha" api@ {
|
||||
val (gachaId, placeId) = parsing { data["gachaId"]!!.int to data["placeId"]!!.int }
|
||||
|
||||
val u = db.userData.findByCard_ExtId(uid)() ?: return@api null
|
||||
val u = db.userData.findByCard_ExtId(uid) ?: return@api null
|
||||
val upsertUserGacha = parsing { mapper.convert<UpsertUserGacha>(data["cmUpsertUserGacha"]!!) }
|
||||
|
||||
upsertUserGacha.gameGachaCardList?.let { lst ->
|
||||
@ -99,7 +99,7 @@ fun ChusanController.cmApiInit() {
|
||||
val userCardPrintState = cmMapper.convert<UserCardPrintState>(parsing { data["userCardPrintState"]!! })
|
||||
val userItemList = cmMapper.convert<List<Chu3UserItem>>(parsing { data["userItemList"]!! })
|
||||
|
||||
val u = db.userData.findByCard_ExtId(uid)() ?: return@api null
|
||||
val u = db.userData.findByCard_ExtId(uid) ?: return@api null
|
||||
|
||||
db.userItem.saveAll(
|
||||
userItemList.mapApply {
|
||||
|
||||
@ -10,7 +10,7 @@ import icu.samnyan.aqua.sega.general.model.UserRecentRating
|
||||
fun ChusanController.upsertApiInit() {
|
||||
"UpsertUserChargelog" {
|
||||
val charge = parsing { mapper.convert<UserCharge>(data["userCharge"] as JDict) }
|
||||
charge.user = db.userData.findByCard_ExtId(uid)() ?: (400 - "User not found")
|
||||
charge.user = db.userData.findByCard_ExtId(uid) ?: (400 - "User not found")
|
||||
charge.id = db.userCharge.findByUser_Card_ExtIdAndChargeId(uid, charge.chargeId)?.id ?: 0
|
||||
db.userCharge.save(charge)
|
||||
"""{"returnCode":"1"}"""
|
||||
@ -21,10 +21,10 @@ fun ChusanController.upsertApiInit() {
|
||||
|
||||
req.run {
|
||||
// UserData
|
||||
val oldUser = db.userData.findByCard_ExtId(uid)()
|
||||
val oldUser = db.userData.findByCard_ExtId(uid)
|
||||
val u = (userData?.get(0) ?: return@api null).apply {
|
||||
id = oldUser?.id ?: 0
|
||||
card = oldUser?.card ?: us.cardRepo.findByExtId(uid).expect("Card not found")
|
||||
card = oldUser?.card ?: us.cardRepo.findByExtId(uid) ?: (404 - "Card not found")
|
||||
|
||||
val version = data["version"] as? String ?: "0.00"
|
||||
val versionNumber = version.toDoubleOrNull() ?: 0.0
|
||||
@ -66,12 +66,12 @@ fun ChusanController.upsertApiInit() {
|
||||
userRatingBaseNextList to "rating_next_list",
|
||||
userRatingBaseNewList to "rating_new_list"
|
||||
).filter { it.first != null }.forEach { (list, key) ->
|
||||
val d = db.userGeneralData.findByUserAndPropertyKey(u, key)()
|
||||
val d = db.userGeneralData.findByUserAndPropertyKey(u, key)
|
||||
?: UserGeneralData().apply { user = u; propertyKey = key }
|
||||
db.userGeneralData.save(d.apply { propertyValue = list!!.str() })
|
||||
}
|
||||
|
||||
val misc = db.userMisc.findSingleByUser(u)() ?: Chu3UserMisc().apply { user = u }
|
||||
val misc = db.userMisc.findSingleByUser(u) ?: Chu3UserMisc().apply { user = u }
|
||||
|
||||
// Favorites
|
||||
userFavoriteMusicList?.filter { it.musicId != -1 }?.ifEmpty { null }?.let { list ->
|
||||
@ -113,7 +113,7 @@ fun ChusanController.upsertApiInit() {
|
||||
// List data
|
||||
userGameOption?.get(0)?.let { obj ->
|
||||
db.userGameOption.saveAndFlush(obj.apply {
|
||||
id = db.userGameOption.findSingleByUser(u)()?.id ?: 0 }) }
|
||||
id = db.userGameOption.findSingleByUser(u)?.id ?: 0 }) }
|
||||
|
||||
userMapAreaList?.let { list ->
|
||||
db.userMap.saveAll(list.distinctBy { it.mapAreaId }.mapApply {
|
||||
@ -137,7 +137,7 @@ fun ChusanController.upsertApiInit() {
|
||||
|
||||
userChargeList?.let { list ->
|
||||
db.userCharge.saveAll(list.distinctBy { it.chargeId }.mapApply {
|
||||
id = db.userCharge.findByUserAndChargeId(u, chargeId)()?.id ?: 0 }) }
|
||||
id = db.userCharge.findByUserAndChargeId(u, chargeId)?.id ?: 0 }) }
|
||||
|
||||
userCourseList?.let { list ->
|
||||
db.userCourse.saveAll(list.distinctBy { it.courseId }.mapApply {
|
||||
@ -155,7 +155,7 @@ fun ChusanController.upsertApiInit() {
|
||||
// userLoginBonusList?.let { list ->
|
||||
// db.userLoginBonus.saveAll(list.distinctBy { it["presetId"] as String }.map {
|
||||
// val id = it["presetId"]!!.int
|
||||
// (db.userLoginBonus.findLoginBonus(uid.int, 1, id)() ?: UserLoginBonus()).apply {
|
||||
// (db.userLoginBonus.findLoginBonus(uid.int, 1, id) ?: UserLoginBonus()).apply {
|
||||
// user = u.id.toInt()
|
||||
// presetId = id
|
||||
// lastUpdateDate = LocalDateTime.now()
|
||||
@ -165,7 +165,7 @@ fun ChusanController.upsertApiInit() {
|
||||
// }
|
||||
|
||||
req.userCMissionList?.forEach { d ->
|
||||
(db.userCMission.findByUser_Card_ExtIdAndMissionId(uid, d.missionId)()
|
||||
(db.userCMission.findByUser_Card_ExtIdAndMissionId(uid, d.missionId)
|
||||
?: UserCMission().apply {
|
||||
missionId = d.missionId
|
||||
user = u
|
||||
@ -173,7 +173,7 @@ fun ChusanController.upsertApiInit() {
|
||||
).apply { point = d.point }.also { db.userCMission.save(it) }
|
||||
|
||||
d.userCMissionProgressList?.forEach inner@ { p ->
|
||||
(db.userCMissionProgress.findByUser_Card_ExtIdAndMissionIdAndOrder(uid, d.missionId, p.order)()
|
||||
(db.userCMissionProgress.findByUser_Card_ExtIdAndMissionIdAndOrder(uid, d.missionId, p.order)
|
||||
?: UserCMissionProgress().apply {
|
||||
missionId = d.missionId
|
||||
order = p.order
|
||||
|
||||
@ -19,7 +19,7 @@ import java.util.*
|
||||
@NoRepositoryBean
|
||||
interface Chu3UserLinked<T> : IUserRepo<Chu3UserData, T> {
|
||||
fun findByUser_Card_ExtId(extId: Long): List<T>
|
||||
fun findSingleByUser_Card_ExtId(extId: Long): Optional<T>
|
||||
fun findSingleByUser_Card_ExtId(extId: Long): T?
|
||||
fun findByUser_Card_ExtId(extId: Long, pageable: Pageable): Page<T>
|
||||
}
|
||||
|
||||
@ -37,11 +37,11 @@ interface Chu3UserLoginBonusRepo : JpaRepository<UserLoginBonus, Long> {
|
||||
value = "select * from chusan_user_login_bonus where user = ?1 and version = ?2 and preset_id = ?3 limit 1",
|
||||
nativeQuery = true
|
||||
)
|
||||
fun findLoginBonus(userId: Int, version: Int, presetId: Long): Optional<UserLoginBonus>
|
||||
fun findLoginBonus(userId: Int, version: Int, presetId: Long): UserLoginBonus?
|
||||
}
|
||||
|
||||
interface Chu3UserActivityRepo : Chu3UserLinked<Chu3UserActivity> {
|
||||
fun findTopByUserAndActivityIdAndKindOrderByIdDesc(user: Chu3UserData, activityId: Int, kind: Int): Optional<Chu3UserActivity>
|
||||
fun findTopByUserAndActivityIdAndKindOrderByIdDesc(user: Chu3UserData, activityId: Int, kind: Int): Chu3UserActivity?
|
||||
fun findByUserAndActivityIdAndKind(user: Chu3UserData, activityId: Int, kind: Int): Chu3UserActivity?
|
||||
|
||||
fun findAllByUser_Card_ExtIdAndKind(extId: Long, kind: Int): List<Chu3UserActivity>
|
||||
@ -54,17 +54,17 @@ interface Chu3UserCardPrintStateRepo : Chu3UserLinked<UserCardPrintState> {
|
||||
}
|
||||
|
||||
interface Chu3UserCharacterRepo : Chu3UserLinked<UserCharacter> {
|
||||
fun findTopByUserAndCharacterIdOrderByIdDesc(user: Chu3UserData, characterId: Int): Optional<UserCharacter>
|
||||
fun findTopByUserAndCharacterIdOrderByIdDesc(user: Chu3UserData, characterId: Int): UserCharacter?
|
||||
fun findByUserAndCharacterId(user: Chu3UserData, characterId: Int): UserCharacter?
|
||||
}
|
||||
|
||||
interface Chu3UserChargeRepo : Chu3UserLinked<UserCharge> {
|
||||
fun findByUserAndChargeId(extId: Chu3UserData, chargeId: Int): Optional<UserCharge>
|
||||
fun findByUserAndChargeId(extId: Chu3UserData, chargeId: Int): UserCharge?
|
||||
fun findByUser_Card_ExtIdAndChargeId(ext: Long, chargeId: Int): UserCharge?
|
||||
}
|
||||
|
||||
interface Chu3UserCourseRepo : Chu3UserLinked<UserCourse> {
|
||||
fun findTopByUserAndCourseIdOrderByIdDesc(user: Chu3UserData, courseId: Int): Optional<UserCourse>
|
||||
fun findTopByUserAndCourseIdOrderByIdDesc(user: Chu3UserData, courseId: Int): UserCourse?
|
||||
fun findByUserAndCourseId(user: Chu3UserData, courseId: Int): UserCourse?
|
||||
}
|
||||
|
||||
@ -73,25 +73,25 @@ interface Chu3UserDataRepo : GenericUserDataRepo<Chu3UserData> {
|
||||
}
|
||||
|
||||
interface Chu3UserDuelRepo : Chu3UserLinked<UserDuel> {
|
||||
fun findTopByUserAndDuelIdOrderByIdDesc(user: Chu3UserData, duelId: Int): Optional<UserDuel>
|
||||
fun findTopByUserAndDuelIdOrderByIdDesc(user: Chu3UserData, duelId: Int): UserDuel?
|
||||
fun findByUserAndDuelId(user: Chu3UserData, duelId: Int): UserDuel?
|
||||
}
|
||||
|
||||
interface Chu3UserGachaRepo : Chu3UserLinked<UserGacha> {
|
||||
fun findByUserAndGachaId(extId: Chu3UserData, gachaId: Int): Optional<UserGacha>
|
||||
fun findByUserAndGachaId(extId: Chu3UserData, gachaId: Int): UserGacha?
|
||||
}
|
||||
|
||||
interface Chu3UserGameOptionRepo : Chu3UserLinked<UserGameOption>
|
||||
|
||||
interface Chu3UserGeneralDataRepo : Chu3UserLinked<UserGeneralData> {
|
||||
fun findByUserAndPropertyKey(user: Chu3UserData, key: String): Optional<UserGeneralData>
|
||||
fun findByUserAndPropertyKey(user: Chu3UserData, key: String): UserGeneralData?
|
||||
|
||||
fun findByUser_Card_ExtIdAndPropertyKey(extId: Long, key: String): Optional<UserGeneralData>
|
||||
fun findByUser_Card_ExtIdAndPropertyKey(extId: Long, key: String): UserGeneralData?
|
||||
}
|
||||
|
||||
interface Chu3UserItemRepo : Chu3UserLinked<Chu3UserItem> {
|
||||
fun findAllByUser(user: Chu3UserData): List<Chu3UserItem>
|
||||
fun findTopByUserAndItemIdAndItemKindOrderByIdDesc(user: Chu3UserData, itemId: Int, itemKind: Int): Optional<Chu3UserItem>
|
||||
fun findTopByUserAndItemIdAndItemKindOrderByIdDesc(user: Chu3UserData, itemId: Int, itemKind: Int): Chu3UserItem?
|
||||
fun findByUserAndItemIdAndItemKind(user: Chu3UserData, itemId: Int, itemKind: Int): Chu3UserItem?
|
||||
|
||||
fun findAllByUser_Card_ExtIdAndItemKind(extId: Long, itemKind: Int, pageable: Pageable): Page<Chu3UserItem>
|
||||
@ -106,7 +106,7 @@ interface Chu3UserMapRepo : Chu3UserLinked<UserMap> {
|
||||
}
|
||||
|
||||
interface Chu3UserMusicDetailRepo : Chu3UserLinked<UserMusicDetail>, GenericUserMusicRepo<UserMusicDetail> {
|
||||
fun findTopByUserAndMusicIdAndLevelOrderByIdDesc(user: Chu3UserData, musicId: Int, level: Int): Optional<UserMusicDetail>
|
||||
fun findTopByUserAndMusicIdAndLevelOrderByIdDesc(user: Chu3UserData, musicId: Int, level: Int): UserMusicDetail?
|
||||
fun findByUserAndMusicIdAndLevel(user: Chu3UserData, musicId: Int, level: Int): UserMusicDetail?
|
||||
|
||||
fun findByUser_Card_ExtIdAndMusicId(extId: Long, musicId: Int): List<UserMusicDetail>
|
||||
@ -119,7 +119,7 @@ interface Chu3UserPlaylogRepo : GenericPlaylogRepo<UserPlaylog>, Chu3UserLinked<
|
||||
}
|
||||
|
||||
interface Chu3UserCMissionRepo : Chu3UserLinked<UserCMission> {
|
||||
fun findByUser_Card_ExtIdAndMissionId(extId: Long, missionId: Int): Optional<UserCMission>
|
||||
fun findByUser_Card_ExtIdAndMissionId(extId: Long, missionId: Int): UserCMission?
|
||||
fun findByUserAndMissionIdIn(user: Chu3UserData, missionIds: Collection<Int>): List<UserCMission>
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ interface Chu3UserCMissionProgressRepo : Chu3UserLinked<UserCMissionProgress> {
|
||||
fun findByUser_Card_ExtIdAndMissionId(extId: Long, missionId: Int): List<UserCMissionProgress>
|
||||
fun findByUserAndMissionId(user: Chu3UserData, missionId: Int): List<UserCMissionProgress>
|
||||
|
||||
fun findByUser_Card_ExtIdAndMissionIdAndOrder(extId: Long, missionId: Int, order: Int): Optional<UserCMissionProgress>
|
||||
fun findByUser_Card_ExtIdAndMissionIdAndOrder(extId: Long, missionId: Int, order: Int): UserCMissionProgress?
|
||||
}
|
||||
|
||||
interface Chu3NetBattleLogRepo : Chu3UserLinked<Chu3NetBattleLog> {
|
||||
@ -171,7 +171,7 @@ interface Chu3GameLoginBonusRepo : JpaRepository<GameLoginBonus, Int> {
|
||||
value = "select * from chusan_game_login_bonus where version = ?1 and preset_id = ?2 and need_login_day_count = ?3 limit 1",
|
||||
nativeQuery = true
|
||||
)
|
||||
fun findByRequiredDays(version: Int, presetId: Int, requiredDays: Int): Optional<GameLoginBonus>
|
||||
fun findByRequiredDays(version: Int, presetId: Int, requiredDays: Int): GameLoginBonus?
|
||||
}
|
||||
|
||||
interface Chu3UserRegionsRepo: Chu3UserLinked<UserRegions> {
|
||||
|
||||
@ -1,40 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.operation;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest;
|
||||
import icu.samnyan.aqua.sega.diva.model.response.operation.PingResponse;
|
||||
import icu.samnyan.aqua.sega.general.dao.PropertyEntryRepository;
|
||||
import icu.samnyan.aqua.sega.general.model.PropertyEntry;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class PingHandler extends BaseHandler {
|
||||
private static final Logger logger = LoggerFactory.getLogger(PingHandler.class);
|
||||
private final PropertyEntryRepository propertyEntryRepository;
|
||||
|
||||
public String handle(BaseRequest request) {
|
||||
|
||||
PropertyEntry news = propertyEntryRepository.findByPropertyKey("diva_news").orElseGet(() -> new PropertyEntry("diva_news", "xxx"));
|
||||
PropertyEntry warning = propertyEntryRepository.findByPropertyKey("diva_warning").orElseGet(() -> new PropertyEntry("diva_warning", "xxx"));
|
||||
|
||||
PingResponse response = new PingResponse(
|
||||
request.getCmd(),
|
||||
request.getReq_id(),
|
||||
"ok",
|
||||
news.getPropertyValue(),
|
||||
warning.getPropertyValue()
|
||||
);
|
||||
|
||||
String resp = this.build(mapper.toMap(response));
|
||||
logger.info("Response: {}", resp);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.operation
|
||||
|
||||
import ext.logger
|
||||
import icu.samnyan.aqua.sega.diva.handler.BaseHandler
|
||||
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.operation.PingResponse
|
||||
import icu.samnyan.aqua.sega.general.dao.PropertyEntryRepository
|
||||
import icu.samnyan.aqua.sega.general.model.PropertyEntry
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component
|
||||
class PingHandler(val rp: PropertyEntryRepository) : BaseHandler() {
|
||||
val logger = logger()
|
||||
|
||||
fun handle(request: BaseRequest): String? {
|
||||
val news: PropertyEntry = rp.findByPropertyKey("diva_news") ?: PropertyEntry("diva_news", "xxx")
|
||||
val warning: PropertyEntry = rp.findByPropertyKey("diva_warning") ?: PropertyEntry("diva_warning", "xxx")
|
||||
|
||||
val response = PingResponse(
|
||||
request.cmd,
|
||||
request.req_id,
|
||||
"ok",
|
||||
news.propertyValue,
|
||||
warning.propertyValue
|
||||
)
|
||||
|
||||
val resp = this.build(mapper.toMap(response))
|
||||
logger.info("Response: {}", resp)
|
||||
|
||||
return resp
|
||||
}
|
||||
}
|
||||
@ -3,13 +3,12 @@ package icu.samnyan.aqua.sega.general.dao
|
||||
import icu.samnyan.aqua.sega.general.model.Card
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.stereotype.Repository
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Repository("SegaCardRepository")
|
||||
interface CardRepository : JpaRepository<Card, Long> {
|
||||
fun findByExtId(extId: Long): Optional<Card>
|
||||
fun findByLuid(luid: String): Optional<Card>
|
||||
fun findByExtId(extId: Long): Card?
|
||||
fun findByLuid(luid: String): Card?
|
||||
}
|
||||
|
||||
@ -10,5 +10,5 @@ import java.util.*
|
||||
*/
|
||||
@Repository
|
||||
interface PropertyEntryRepository : JpaRepository<PropertyEntry, Long> {
|
||||
fun findByPropertyKey(key: String): Optional<PropertyEntry>
|
||||
fun findByPropertyKey(key: String): PropertyEntry?
|
||||
}
|
||||
|
||||
@ -6,9 +6,7 @@ import icu.samnyan.aqua.sega.general.dao.CardRepository
|
||||
import icu.samnyan.aqua.sega.general.model.Card
|
||||
import org.springframework.stereotype.Service
|
||||
import java.time.LocalDateTime
|
||||
import java.util.*
|
||||
import java.util.concurrent.ThreadLocalRandom
|
||||
import kotlin.jvm.optionals.getOrNull
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
@ -22,7 +20,7 @@ class CardService(val cardRepo: CardRepository)
|
||||
* @param extId External ID
|
||||
* @return Optional of a Card
|
||||
*/
|
||||
fun getCardByExtId(extId: Long): Optional<Card> = cardRepo.findByExtId(extId)
|
||||
fun getCardByExtId(extId: Long): Card? = cardRepo.findByExtId(extId)
|
||||
|
||||
/**
|
||||
* Register a new card with access code
|
||||
@ -51,19 +49,19 @@ class CardService(val cardRepo: CardRepository)
|
||||
val idm = id.replace(":", "").replace(" ", "")
|
||||
|
||||
// Check case (1) and (4)
|
||||
cardRepo.findByLuid(idm)?.getOrNull()?.let { return it }
|
||||
cardRepo.findByLuid(idm.padStart(20, '0'))?.getOrNull()?.let { return it }
|
||||
cardRepo.findByLuid(idm)?.let { return it }
|
||||
cardRepo.findByLuid(idm.padStart(20, '0'))?.let { return it }
|
||||
|
||||
// Check case (2)
|
||||
// Then convert to long, left pad zeros to make 20 digits, and look up
|
||||
idm.toLongOrNull(16)?.let { idmLong ->
|
||||
cardRepo.findByLuid("%020d".format(idmLong))?.getOrNull()?.let { return it }
|
||||
cardRepo.findByLuid("%020d".format(idmLong))?.let { return it }
|
||||
}
|
||||
|
||||
// Check case (3)
|
||||
idm.padStart(16, '0').takeLast(12).let { "012E$it" }.let { idmMasked ->
|
||||
idmMasked.toLongOrNull(16)?.let { idmMaskedLong ->
|
||||
cardRepo.findByLuid("%020d".format(idmMaskedLong))?.getOrNull()?.let { return it }
|
||||
cardRepo.findByLuid("%020d".format(idmMaskedLong))?.let { return it }
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,7 +92,7 @@ class CardService(val cardRepo: CardRepository)
|
||||
|
||||
fun randExtID(lower: Long = 0, upper: Long = 1e9.toLong() - 1): Long {
|
||||
var eid = ThreadLocalRandom.current().nextLong(lower, upper)
|
||||
while (cardRepo.findByExtId(eid).isPresent) {
|
||||
while (cardRepo.findByExtId(eid) != null) {
|
||||
eid = ThreadLocalRandom.current().nextLong(lower, upper)
|
||||
}
|
||||
return eid
|
||||
|
||||
@ -16,12 +16,12 @@ fun Maimai2ServletController.initApis() {
|
||||
|
||||
"GetUserExtend" { mapOf(
|
||||
"userId" to uid,
|
||||
"userExtend" to (db.userExtend.findSingleByUser_Card_ExtId(uid)() ?: (404 - "User not found"))
|
||||
"userExtend" to (db.userExtend.findSingleByUser_Card_ExtId(uid) ?: (404 - "User not found"))
|
||||
) }
|
||||
|
||||
"GetUserData" { mapOf(
|
||||
"userId" to uid,
|
||||
"userData" to (db.userData.findByCardExtId(uid)() ?: (404 - "User not found")),
|
||||
"userData" to (db.userData.findByCardExtId(uid) ?: (404 - "User not found")),
|
||||
"banState" to 0
|
||||
) }
|
||||
|
||||
@ -56,7 +56,7 @@ fun Maimai2ServletController.initApis() {
|
||||
|
||||
"GetUserOption" { mapOf(
|
||||
"userId" to uid,
|
||||
"userOption" to (db.userOption.findSingleByUser_Card_ExtId(uid)() ?: (404 - "User not found"))
|
||||
"userOption" to (db.userOption.findSingleByUser_Card_ExtId(uid) ?: (404 - "User not found"))
|
||||
) }
|
||||
|
||||
"CreateToken" static { """{"Bearer":"meow"}""" }
|
||||
@ -75,7 +75,7 @@ fun Maimai2ServletController.initApis() {
|
||||
)
|
||||
} }
|
||||
|
||||
"CMGetUserPreview" { db.userData.findByCardExtId(uid)()?.let {
|
||||
"CMGetUserPreview" { db.userData.findByCardExtId(uid)?.let {
|
||||
mapOf(
|
||||
"userId" to uid,
|
||||
"userName" to it.userName,
|
||||
@ -87,8 +87,8 @@ fun Maimai2ServletController.initApis() {
|
||||
} ?: (404 - "User not found") }
|
||||
|
||||
"GetUserPreview" {
|
||||
val d = db.userData.findByCardExtId(uid)() ?: (404 - "User not found")
|
||||
val option = db.userOption.findSingleByUser_Card_ExtId(uid)()
|
||||
val d = db.userData.findByCardExtId(uid) ?: (404 - "User not found")
|
||||
val option = db.userOption.findSingleByUser_Card_ExtId(uid)
|
||||
|
||||
val res = mutableMapOf(
|
||||
"userId" to uid,
|
||||
@ -125,7 +125,7 @@ fun Maimai2ServletController.initApis() {
|
||||
}
|
||||
|
||||
"UserLogin" {
|
||||
val d = db.userData.findByCardExtId(uid)()
|
||||
val d = db.userData.findByCardExtId(uid)
|
||||
|
||||
val res = mutableMapOf(
|
||||
"returnCode" to 1, "loginCount" to 1,
|
||||
@ -204,7 +204,7 @@ fun Maimai2ServletController.initApis() {
|
||||
}
|
||||
|
||||
"GetUserIntimate".unpaged {
|
||||
val u = db.userData.findByCardExtId(uid)() ?: (404 - "User not found")
|
||||
val u = db.userData.findByCardExtId(uid) ?: (404 - "User not found")
|
||||
db.userIntimate.findByUser(u)
|
||||
}
|
||||
|
||||
@ -241,7 +241,7 @@ fun Maimai2ServletController.initApis() {
|
||||
// Request: {userId}
|
||||
// Response: {userId, userKaleidxScopeList}
|
||||
"GetUserKaleidxScope".unpaged {
|
||||
val u = db.userData.findByCardExtId(uid)() ?: (404 - "User not found")
|
||||
val u = db.userData.findByCardExtId(uid) ?: (404 - "User not found")
|
||||
val lst = db.userKaleidx.findByUser(u)
|
||||
.mapApply { isKeyFound = true }.toMutableList()
|
||||
|
||||
@ -349,7 +349,7 @@ fun Maimai2ServletController.initApis() {
|
||||
) }
|
||||
|
||||
"GetUserRecommendSelectMusic" {
|
||||
val user = db.userData.findByCard_ExtId(uid)() ?: (404 - "User not found")
|
||||
val user = db.userData.findByCard_ExtId(uid) ?: (404 - "User not found")
|
||||
mapOf(
|
||||
"userId" to uid,
|
||||
"userRecommendSelectionMusicIdList" to (net.recommendedMusic[user.id] ?: empty)
|
||||
|
||||
@ -7,7 +7,6 @@ import icu.samnyan.aqua.sega.general.dao.CardRepository
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2Repos
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2ItemKind
|
||||
import org.springframework.stereotype.Component
|
||||
import kotlin.jvm.optionals.getOrNull
|
||||
|
||||
@Component("Maimai2GetUserCharacterHandler")
|
||||
class GetUserCharacterHandler(
|
||||
@ -30,7 +29,7 @@ class GetUserCharacterHandler(
|
||||
val userId = (request["userId"] as Number).toLong()
|
||||
|
||||
// Aqua Net game unlock feature
|
||||
cardRepo.findByExtId(userId).getOrNull()?.aquaUser?.gameOptions?.let { opt ->
|
||||
cardRepo.findByExtId(userId)?.aquaUser?.gameOptions?.let { opt ->
|
||||
if (!opt.unlockChara or itemUnlock.isNullOrEmpty()) return@let
|
||||
|
||||
logger.info("Response: ${itemUnlock!!.size} Characters - All unlock")
|
||||
|
||||
@ -1,10 +1,8 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler
|
||||
|
||||
import ext.invoke
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2Repos
|
||||
import org.springframework.stereotype.Component
|
||||
import java.util.*
|
||||
|
||||
@Component("Maimai2GetUserFavoriteItemHandler")
|
||||
class GetUserFavoriteItemHandler(val repos: Mai2Repos) : BaseHandler {
|
||||
@ -15,8 +13,8 @@ class GetUserFavoriteItemHandler(val repos: Mai2Repos) : BaseHandler {
|
||||
val items = when (kind) {
|
||||
1 -> repos.userGeneralData.findByUser_Card_ExtIdAndPropertyKey(userId, "favorite_music")
|
||||
2 -> repos.userGeneralData.findByUser_Card_ExtIdAndPropertyKey(userId, "favorite_rival")
|
||||
else -> Optional.empty()
|
||||
}()?.let { fav ->
|
||||
else -> null
|
||||
}?.let { fav ->
|
||||
val v = fav.propertyValue
|
||||
if (v.isNotBlank()) v.split(",").filter { it.isNotEmpty() }.mapIndexed { i, record ->
|
||||
mapOf("id" to record.toInt(), "orderId" to i) }
|
||||
|
||||
@ -7,7 +7,6 @@ import icu.samnyan.aqua.sega.general.dao.CardRepository
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2Repos
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2ItemKind
|
||||
import org.springframework.stereotype.Component
|
||||
import kotlin.jvm.optionals.getOrNull
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
@ -48,7 +47,7 @@ class GetUserItemHandler(
|
||||
val kindType = Mai2ItemKind.ALL[kind]?.name
|
||||
|
||||
// Aqua Net game unlock feature
|
||||
cardRepo.findByExtId(userId).getOrNull()?.aquaUser?.gameOptions?.let { opt ->
|
||||
cardRepo.findByExtId(userId)?.aquaUser?.gameOptions?.let { opt ->
|
||||
val items = when {
|
||||
(kind in 5..8) && opt.unlockMusic -> musicUnlock.getValue(kind)
|
||||
(kind in 1..3 || kind == 11) && opt.unlockCollectables -> itemUnlock[kind]
|
||||
|
||||
@ -29,7 +29,7 @@ class GetUserPortraitHandler(
|
||||
|
||||
val uid = (request["userId"] as Number).toLong()
|
||||
val list = ArrayList<Mai2UserPortrait>()
|
||||
val profilePicture = cardRepo.findByExtId(uid)()?.aquaUser?.profilePicture?.ifBlank { null }
|
||||
val profilePicture = cardRepo.findByExtId(uid)?.aquaUser?.profilePicture?.ifBlank { null }
|
||||
?: return """{"length":0,"userPortraitList":[]}"""
|
||||
|
||||
try {
|
||||
|
||||
@ -23,25 +23,25 @@ class GetUserRatingHandler(
|
||||
|
||||
val ur = UserRating()
|
||||
|
||||
repos.userData.findByCardExtId(userId)()?.let {
|
||||
repos.userData.findByCardExtId(userId)?.let {
|
||||
ur.rating = it.playerRating
|
||||
}
|
||||
|
||||
// Old charts (standard) = 25
|
||||
ur.ratingList = repos.userGeneralData.findByUser_Card_ExtIdAndPropertyKey(userId, "recent_rating")()
|
||||
ur.ratingList = repos.userGeneralData.findByUser_Card_ExtIdAndPropertyKey(userId, "recent_rating")
|
||||
?.let { loadRateData(it.propertyValue) } ?: empty
|
||||
|
||||
// New charts (DX) = 15
|
||||
ur.newRatingList = repos.userGeneralData.findByUser_Card_ExtIdAndPropertyKey(userId, "recent_rating_new")()
|
||||
ur.newRatingList = repos.userGeneralData.findByUser_Card_ExtIdAndPropertyKey(userId, "recent_rating_new")
|
||||
?.let { loadRateData(it.propertyValue) } ?: empty
|
||||
|
||||
ur.nextRatingList = repos.userGeneralData.findByUser_Card_ExtIdAndPropertyKey(userId, "recent_rating_next")()
|
||||
ur.nextRatingList = repos.userGeneralData.findByUser_Card_ExtIdAndPropertyKey(userId, "recent_rating_next")
|
||||
?.let { loadRateData(it.propertyValue) } ?: empty
|
||||
|
||||
ur.nextNewRatingList = repos.userGeneralData.findByUser_Card_ExtIdAndPropertyKey(userId, "recent_rating_next_new")()
|
||||
ur.nextNewRatingList = repos.userGeneralData.findByUser_Card_ExtIdAndPropertyKey(userId, "recent_rating_next_new")
|
||||
?.let { loadRateData(it.propertyValue) } ?: empty
|
||||
|
||||
ur.udemae = repos.userUdemae.findSingleByUser_Card_ExtId(userId)() ?: Mai2UserUdemae()
|
||||
ur.udemae = repos.userUdemae.findSingleByUser_Card_ExtId(userId) ?: Mai2UserUdemae()
|
||||
|
||||
return mapOf(
|
||||
"userId" to userId,
|
||||
|
||||
@ -13,7 +13,6 @@ import icu.samnyan.aqua.sega.util.BasicMapper
|
||||
import icu.samnyan.aqua.spring.Metrics
|
||||
import org.springframework.scheduling.annotation.Scheduled
|
||||
import org.springframework.stereotype.Component
|
||||
import kotlin.jvm.optionals.getOrNull
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
@ -52,14 +51,14 @@ class UploadUserPlaylogHandler(
|
||||
uid,
|
||||
playlog.musicId,
|
||||
playlog.userPlayDate
|
||||
).size > 0
|
||||
).isNotEmpty()
|
||||
if (isDup) {
|
||||
log.info("Duplicate playlog detected")
|
||||
return """{"returnCode":1,"apiName":"com.sega.maimai2servlet.api.UploadUserPlaylogApi"}"""
|
||||
}
|
||||
|
||||
// Save if the user is registered
|
||||
val u = userDataRepository.findByCardExtId(uid).getOrNull()
|
||||
val u = userDataRepository.findByCardExtId(uid)
|
||||
if (u != null) playlogRepo.save(playlog.apply { user = u })
|
||||
|
||||
// If the user hasn't registered (first play), save the playlog to a backlog
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler
|
||||
|
||||
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
|
||||
@ -39,10 +39,10 @@ class UpsertUserAllHandler(
|
||||
// If user is guest, just return OK response.
|
||||
if ((userId and 281474976710657L) == 281474976710657L) return SUCCESS
|
||||
|
||||
val userData = repos.userData.findByCardExtId(userId)()
|
||||
val userData = repos.userData.findByCardExtId(userId)
|
||||
val u = repos.userData.saveAndFlush(req.userData[0].apply {
|
||||
id = userData?.id ?: 0
|
||||
card = userData?.card ?: cardService.getCardByExtId(userId).orElseThrow()
|
||||
card = userData?.card ?: cardService.getCardByExtId(userId) ?: (404 - "User not found")
|
||||
isNetMember = 1
|
||||
|
||||
// Validate username
|
||||
@ -76,30 +76,30 @@ class UpsertUserAllHandler(
|
||||
}.flatten().forEach { it.user = u }
|
||||
|
||||
req.userExtend?.getOrNull(0)?.let {
|
||||
repos.userExtend.save(it.apply { id = repos.userExtend.findSingleByUser(u)()?.id ?: 0 })
|
||||
repos.userExtend.save(it.apply { id = repos.userExtend.findSingleByUser(u)?.id ?: 0 })
|
||||
}
|
||||
|
||||
req.userOption?.getOrNull(0)?.let {
|
||||
repos.userOption.save(it.apply { id = repos.userOption.findSingleByUser(u)()?.id ?: 0 })
|
||||
repos.userOption.save(it.apply { id = repos.userOption.findSingleByUser(u)?.id ?: 0 })
|
||||
}
|
||||
|
||||
req.userCharacterList?.unique { it.characterId }?.let { news ->
|
||||
repos.userCharacter.saveAll(news.mapApply {
|
||||
id = repos.userCharacter.findByUserAndCharacterId(u, characterId)()?.id ?: 0 }) }
|
||||
id = repos.userCharacter.findByUserAndCharacterId(u, characterId)?.id ?: 0 }) }
|
||||
|
||||
req.userMapList?.unique { it.mapId }?.let { news ->
|
||||
repos.userMap.saveAll(news.mapApply {
|
||||
id = repos.userMap.findByUserAndMapId(u, mapId)()?.id ?: 0 }) }
|
||||
id = repos.userMap.findByUserAndMapId(u, mapId)?.id ?: 0 }) }
|
||||
|
||||
req.userLoginBonusList?.unique { it.bonusId }?.let { news ->
|
||||
repos.userLoginBonus.saveAll(news.mapApply {
|
||||
id = repos.userLoginBonus.findByUserAndBonusId(u, bonusId)()?.id ?: 0
|
||||
id = repos.userLoginBonus.findByUserAndBonusId(u, bonusId)?.id ?: 0
|
||||
isCurrent = false
|
||||
}) }
|
||||
|
||||
req.userRatingList?.getOrNull(0)?.let { r ->
|
||||
repos.userUdemae.saveAndFlush(r.udemae.apply {
|
||||
id = repos.userUdemae.findSingleByUser(u)()?.id ?: 0
|
||||
id = repos.userUdemae.findSingleByUser(u)?.id ?: 0
|
||||
user = u
|
||||
})
|
||||
|
||||
@ -111,23 +111,23 @@ class UpsertUserAllHandler(
|
||||
|
||||
req.userItemList?.unique { it.itemId to it.itemKind }?.let { news ->
|
||||
repos.userItem.saveAll(news.mapApply {
|
||||
id = repos.userItem.findByUserAndItemKindAndItemId(u, itemKind, itemId)()?.id ?: 0 }) }
|
||||
id = repos.userItem.findByUserAndItemKindAndItemId(u, itemKind, itemId)?.id ?: 0 }) }
|
||||
|
||||
req.userMusicDetailList?.unique { it.musicId to it.level }?.let { news ->
|
||||
repos.userMusicDetail.saveAll(news.mapApply {
|
||||
id = repos.userMusicDetail.findByUserAndMusicIdAndLevel(u, musicId, level)()?.id ?: 0 }) }
|
||||
id = repos.userMusicDetail.findByUserAndMusicIdAndLevel(u, musicId, level)?.id ?: 0 }) }
|
||||
|
||||
req.userCourseList?.unique { it.courseId }?.let { news ->
|
||||
repos.userCourse.saveAll(news.mapApply {
|
||||
id = repos.userCourse.findByUserAndCourseId(u, courseId)()?.id ?: 0 }) }
|
||||
id = repos.userCourse.findByUserAndCourseId(u, courseId)?.id ?: 0 }) }
|
||||
|
||||
req.userFriendSeasonRankingList?.unique { it.seasonId }?.let { news ->
|
||||
repos.userFriendSeasonRanking.saveAll(news.mapApply {
|
||||
id = repos.userFriendSeasonRanking.findByUserAndSeasonId(u, seasonId)()?.id ?: 0 }) }
|
||||
id = repos.userFriendSeasonRanking.findByUserAndSeasonId(u, seasonId)?.id ?: 0 }) }
|
||||
|
||||
req.userFavoriteList?.unique { it.itemKind }?.let { news ->
|
||||
repos.userFavorite.saveAll(news.mapApply {
|
||||
id = repos.userFavorite.findByUserAndItemKind(u, itemKind)()?.id ?: 0 }) }
|
||||
id = repos.userFavorite.findByUserAndItemKind(u, itemKind)?.id ?: 0 }) }
|
||||
|
||||
// Added on 1.50
|
||||
req.userKaleidxScopeList?.unique { it.gateId }?.let { lst ->
|
||||
@ -145,7 +145,7 @@ class UpsertUserAllHandler(
|
||||
repos.userAct.saveAll(news.flatMap { listOf(it.musicList, it.playList) }.flatten()
|
||||
.filter { it.kind != 0 && it.activityId != 0 }
|
||||
.mapApply {
|
||||
// id = repos.userAct.findByUserAndKindAndActivityId(u, kind, activityId)()?.id ?: 0
|
||||
// id = repos.userAct.findByUserAndKindAndActivityId(u, kind, activityId)?.id ?: 0
|
||||
user = u
|
||||
}.sortedBy { it.sortNumber })
|
||||
}
|
||||
@ -158,7 +158,7 @@ class UpsertUserAllHandler(
|
||||
// Or userFavoritemusicList will be empty
|
||||
req.userFavoritemusicList?.let { news ->
|
||||
val key = "favorite_music"
|
||||
val data = repos.userGeneralData.findByUserAndPropertyKey(u, key)()
|
||||
val data = repos.userGeneralData.findByUserAndPropertyKey(u, key)
|
||||
?: Mai2UserGeneralData().apply { user = u; propertyKey = key }
|
||||
repos.userGeneralData.save(data.apply {
|
||||
propertyValue = news.map { it.id }.joinToString(",")
|
||||
@ -170,7 +170,7 @@ class UpsertUserAllHandler(
|
||||
|
||||
fun saveRating(itemList: List<Mai2UserRate>, u: Mai2UserDetail, key: String) {
|
||||
val sb = itemList.joinToString(",") { "${it.musicId}:${it.level}:${it.romVersion}:${it.achievement}" }
|
||||
val data = repos.userGeneralData.findByUserAndPropertyKey(u, key)()
|
||||
val data = repos.userGeneralData.findByUserAndPropertyKey(u, key)
|
||||
?: Mai2UserGeneralData().apply { user = u; propertyKey = key }
|
||||
repos.userGeneralData.save(data.apply { propertyValue = sb })
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ class UpsertUserPrintHandler(
|
||||
|
||||
override fun handle(request: Map<String, Any>): Any? {
|
||||
val userId = parsing { request["userId"]!!.long }
|
||||
val userData = db.userData.findByCardExtId(userId)() ?: return null
|
||||
val userData = db.userData.findByCardExtId(userId) ?: return null
|
||||
|
||||
val userPrint = parsing { mapper.convert(request["userPrintDetail"]!!, Mai2UserPrintDetail::class.java) }
|
||||
val newCard = userPrint.userCard ?: return null
|
||||
@ -33,7 +33,7 @@ class UpsertUserPrintHandler(
|
||||
newCard.user = userData
|
||||
newCard.startDate = LocalDateTime.now().format(formatter)
|
||||
newCard.endDate = LocalDateTime.now().plusDays(expirationTime).format(formatter)
|
||||
newCard.id = db.userCard.findByUserAndCardId(newCard.user, newCard.cardId)()?.id ?: 0
|
||||
newCard.id = db.userCard.findByUserAndCardId(newCard.user, newCard.cardId)?.id ?: 0
|
||||
db.userCard.save(newCard)
|
||||
|
||||
userPrint.user = userData
|
||||
|
||||
@ -21,7 +21,7 @@ import java.util.*
|
||||
interface Mai2UserLinked<T>: JpaRepository<T, Long>, IUserRepo<Mai2UserDetail, T> {
|
||||
fun findByUser_Card_ExtId(userId: Long): List<T>
|
||||
fun findByUser_Card_ExtId(userId: Long, page: Pageable): Page<T>
|
||||
fun findSingleByUser_Card_ExtId(userId: Long): Optional<T>
|
||||
fun findSingleByUser_Card_ExtId(userId: Long): T?
|
||||
@Transactional
|
||||
fun deleteByUser(user: Mai2UserDetail)
|
||||
}
|
||||
@ -31,21 +31,21 @@ interface Mai2MapEncountNpcRepo : Mai2UserLinked<Mai2MapEncountNpc>
|
||||
interface Mai2UserActRepo : Mai2UserLinked<Mai2UserAct>
|
||||
|
||||
interface Mai2UserCardRepo : Mai2UserLinked<Mai2UserCard> {
|
||||
fun findByUserAndCardId(user: Mai2UserDetail, cardId: Int): Optional<Mai2UserCard>
|
||||
fun findByUserAndCardId(user: Mai2UserDetail, cardId: Int): Mai2UserCard?
|
||||
}
|
||||
|
||||
interface Mai2UserCharacterRepo : Mai2UserLinked<Mai2UserCharacter> {
|
||||
fun findByUserAndCharacterId(user: Mai2UserDetail, characterId: Int): Optional<Mai2UserCharacter>
|
||||
fun findByUserAndCharacterId(user: Mai2UserDetail, characterId: Int): Mai2UserCharacter?
|
||||
}
|
||||
|
||||
interface Mai2UserChargeRepo : Mai2UserLinked<Mai2UserCharge>
|
||||
|
||||
interface Mai2UserCourseRepo : Mai2UserLinked<Mai2UserCourse> {
|
||||
fun findByUserAndCourseId(user: Mai2UserDetail, courseId: Int): Optional<Mai2UserCourse>
|
||||
fun findByUserAndCourseId(user: Mai2UserDetail, courseId: Int): Mai2UserCourse?
|
||||
}
|
||||
|
||||
interface Mai2UserDataRepo : GenericUserDataRepo<Mai2UserDetail> {
|
||||
fun findByCardExtId(userId: Long): Optional<Mai2UserDetail>
|
||||
fun findByCardExtId(userId: Long): Mai2UserDetail?
|
||||
|
||||
@Modifying
|
||||
@Transactional
|
||||
@ -55,40 +55,40 @@ interface Mai2UserDataRepo : GenericUserDataRepo<Mai2UserDetail> {
|
||||
interface Mai2UserExtendRepo : Mai2UserLinked<Mai2UserExtend>
|
||||
|
||||
interface Mai2UserFavoriteRepo : Mai2UserLinked<Mai2UserFavorite> {
|
||||
fun findByUserAndItemKind(user: Mai2UserDetail, kind: Int): Optional<Mai2UserFavorite>
|
||||
fun findByUserAndItemKind(user: Mai2UserDetail, kind: Int): Mai2UserFavorite?
|
||||
|
||||
fun findByUser_Card_ExtIdAndItemKind(userId: Long, kind: Int): Optional<Mai2UserFavorite>
|
||||
fun findByUser_Card_ExtIdAndItemKind(userId: Long, kind: Int): Mai2UserFavorite?
|
||||
}
|
||||
|
||||
interface Mai2UserFriendSeasonRankingRepo : Mai2UserLinked<Mai2UserFriendSeasonRanking> {
|
||||
fun findByUserAndSeasonId(user: Mai2UserDetail, seasonId: Int): Optional<Mai2UserFriendSeasonRanking>
|
||||
fun findByUserAndSeasonId(user: Mai2UserDetail, seasonId: Int): Mai2UserFriendSeasonRanking?
|
||||
}
|
||||
|
||||
interface Mai2UserGeneralDataRepo : Mai2UserLinked<Mai2UserGeneralData> {
|
||||
fun findByUserAndPropertyKey(user: Mai2UserDetail, key: String): Optional<Mai2UserGeneralData>
|
||||
fun findByUserAndPropertyKey(user: Mai2UserDetail, key: String): Mai2UserGeneralData?
|
||||
|
||||
fun findByUser_Card_ExtIdAndPropertyKey(userId: Long, key: String): Optional<Mai2UserGeneralData>
|
||||
fun findByUser_Card_ExtIdAndPropertyKey(userId: Long, key: String): Mai2UserGeneralData?
|
||||
}
|
||||
|
||||
interface Mai2UserItemRepo : Mai2UserLinked<Mai2UserItem> {
|
||||
fun findByUserCardExtIdAndItemKind(userId: Long, kind: Int): List<Mai2UserItem>
|
||||
fun findByUserAndItemKindAndItemId(user: Mai2UserDetail, itemKind: Int, itemId: Int): Optional<Mai2UserItem>
|
||||
fun findByUserAndItemKindAndItemId(user: Mai2UserDetail, itemKind: Int, itemId: Int): Mai2UserItem?
|
||||
|
||||
fun findByUser_Card_ExtIdAndItemKind(userId: Long, kind: Int, page: Pageable): Page<Mai2UserItem>
|
||||
}
|
||||
|
||||
interface Mai2UserLoginBonusRepo : Mai2UserLinked<Mai2UserLoginBonus> {
|
||||
fun findByUserAndBonusId(user: Mai2UserDetail, bonusId: Int): Optional<Mai2UserLoginBonus>
|
||||
fun findByUserAndBonusId(user: Mai2UserDetail, bonusId: Int): Mai2UserLoginBonus?
|
||||
}
|
||||
|
||||
interface Mai2UserMapRepo : Mai2UserLinked<Mai2UserMap> {
|
||||
fun findByUserAndMapId(user: Mai2UserDetail, mapId: Int): Optional<Mai2UserMap>
|
||||
fun findByUserAndMapId(user: Mai2UserDetail, mapId: Int): Mai2UserMap?
|
||||
}
|
||||
|
||||
interface Mai2UserMusicDetailRepo : Mai2UserLinked<Mai2UserMusicDetail>, GenericUserMusicRepo<Mai2UserMusicDetail> {
|
||||
fun findByUser_Card_ExtIdAndMusicId(userId: Long, id: Int): List<Mai2UserMusicDetail>
|
||||
|
||||
fun findByUserAndMusicIdAndLevel(user: Mai2UserDetail, musicId: Int, level: Int): Optional<Mai2UserMusicDetail>
|
||||
fun findByUserAndMusicIdAndLevel(user: Mai2UserDetail, musicId: Int, level: Int): Mai2UserMusicDetail?
|
||||
|
||||
fun findByUserId(userId: Long): List<Mai2UserMusicDetail>
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ import java.time.LocalDateTime
|
||||
|
||||
fun OngekiController.cmApiInit() {
|
||||
"CMGetUserData" {
|
||||
val user = db.data.findByCard_ExtId(uid)() ?: (400 - "User not found")
|
||||
val user = db.data.findByCard_ExtId(uid) ?: (400 - "User not found")
|
||||
mapOf("userId" to uid, "userData" to user)
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ fun OngekiController.cmApiInit() {
|
||||
|
||||
// Check if user have infinite kaika
|
||||
if (kind == OgkItemType.KaikaItem.ordinal) {
|
||||
val u = db.data.findByCard_ExtId(uid)()
|
||||
val u = db.data.findByCard_ExtId(uid)
|
||||
u?.card?.aquaUser?.gameOptions?.let {
|
||||
if (it.ongekiInfiniteKaika) {
|
||||
dat = listOf(UserItem().apply {
|
||||
@ -67,7 +67,7 @@ fun OngekiController.cmApiInit() {
|
||||
val (gachaId, tmpTimes) = parsing { data["gachaId"]!!.long to data["times"]!!.int }
|
||||
var times = tmpTimes
|
||||
|
||||
val user = db.data.findByCard_ExtId(uid)() ?: (400 - "User not found")
|
||||
val user = db.data.findByCard_ExtId(uid) ?: (400 - "User not found")
|
||||
val foundGacha = gdb.gacha.findById(gachaId)() ?: (404 - "Gacha not found")
|
||||
|
||||
val foundUserGacha = db.gacha.findByUserAndGachaId(user, gachaId)
|
||||
@ -111,10 +111,10 @@ fun OngekiController.cmApiInit() {
|
||||
val earnedSelectPoints = parsing { data["selectPoint"]!!.int }
|
||||
|
||||
// User data
|
||||
val oldUser = db.data.findByCard_ExtId(uid)()
|
||||
val oldUser = db.data.findByCard_ExtId(uid)
|
||||
val u: UserData = all.userData?.get(0)?.apply {
|
||||
id = oldUser?.id ?: 0
|
||||
card = oldUser?.card ?: us.cardRepo.findByExtId(uid)() ?: (404 - "Card not found")
|
||||
card = oldUser?.card ?: us.cardRepo.findByExtId(uid) ?: (404 - "Card not found")
|
||||
|
||||
// Set eventWatchedDate with lastPlayDate, because client doesn't update it
|
||||
cmEventWatchedDate = oldUser?.lastPlayDate ?: ""
|
||||
@ -171,21 +171,21 @@ fun OngekiController.cmApiInit() {
|
||||
// UserCharacterList
|
||||
userCharacterList?.let { list ->
|
||||
db.character.saveAll(list.distinctBy { it.characterId }.mapApply {
|
||||
id = db.character.findByUserAndCharacterId(u, characterId)()?.id ?: 0
|
||||
id = db.character.findByUserAndCharacterId(u, characterId)?.id ?: 0
|
||||
})
|
||||
}
|
||||
|
||||
// UserCardList
|
||||
userCardList?.let { list ->
|
||||
db.card.saveAll(list.distinctBy { it.cardId }.mapApply {
|
||||
id = db.card.findByUserAndCardId(u, cardId)()?.id ?: 0
|
||||
id = db.card.findByUserAndCardId(u, cardId)?.id ?: 0
|
||||
})
|
||||
}
|
||||
|
||||
// UserItemList
|
||||
userItemList?.let { list ->
|
||||
db.item.saveAll(list.distinctBy { it.itemKind to it.itemId }.mapApply {
|
||||
id = db.item.findByUserAndItemKindAndItemId(u, itemKind, itemId)()?.id ?: 0
|
||||
id = db.item.findByUserAndItemKindAndItemId(u, itemKind, itemId)?.id ?: 0
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -197,10 +197,10 @@ fun OngekiController.cmApiInit() {
|
||||
val all: OngekiCMUpsertAll = mapper.convert(data["cmUpsertUserAll"]!!)
|
||||
|
||||
// User data
|
||||
val oldUser = db.data.findByCard_ExtId(uid)()
|
||||
val oldUser = db.data.findByCard_ExtId(uid)
|
||||
val u: UserData = all.userData?.get(0)?.apply {
|
||||
id = oldUser?.id ?: 0
|
||||
card = oldUser?.card ?: us.cardRepo.findByExtId(uid)() ?: (404 - "Card not found")
|
||||
card = oldUser?.card ?: us.cardRepo.findByExtId(uid) ?: (404 - "Card not found")
|
||||
|
||||
// Set eventWatchedDate with lastPlayDate, because client doesn't update it
|
||||
cmEventWatchedDate = oldUser?.lastPlayDate ?: ""
|
||||
@ -216,7 +216,7 @@ fun OngekiController.cmApiInit() {
|
||||
// UserActivityList
|
||||
userActivityList?.let { list ->
|
||||
db.activity.saveAll(list.distinctBy { it.activityId to it.kind }.mapApply {
|
||||
id = db.activity.findByUserAndKindAndActivityId(u, kind, activityId)()?.id ?: 0
|
||||
id = db.activity.findByUserAndKindAndActivityId(u, kind, activityId)?.id ?: 0
|
||||
})
|
||||
}
|
||||
|
||||
@ -224,21 +224,21 @@ fun OngekiController.cmApiInit() {
|
||||
// UserCharacterList
|
||||
userCharacterList?.let { list ->
|
||||
db.character.saveAll(list.distinctBy { it.characterId }.mapApply {
|
||||
id = db.character.findByUserAndCharacterId(u, characterId)()?.id ?: 0
|
||||
id = db.character.findByUserAndCharacterId(u, characterId)?.id ?: 0
|
||||
})
|
||||
}
|
||||
|
||||
// UserCardList
|
||||
userCardList?.let { list ->
|
||||
db.card.saveAll(list.distinctBy { it.cardId }.mapApply {
|
||||
id = db.card.findByUserAndCardId(u, cardId)()?.id ?: 0
|
||||
id = db.card.findByUserAndCardId(u, cardId)?.id ?: 0
|
||||
})
|
||||
}
|
||||
|
||||
// UserItemList
|
||||
userItemList?.let { list ->
|
||||
db.item.saveAll(list.distinctBy { it.itemKind to it.itemId }.mapApply {
|
||||
id = db.item.findByUserAndItemKindAndItemId(u, itemKind, itemId)()?.id ?: 0
|
||||
id = db.item.findByUserAndItemKindAndItemId(u, itemKind, itemId)?.id ?: 0
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -251,10 +251,10 @@ fun OngekiController.cmApiInit() {
|
||||
val selectLog:List<OngekiCMSelectGachaLog> = mapper.convert(data["selectGachaLogList"]!!)
|
||||
|
||||
// User data
|
||||
val oldUser = db.data.findByCard_ExtId(uid)()
|
||||
val oldUser = db.data.findByCard_ExtId(uid)
|
||||
val u: UserData = all.userData?.get(0)?.apply {
|
||||
id = oldUser?.id ?: 0
|
||||
card = oldUser?.card ?: us.cardRepo.findByExtId(uid)() ?: (404 - "Card not found")
|
||||
card = oldUser?.card ?: us.cardRepo.findByExtId(uid) ?: (404 - "Card not found")
|
||||
|
||||
// Set eventWatchedDate with lastPlayDate, because client doesn't update it
|
||||
cmEventWatchedDate = oldUser?.lastPlayDate ?: ""
|
||||
@ -291,7 +291,7 @@ fun OngekiController.cmApiInit() {
|
||||
// UserCharacterList
|
||||
userCharacterList?.let { list ->
|
||||
db.character.saveAll(list.distinctBy { it.characterId }.mapApply {
|
||||
id = db.character.findByUserAndCharacterId(u, characterId)()?.id ?: 0
|
||||
id = db.character.findByUserAndCharacterId(u, characterId)?.id ?: 0
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -300,7 +300,7 @@ fun OngekiController.cmApiInit() {
|
||||
// UserCardList
|
||||
userCardList?.let { list ->
|
||||
db.card.saveAll(list.distinctBy { it.cardId }.mapApply {
|
||||
id = db.card.findByUserAndCardId(u, cardId)()?.id ?: 0
|
||||
id = db.card.findByUserAndCardId(u, cardId)?.id ?: 0
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ import java.util.*
|
||||
@NoRepositoryBean
|
||||
interface OngekiUserLinked<T> : IUserRepo<UserData, T> {
|
||||
fun findByUser_Card_ExtId(extId: Long): List<T>
|
||||
fun findSingleByUser_Card_ExtId(extId: Long): Optional<T>
|
||||
fun findSingleByUser_Card_ExtId(extId: Long): T?
|
||||
fun findByUser_Card_ExtId(extId: Long, pageable: Pageable): Page<T>
|
||||
}
|
||||
|
||||
@ -27,28 +27,28 @@ interface OgkUserDataRepo : GenericUserDataRepo<UserData> {
|
||||
}
|
||||
|
||||
interface OgkUserActivityRepo : OngekiUserLinked<UserActivity> {
|
||||
fun findByUserAndKindAndActivityId(userData: UserData, kind: Int, activityId: Int): Optional<UserActivity>
|
||||
fun findByUserAndKindAndActivityId(userData: UserData, kind: Int, activityId: Int): UserActivity?
|
||||
fun findByUser_Card_ExtIdAndKindOrderBySortNumberDesc(userId: Long, kind: Int): List<UserActivity>
|
||||
}
|
||||
|
||||
interface OgkUserBossRepo : OngekiUserLinked<UserBoss> {
|
||||
fun findByUserAndMusicId(user: UserData, musicId: Int): Optional<UserBoss>
|
||||
fun findByUserAndMusicId(user: UserData, musicId: Int): UserBoss?
|
||||
}
|
||||
|
||||
interface OgkUserCardRepo : OngekiUserLinked<UserCard> {
|
||||
fun findByUserAndCardId(userData: UserData, cardId: Int): Optional<UserCard>
|
||||
fun findByUserAndCardId(userData: UserData, cardId: Int): UserCard?
|
||||
}
|
||||
|
||||
interface OgkUserChapterRepo : OngekiUserLinked<UserChapter> {
|
||||
fun findByUserAndChapterId(userData: UserData, chapterId: Int): Optional<UserChapter>
|
||||
fun findByUserAndChapterId(userData: UserData, chapterId: Int): UserChapter?
|
||||
}
|
||||
|
||||
interface OgkUserCharacterRepo : OngekiUserLinked<UserCharacter> {
|
||||
fun findByUserAndCharacterId(userData: UserData, characterId: Int): Optional<UserCharacter>
|
||||
fun findByUserAndCharacterId(userData: UserData, characterId: Int): UserCharacter?
|
||||
}
|
||||
|
||||
interface OgkUserDeckRepo : OngekiUserLinked<UserDeck> {
|
||||
fun findByUserAndDeckId(userData: UserData, deckId: Int): Optional<UserDeck>
|
||||
fun findByUserAndDeckId(userData: UserData, deckId: Int): UserDeck?
|
||||
}
|
||||
|
||||
interface OgkUserEventMusicRepo : OngekiUserLinked<UserEventMusic> {
|
||||
@ -57,11 +57,11 @@ interface OgkUserEventMusicRepo : OngekiUserLinked<UserEventMusic> {
|
||||
eventId: Int,
|
||||
type: Int,
|
||||
musicId: Int
|
||||
): Optional<UserEventMusic>
|
||||
): UserEventMusic?
|
||||
}
|
||||
|
||||
interface OgkUserEventPointRepo : OngekiUserLinked<UserEventPoint> {
|
||||
fun findByUserAndEventId(userData: UserData, eventId: Int): Optional<UserEventPoint>
|
||||
fun findByUserAndEventId(userData: UserData, eventId: Int): UserEventPoint?
|
||||
|
||||
//@Query(value = "SELECT rank from (SELECT user_id , DENSE_RANK() OVER (ORDER BY point DESC) as rank from ongeki_user_event_point where event_id = :eventId) where user_id == :userId limit 1", nativeQuery = true)
|
||||
@Query("SELECT COUNT(u)+1 FROM OngekiUserEventPoint u WHERE u.eventId = :eventId AND u.point > (SELECT u2.point FROM OngekiUserEventPoint u2 WHERE u2.user.id = :userId AND u2.eventId = :eventId)")
|
||||
@ -69,40 +69,40 @@ interface OgkUserEventPointRepo : OngekiUserLinked<UserEventPoint> {
|
||||
}
|
||||
|
||||
interface OgkUserGeneralDataRepo : OngekiUserLinked<UserGeneralData> {
|
||||
fun findByUserAndPropertyKey(user: UserData, key: String): Optional<UserGeneralData>
|
||||
fun findByUserAndPropertyKey(user: UserData, key: String): UserGeneralData?
|
||||
|
||||
fun findByUser_Card_ExtIdAndPropertyKey(userId: Long, key: String): Optional<UserGeneralData>
|
||||
fun findByUser_Card_ExtIdAndPropertyKey(userId: Long, key: String): UserGeneralData?
|
||||
}
|
||||
|
||||
interface OgkUserItemRepo : OngekiUserLinked<UserItem> {
|
||||
fun findByUserAndItemKindAndItemId(userData: UserData, itemKind: Int, itemId: Int): Optional<UserItem>
|
||||
fun findByUserAndItemKindAndItemId(userData: UserData, itemKind: Int, itemId: Int): UserItem?
|
||||
|
||||
fun findByUser_Card_ExtIdAndItemKind(userId: Long, kind: Int, page: Pageable): Page<UserItem>
|
||||
fun findByUser_Card_ExtIdAndItemKind(userId: Long, kind: Int): List<UserItem>
|
||||
}
|
||||
|
||||
interface OgkUserKopRepo : OngekiUserLinked<UserKop> {
|
||||
fun findByUserAndKopIdAndAreaId(userData: UserData, kopId: Int, areaId: Int): Optional<UserKop>
|
||||
fun findByUserAndKopIdAndAreaId(userData: UserData, kopId: Int, areaId: Int): UserKop?
|
||||
}
|
||||
|
||||
interface OgkUserLoginBonusRepo : OngekiUserLinked<UserLoginBonus> {
|
||||
fun findByUserAndBonusId(userData: UserData, bonusId: Int): Optional<UserLoginBonus>
|
||||
fun findByUserAndBonusId(userData: UserData, bonusId: Int): UserLoginBonus?
|
||||
}
|
||||
|
||||
interface OgkUserMemoryChapterRepo : OngekiUserLinked<UserMemoryChapter> {
|
||||
fun findByUserAndChapterId(userData: UserData, chapterId: Int): Optional<UserMemoryChapter>
|
||||
fun findByUserAndChapterId(userData: UserData, chapterId: Int): UserMemoryChapter?
|
||||
}
|
||||
|
||||
interface OgkUserMissionPointRepo : OngekiUserLinked<UserMissionPoint> {
|
||||
fun findByUserAndEventId(userData: UserData, eventId: Int): Optional<UserMissionPoint>
|
||||
fun findByUserAndEventId(userData: UserData, eventId: Int): UserMissionPoint?
|
||||
}
|
||||
|
||||
interface OgkUserMusicDetailRepo : OngekiUserLinked<UserMusicDetail>, GenericUserMusicRepo<UserMusicDetail> {
|
||||
fun findByUserAndMusicIdAndLevel(userData: UserData, musicId: Int, level: Int): Optional<UserMusicDetail>
|
||||
fun findByUserAndMusicIdAndLevel(userData: UserData, musicId: Int, level: Int): UserMusicDetail?
|
||||
}
|
||||
|
||||
interface OgkUserMusicItemRepo : OngekiUserLinked<UserMusicItem> {
|
||||
fun findByUserAndMusicId(userData: UserData, musicId: Int): Optional<UserMusicItem>
|
||||
fun findByUserAndMusicId(userData: UserData, musicId: Int): UserMusicItem?
|
||||
}
|
||||
|
||||
interface OgkUserOptionRepo : OngekiUserLinked<UserOption>
|
||||
@ -112,19 +112,19 @@ interface OgkUserPlaylogRepo : OngekiUserLinked<UserPlaylog>, GenericPlaylogRepo
|
||||
interface OgkUserRivalDataRepo : OngekiUserLinked<UserRival>
|
||||
|
||||
interface OgkUserScenarioRepo : OngekiUserLinked<UserScenario> {
|
||||
fun findByUserAndScenarioId(user: UserData, scenarioId: Int): Optional<UserScenario>
|
||||
fun findByUserAndScenarioId(user: UserData, scenarioId: Int): UserScenario?
|
||||
}
|
||||
|
||||
interface OgkUserStoryRepo : OngekiUserLinked<UserStory> {
|
||||
fun findByUserAndStoryId(userData: UserData, storyId: Int): Optional<UserStory>
|
||||
fun findByUserAndStoryId(userData: UserData, storyId: Int): UserStory?
|
||||
}
|
||||
|
||||
interface OgkUserTechCountRepo : OngekiUserLinked<UserTechCount> {
|
||||
fun findByUserAndLevelId(user: UserData, levelId: Int): Optional<UserTechCount>
|
||||
fun findByUserAndLevelId(user: UserData, levelId: Int): UserTechCount?
|
||||
}
|
||||
|
||||
interface OgkUserTechEventRepo : OngekiUserLinked<UserTechEvent> {
|
||||
fun findByUserAndEventId(userData: UserData, eventId: Int): Optional<UserTechEvent>
|
||||
fun findByUserAndEventId(userData: UserData, eventId: Int): UserTechEvent?
|
||||
}
|
||||
|
||||
interface OgkUserTradeItemRepo : OngekiUserLinked<UserTradeItem> {
|
||||
@ -138,11 +138,11 @@ interface OgkUserTradeItemRepo : OngekiUserLinked<UserTradeItem> {
|
||||
userData: UserData,
|
||||
chapterId: Int,
|
||||
tradeItemId: Int
|
||||
): Optional<UserTradeItem>
|
||||
): UserTradeItem?
|
||||
}
|
||||
|
||||
interface OgkUserTrainingRoomRepo : OngekiUserLinked<UserTrainingRoom> {
|
||||
fun findByUserAndRoomId(user: UserData, roomId: Int): Optional<UserTrainingRoom>
|
||||
fun findByUserAndRoomId(user: UserData, roomId: Int): UserTrainingRoom?
|
||||
}
|
||||
|
||||
interface OgkUserRegionsRepo: OngekiUserLinked<UserRegions> {
|
||||
|
||||
@ -13,7 +13,7 @@ import icu.samnyan.aqua.sega.ongeki.model.UserRegions
|
||||
fun OngekiController.initUpsertAll() {
|
||||
fun saveGeneralData(items: List<Any>, u: UserData, key: String) {
|
||||
db.generalData.save(UserGeneralData().apply {
|
||||
id = db.generalData.findByUserAndPropertyKey(u, key)()?.id ?: 0
|
||||
id = db.generalData.findByUserAndPropertyKey(u, key)?.id ?: 0
|
||||
user = u
|
||||
propertyKey = key
|
||||
propertyValue = items.joinToString(",")
|
||||
@ -24,10 +24,10 @@ fun OngekiController.initUpsertAll() {
|
||||
val all: OngekiUpsertUserAll = mapper.convert(data["upsertUserAll"]!!)
|
||||
|
||||
// User data
|
||||
val oldUser = db.data.findByCard_ExtId(uid)()
|
||||
val oldUser = db.data.findByCard_ExtId(uid)
|
||||
val u: UserData = all.userData?.get(0)?.apply {
|
||||
id = oldUser?.id ?: 0
|
||||
card = oldUser?.card ?: us.cardRepo.findByExtId(uid)() ?: (404 - "Card not found")
|
||||
card = oldUser?.card ?: us.cardRepo.findByExtId(uid) ?: (404 - "Card not found")
|
||||
|
||||
// Set eventWatchedDate with lastPlayDate, because client doesn't update it
|
||||
eventWatchedDate = oldUser?.lastPlayDate ?: ""
|
||||
@ -62,12 +62,12 @@ fun OngekiController.initUpsertAll() {
|
||||
// UserOption
|
||||
userOption?.get(0)?.let {
|
||||
db.option.save(it.apply {
|
||||
id = db.option.findSingleByUser(u)()?.id ?: 0 }) }
|
||||
id = db.option.findSingleByUser(u)?.id ?: 0 }) }
|
||||
|
||||
// UserEventMap
|
||||
userEventMap?.let {
|
||||
db.eventMap.save(it.apply {
|
||||
id = db.eventMap.findSingleByUser(u)()?.id ?: 0 }) }
|
||||
id = db.eventMap.findSingleByUser(u)?.id ?: 0 }) }
|
||||
|
||||
// UserPlaylogList
|
||||
userPlaylogList?.let { db.playlog.saveAll(it) }
|
||||
@ -97,109 +97,109 @@ fun OngekiController.initUpsertAll() {
|
||||
// UserActivityList
|
||||
userActivityList?.let { list ->
|
||||
db.activity.saveAll(list.distinctBy { it.activityId to it.kind }.mapApply {
|
||||
id = db.activity.findByUserAndKindAndActivityId(u, kind, activityId)()?.id ?: 0 }) }
|
||||
id = db.activity.findByUserAndKindAndActivityId(u, kind, activityId)?.id ?: 0 }) }
|
||||
|
||||
// UserMusicDetailList
|
||||
userMusicDetailList?.let { list ->
|
||||
db.musicDetail.saveAll(list.distinctBy { it.musicId to it.level }.mapApply {
|
||||
id = db.musicDetail.findByUserAndMusicIdAndLevel(u, musicId, level)()?.id ?: 0 }) }
|
||||
id = db.musicDetail.findByUserAndMusicIdAndLevel(u, musicId, level)?.id ?: 0 }) }
|
||||
|
||||
// UserCharacterList
|
||||
userCharacterList?.let { list ->
|
||||
db.character.saveAll(list.distinctBy { it.characterId }.mapApply {
|
||||
id = db.character.findByUserAndCharacterId(u, characterId)()?.id ?: 0 }) }
|
||||
id = db.character.findByUserAndCharacterId(u, characterId)?.id ?: 0 }) }
|
||||
|
||||
// UserCardList
|
||||
userCardList?.let { list ->
|
||||
db.card.saveAll(list.distinctBy { it.cardId }.mapApply {
|
||||
id = db.card.findByUserAndCardId(u, cardId)()?.id ?: 0 }) }
|
||||
id = db.card.findByUserAndCardId(u, cardId)?.id ?: 0 }) }
|
||||
|
||||
// UserDeckList
|
||||
userDeckList?.let { list ->
|
||||
db.deck.saveAll(list.distinctBy { it.deckId }.mapApply {
|
||||
id = db.deck.findByUserAndDeckId(u, deckId)()?.id ?: 0 }) }
|
||||
id = db.deck.findByUserAndDeckId(u, deckId)?.id ?: 0 }) }
|
||||
|
||||
// UserTrainingRoomList
|
||||
userTrainingRoomList?.let { list ->
|
||||
db.trainingRoom.saveAll(list.distinctBy { it.roomId }.mapApply {
|
||||
id = db.trainingRoom.findByUserAndRoomId(u, roomId)()?.id ?: 0 }) }
|
||||
id = db.trainingRoom.findByUserAndRoomId(u, roomId)?.id ?: 0 }) }
|
||||
|
||||
// UserStoryList
|
||||
userStoryList?.let { list ->
|
||||
db.story.saveAll(list.distinctBy { it.storyId }.mapApply {
|
||||
id = db.story.findByUserAndStoryId(u, storyId)()?.id ?: 0 }) }
|
||||
id = db.story.findByUserAndStoryId(u, storyId)?.id ?: 0 }) }
|
||||
|
||||
// UserChapterList
|
||||
userChapterList?.let { list ->
|
||||
db.chapter.saveAll(list.distinctBy { it.chapterId }.mapApply {
|
||||
id = db.chapter.findByUserAndChapterId(u, chapterId)()?.id ?: 0 }) }
|
||||
id = db.chapter.findByUserAndChapterId(u, chapterId)?.id ?: 0 }) }
|
||||
|
||||
// UserMemoryChapterList
|
||||
userMemoryChapterList?.let { list ->
|
||||
db.memoryChapter.saveAll(list.distinctBy { it.chapterId }.mapApply {
|
||||
id = db.memoryChapter.findByUserAndChapterId(u, chapterId)()?.id ?: 0 }) }
|
||||
id = db.memoryChapter.findByUserAndChapterId(u, chapterId)?.id ?: 0 }) }
|
||||
|
||||
// UserItemList
|
||||
userItemList?.let { list ->
|
||||
db.item.saveAll(list.distinctBy { it.itemKind to it.itemId }.mapApply {
|
||||
id = db.item.findByUserAndItemKindAndItemId(u, itemKind, itemId)()?.id ?: 0 }) }
|
||||
id = db.item.findByUserAndItemKindAndItemId(u, itemKind, itemId)?.id ?: 0 }) }
|
||||
|
||||
// UserMusicItemList
|
||||
userMusicItemList?.let { list ->
|
||||
db.musicItem.saveAll(list.distinctBy { it.musicId }.mapApply {
|
||||
id = db.musicItem.findByUserAndMusicId(u, musicId)()?.id ?: 0 }) }
|
||||
id = db.musicItem.findByUserAndMusicId(u, musicId)?.id ?: 0 }) }
|
||||
|
||||
// UserLoginBonusList
|
||||
userLoginBonusList?.let { list ->
|
||||
db.loginBonus.saveAll(list.distinctBy { it.bonusId }.mapApply {
|
||||
id = db.loginBonus.findByUserAndBonusId(u, bonusId)()?.id ?: 0 }) }
|
||||
id = db.loginBonus.findByUserAndBonusId(u, bonusId)?.id ?: 0 }) }
|
||||
|
||||
// UserEventPointList
|
||||
userEventPointList?.let { list ->
|
||||
db.eventPoint.saveAll(list.distinctBy { it.eventId }.mapApply {
|
||||
id = db.eventPoint.findByUserAndEventId(u, eventId)()?.id ?: 0 }) }
|
||||
id = db.eventPoint.findByUserAndEventId(u, eventId)?.id ?: 0 }) }
|
||||
|
||||
// UserMissionPointList
|
||||
userMissionPointList?.let { list ->
|
||||
db.missionPoint.saveAll(list.distinctBy { it.eventId }.mapApply {
|
||||
id = db.missionPoint.findByUserAndEventId(u, eventId)()?.id ?: 0 }) }
|
||||
id = db.missionPoint.findByUserAndEventId(u, eventId)?.id ?: 0 }) }
|
||||
|
||||
// UserRatinglogList (For the highest rating of each version)
|
||||
|
||||
// UserBossList
|
||||
userBossList?.let { list ->
|
||||
db.boss.saveAll(list.distinctBy { it.musicId }.mapApply {
|
||||
id = db.boss.findByUserAndMusicId(u, musicId)()?.id ?: 0 }) }
|
||||
id = db.boss.findByUserAndMusicId(u, musicId)?.id ?: 0 }) }
|
||||
|
||||
// UserTechCountList
|
||||
userTechCountList?.let { list ->
|
||||
db.techCount.saveAll(list.distinctBy { it.levelId }.mapApply {
|
||||
id = db.techCount.findByUserAndLevelId(u, levelId)()?.id ?: 0 }) }
|
||||
id = db.techCount.findByUserAndLevelId(u, levelId)?.id ?: 0 }) }
|
||||
|
||||
// UserScenarioList
|
||||
userScenarioList?.let { list ->
|
||||
db.scenario.saveAll(list.distinctBy { it.scenarioId }.mapApply {
|
||||
id = db.scenario.findByUserAndScenarioId(u, scenarioId)()?.id ?: 0 }) }
|
||||
id = db.scenario.findByUserAndScenarioId(u, scenarioId)?.id ?: 0 }) }
|
||||
|
||||
// UserTradeItemList
|
||||
userTradeItemList?.let { list ->
|
||||
db.tradeItem.saveAll(list.distinctBy { it.chapterId to it.tradeItemId }.mapApply {
|
||||
id = db.tradeItem.findByUserAndChapterIdAndTradeItemId(u, chapterId, tradeItemId)()?.id ?: 0 }) }
|
||||
id = db.tradeItem.findByUserAndChapterIdAndTradeItemId(u, chapterId, tradeItemId)?.id ?: 0 }) }
|
||||
|
||||
// UserEventMusicList
|
||||
userEventMusicList?.let { list ->
|
||||
db.eventMusic.saveAll(list.distinctBy { it.eventId to it.type to it.musicId }.mapApply {
|
||||
id = db.eventMusic.findByUserAndEventIdAndTypeAndMusicId(u, eventId, type, musicId)()?.id ?: 0 }) }
|
||||
id = db.eventMusic.findByUserAndEventIdAndTypeAndMusicId(u, eventId, type, musicId)?.id ?: 0 }) }
|
||||
|
||||
// UserTechEventList
|
||||
userTechEventList?.let { list ->
|
||||
db.techEvent.saveAll(list.distinctBy { it.eventId }.mapApply {
|
||||
id = db.techEvent.findByUserAndEventId(u, eventId)()?.id ?: 0 }) }
|
||||
id = db.techEvent.findByUserAndEventId(u, eventId)?.id ?: 0 }) }
|
||||
|
||||
// UserKopList
|
||||
userKopList?.let { list ->
|
||||
db.kop.saveAll(list.distinctBy { it.kopId to it.areaId }.mapApply {
|
||||
id = db.kop.findByUserAndKopIdAndAreaId(u, kopId, areaId)()?.id ?: 0 }) }
|
||||
id = db.kop.findByUserAndKopIdAndAreaId(u, kopId, areaId)?.id ?: 0 }) }
|
||||
}
|
||||
|
||||
null
|
||||
|
||||
@ -14,10 +14,10 @@ import java.time.format.DateTimeFormatter
|
||||
|
||||
|
||||
fun OngekiController.initUser() {
|
||||
"GetUserData" { mapOf("userId" to uid, "userData" to db.data.findByCard_ExtId(uid)()) }
|
||||
"GetUserData" { mapOf("userId" to uid, "userData" to db.data.findByCard_ExtId(uid)) }
|
||||
|
||||
"GetUserOption" { mapOf("userId" to uid, "userOption" to db.option.findSingleByUser_Card_ExtId(uid)()) }
|
||||
"GetUserEventMap" { mapOf("userId" to uid, "userEventMap" to db.eventMap.findSingleByUser_Card_ExtId(uid)()) }
|
||||
"GetUserOption" { mapOf("userId" to uid, "userOption" to db.option.findSingleByUser_Card_ExtId(uid)) }
|
||||
"GetUserEventMap" { mapOf("userId" to uid, "userEventMap" to db.eventMap.findSingleByUser_Card_ExtId(uid)) }
|
||||
|
||||
"GetUserTechEvent".unpaged { db.techEvent.findByUser_Card_ExtId(uid) }
|
||||
"GetUserBoss".unpaged { db.boss.findByUser_Card_ExtId(uid) }
|
||||
@ -91,7 +91,7 @@ fun OngekiController.initUser() {
|
||||
|
||||
// Check if user have infinite kaika
|
||||
if (kind == OgkItemType.KaikaItem.ordinal) {
|
||||
val u = db.data.findByCard_ExtId(uid)()
|
||||
val u = db.data.findByCard_ExtId(uid)
|
||||
u?.card?.aquaUser?.gameOptions?.let {
|
||||
if (it.ongekiInfiniteKaika) {
|
||||
dat = listOf(UserItem().apply {
|
||||
@ -115,7 +115,7 @@ fun OngekiController.initUser() {
|
||||
}
|
||||
|
||||
"GetUserPreview" api@ {
|
||||
val u = db.data.findByCard_ExtId(uid)() ?: return@api mapOf(
|
||||
val u = db.data.findByCard_ExtId(uid) ?: return@api mapOf(
|
||||
"userId" to uid,
|
||||
"isLogin" to false,
|
||||
"lastLoginDate" to "0000-00-00 00:00:00",
|
||||
@ -138,7 +138,7 @@ fun OngekiController.initUser() {
|
||||
"banStatus" to 0,
|
||||
"isWarningConfirmed" to true
|
||||
)
|
||||
val o = db.option.findSingleByUser(u)()
|
||||
val o = db.option.findSingleByUser(u)
|
||||
|
||||
val res = mutableMapOf(
|
||||
"userId" to uid, "isLogin" to false,
|
||||
@ -173,7 +173,7 @@ fun OngekiController.initUser() {
|
||||
}
|
||||
|
||||
"GameLogin" {
|
||||
val user = db.data.findByCard_ExtId(uid)()
|
||||
val user = db.data.findByCard_ExtId(uid)
|
||||
|
||||
if (user?.card?.status == CardStatus.MIGRATED_TO_MINATO) {
|
||||
"""{"returnCode":"0"}"""
|
||||
@ -184,7 +184,7 @@ fun OngekiController.initUser() {
|
||||
}
|
||||
|
||||
"GetUserRecentRating".unpaged {
|
||||
db.generalData.findByUser_Card_ExtIdAndPropertyKey(uid, "recent_rating_list")()?.let { recent ->
|
||||
db.generalData.findByUser_Card_ExtIdAndPropertyKey(uid, "recent_rating_list")?.let { recent ->
|
||||
recent.propertyValue.split(',').dropLastWhile { it.isEmpty() }.map {
|
||||
val (m, d, s) = it.split(':').map { it.int }
|
||||
UserRecentRating(m, d, "1000000", s)
|
||||
|
||||
@ -155,7 +155,7 @@ fun WaccaServer.init() {
|
||||
if (user(uid) != null) 404 - "User already exists"
|
||||
|
||||
val u = rp.user.save(WaccaUser().apply {
|
||||
card = cardRepo.findByExtId(uid.uint32())() ?: (404 - "Card not found")
|
||||
card = cardRepo.findByExtId(uid.uint32()) ?: (404 - "Card not found")
|
||||
userName = name.toString()
|
||||
})
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user