forked from Cookies_Github_mirror/AquaDX
[F] Fix json
This commit is contained in:
@@ -62,21 +62,22 @@ class ChusanController(
|
||||
val token = TokenChecker.getCurrentSession()?.token?.substring(0, 6) ?: "NO-TOKEN"
|
||||
log.info("Chu3 < $api : ${data.toJson()} : [$token]")
|
||||
|
||||
val noop = """{"returnCode":"1","apiName":"$api"}"""
|
||||
if (api !in noopEndpoint && !handlers.containsKey(api)) {
|
||||
log.warn("Chu3 > $api not found")
|
||||
return """{"returnCode":"1","apiName":"$api"}"""
|
||||
return noop
|
||||
}
|
||||
|
||||
// Only record the counter metrics if the API is known.
|
||||
Metrics.counter("aquadx_chusan_api_call", "api" to api).increment()
|
||||
if (api in noopEndpoint) {
|
||||
log.info("Chu3 > $api no-op")
|
||||
return """{"returnCode":"1"}"""
|
||||
return noop
|
||||
}
|
||||
|
||||
return try {
|
||||
Metrics.timer("aquadx_chusan_api_latency", "api" to api).recordCallable {
|
||||
serialize(api, handlers[api]!!(ctx)).also {
|
||||
serialize(api, handlers[api]!!(ctx) ?: noop).also {
|
||||
if (api !in setOf("GetUserItemApi", "GetGameEventApi"))
|
||||
log.info("Chu3 > $api : $it")
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package icu.samnyan.aqua.sega.chusan.handler
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference
|
||||
import ext.*
|
||||
import icu.samnyan.aqua.sega.chusan.ChusanController
|
||||
import icu.samnyan.aqua.sega.chusan.model.request.UpsertUserGacha
|
||||
@@ -29,7 +28,7 @@ fun ChusanController.cmApiInit() {
|
||||
val (gachaId, placeId) = parsing { data["gachaId"]!!.int to data["placeId"]!!.int }
|
||||
|
||||
val u = db.userData.findByCard_ExtId(uid)() ?: return@api null
|
||||
val upsertUserGacha = parsing { mapper.convert(data["cmUpsertUserGacha"], UpsertUserGacha::class.java) }
|
||||
val upsertUserGacha = parsing { mapper.convert<UpsertUserGacha>(data["cmUpsertUserGacha"]!!) }
|
||||
|
||||
upsertUserGacha.gameGachaCardList?.let { lst ->
|
||||
db.userCardPrintState.saveAll(lst.map {
|
||||
@@ -63,7 +62,7 @@ fun ChusanController.cmApiInit() {
|
||||
}
|
||||
|
||||
"CMUpsertUserPrintCancel" {
|
||||
val orderIdList: List<Long> = cmMapper.convert(data["orderIdList"], object : TypeReference<List<Long>>() {})
|
||||
val orderIdList: List<Long> = cmMapper.convert<List<Long>>(parsing { data["orderIdList"]!! })
|
||||
|
||||
db.userCardPrintState.saveAll(orderIdList.mapNotNull {
|
||||
// TODO: The original code by Eori writes findById but I don't think that is correct...
|
||||
@@ -76,8 +75,8 @@ fun ChusanController.cmApiInit() {
|
||||
}
|
||||
|
||||
"CMUpsertUserPrintSubtract" api@ {
|
||||
val userCardPrintState = cmMapper.convert(data["userCardPrintState"], UserCardPrintState::class.java)
|
||||
val userItemList = cmMapper.convert(data["userItemList"], object : TypeReference<List<UserItem>>() {})
|
||||
val userCardPrintState = cmMapper.convert<UserCardPrintState>(parsing { data["userCardPrintState"]!! })
|
||||
val userItemList = cmMapper.convert<List<UserItem>>(parsing { data["userItemList"]!! })
|
||||
|
||||
val u = db.userData.findByCard_ExtId(uid)() ?: return@api null
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ fun ChusanController.upsertApiInit() {
|
||||
}
|
||||
|
||||
"UpsertUserAll" api@ {
|
||||
val req = mapper.convert(data["upsertUserAll"], UpsertUserAll::class.java)
|
||||
val req = parsing { mapper.convert<UpsertUserAll>(data["upsertUserAll"]!!) }
|
||||
|
||||
req.run {
|
||||
// UserData
|
||||
|
||||
Reference in New Issue
Block a user