forked from Cookies_Github_mirror/AquaDX
[O] Complete kt rewrite
This commit is contained in:
@@ -4,11 +4,10 @@ import ext.*
|
||||
import icu.samnyan.aqua.net.db.AquaUserServices
|
||||
import icu.samnyan.aqua.net.utils.simpleDescribe
|
||||
import icu.samnyan.aqua.sega.allnet.TokenChecker
|
||||
import icu.samnyan.aqua.sega.chusan.handler.GameLoginHandler
|
||||
import icu.samnyan.aqua.sega.chusan.handler.UpsertUserAllHandler
|
||||
import icu.samnyan.aqua.sega.chusan.handler.chusanInit
|
||||
import icu.samnyan.aqua.sega.chusan.model.Chu3Repos
|
||||
import icu.samnyan.aqua.sega.general.*
|
||||
import icu.samnyan.aqua.sega.general.MeowApi
|
||||
import icu.samnyan.aqua.sega.general.RequestContext
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper
|
||||
import icu.samnyan.aqua.sega.util.jackson.StringMapper
|
||||
import icu.samnyan.aqua.spring.Metrics
|
||||
@@ -16,7 +15,6 @@ import jakarta.servlet.http.HttpServletRequest
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import kotlin.collections.set
|
||||
import kotlin.reflect.full.declaredMemberProperties
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
@@ -25,9 +23,6 @@ import kotlin.reflect.full.declaredMemberProperties
|
||||
@RestController
|
||||
@API(value = ["/g/chu3/{version}/ChuniServlet", "/g/chu3/{version}"])
|
||||
class ChusanController(
|
||||
val gameLogin: GameLoginHandler,
|
||||
val upsertUserAll: UpsertUserAllHandler,
|
||||
|
||||
val mapper: StringMapper,
|
||||
val cmMapper: BasicMapper,
|
||||
val db: Chu3Repos,
|
||||
@@ -40,22 +35,12 @@ class ChusanController(
|
||||
}) {
|
||||
val log = LoggerFactory.getLogger(ChusanController::class.java)
|
||||
|
||||
// Below are code related to handling the handlers
|
||||
val externalHandlers = mutableListOf("GameLoginApi", "UpsertUserAllApi")
|
||||
|
||||
val noopEndpoint = setOf("UpsertClientBookkeepingApi", "UpsertClientDevelopApi", "UpsertClientErrorApi",
|
||||
"UpsertClientSettingApi", "UpsertClientTestmodeApi", "CreateTokenApi", "RemoveTokenApi", "UpsertClientUploadApi",
|
||||
"PrinterLoginApi", "PrinterLogoutApi", "Ping", "GameLogoutApi", "RemoveMatchingMemberApi")
|
||||
|
||||
init { chusanInit() }
|
||||
|
||||
val members = this::class.declaredMemberProperties
|
||||
val handlers: Map<String, SpecialHandler> = initH + externalHandlers.associateWith { api ->
|
||||
val name = api.replace("Api", "").lowercase()
|
||||
(members.find { it.name.lowercase() == name } ?: members.find { it.name.lowercase() == name.replace("cm", "") })
|
||||
?.let { (it.call(this) as BaseHandler).toSpecial() }
|
||||
?: throw IllegalArgumentException("Chu3: No handler found for $api")
|
||||
}
|
||||
val handlers = initH
|
||||
|
||||
@API("/{endpoint}", "/MatchingServer/{endpoint}")
|
||||
fun handle(@PV endpoint: Str, @RB data: MutableMap<Str, Any>, @PV version: Str, req: HttpServletRequest): Any {
|
||||
|
||||
Reference in New Issue
Block a user