mirror of
https://github.com/MewoLab/AquaDX.git
synced 2025-10-26 04:22:38 +00:00
export options
This commit is contained in:
parent
155202dab9
commit
5c1f659437
@ -30,7 +30,7 @@ allnet.server.redirect=https://aquadx.net
|
|||||||
## Http Server Port
|
## Http Server Port
|
||||||
## Only change this if you have a reverse proxy running.
|
## Only change this if you have a reverse proxy running.
|
||||||
## The game rely on 80 port for boot up command
|
## The game rely on 80 port for boot up command
|
||||||
server.port=80
|
server.port=8080
|
||||||
|
|
||||||
## Static file server
|
## Static file server
|
||||||
## This is used to server static files in /web/ directory, which is Aquaviewer
|
## This is used to server static files in /web/ directory, which is Aquaviewer
|
||||||
|
|||||||
@ -16,6 +16,10 @@ import kotlin.io.path.Path
|
|||||||
import kotlin.io.path.writeText
|
import kotlin.io.path.writeText
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
data class ExportOptions(
|
||||||
|
val playlogSince: String? = null
|
||||||
|
)
|
||||||
|
|
||||||
// Import class with renaming
|
// Import class with renaming
|
||||||
data class ImportClass<T : Any>(
|
data class ImportClass<T : Any>(
|
||||||
val type: KClass<T>,
|
val type: KClass<T>,
|
||||||
@ -54,6 +58,7 @@ abstract class ImportController<ExportModel: IExportClass<UserModel>, UserModel:
|
|||||||
val exportFields: Map<String, Var<ExportModel, Any>>,
|
val exportFields: Map<String, Var<ExportModel, Any>>,
|
||||||
val exportRepos: Map<Var<ExportModel, Any>, IUserRepo<UserModel, *>>,
|
val exportRepos: Map<Var<ExportModel, Any>, IUserRepo<UserModel, *>>,
|
||||||
val artemisRenames: Map<String, ImportClass<*>>,
|
val artemisRenames: Map<String, ImportClass<*>>,
|
||||||
|
val customExporters: Map<Var<ExportModel, Any>, (UserModel, ExportOptions) -> Any?> = emptyMap()
|
||||||
) {
|
) {
|
||||||
abstract fun createEmpty(): ExportModel
|
abstract fun createEmpty(): ExportModel
|
||||||
abstract val userDataRepo: GenericUserDataRepo<UserModel>
|
abstract val userDataRepo: GenericUserDataRepo<UserModel>
|
||||||
@ -72,12 +77,19 @@ abstract class ImportController<ExportModel: IExportClass<UserModel>, UserModel:
|
|||||||
val listRepos = exportRepos.filter { it.key returns List::class }
|
val listRepos = exportRepos.filter { it.key returns List::class }
|
||||||
val singleRepos = exportRepos.filter { !(it.key returns List::class) }
|
val singleRepos = exportRepos.filter { !(it.key returns List::class) }
|
||||||
|
|
||||||
fun export(u: AquaNetUser) = createEmpty().apply {
|
fun export(u: AquaNetUser): ExportModel = export(u, ExportOptions())
|
||||||
|
|
||||||
|
fun export(u: AquaNetUser, options: ExportOptions) = createEmpty().apply {
|
||||||
gameId = game
|
gameId = game
|
||||||
userData = userDataRepo.findByCard(u.ghostCard) ?: (404 - "User not found")
|
userData = userDataRepo.findByCard(u.ghostCard) ?: (404 - "User not found")
|
||||||
exportRepos.forEach { (f, u) ->
|
exportRepos.forEach { (f, u) ->
|
||||||
if (f returns List::class) f.set(this, u.findByUser(userData))
|
val customExporter = customExporters[f]
|
||||||
else u.findSingleByUser(userData)()?.let { f.set(this, it) }
|
if (customExporter != null) {
|
||||||
|
customExporter(userData, options)?.let { f.set(this, it) }
|
||||||
|
} else {
|
||||||
|
if (f returns List::class) f.set(this, u.findByUser(userData))
|
||||||
|
else u.findSingleByUser(userData)()?.let { f.set(this, it) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package icu.samnyan.aqua.net.games.mai2
|
|||||||
import ext.API
|
import ext.API
|
||||||
import ext.returns
|
import ext.returns
|
||||||
import ext.vars
|
import ext.vars
|
||||||
|
import icu.samnyan.aqua.net.games.ExportOptions
|
||||||
import icu.samnyan.aqua.net.games.IExportClass
|
import icu.samnyan.aqua.net.games.IExportClass
|
||||||
import icu.samnyan.aqua.net.games.ImportClass
|
import icu.samnyan.aqua.net.games.ImportClass
|
||||||
import icu.samnyan.aqua.net.games.ImportController
|
import icu.samnyan.aqua.net.games.ImportController
|
||||||
@ -44,7 +45,18 @@ class Mai2Import(
|
|||||||
"mai2_profile_option" to ImportClass(Mai2UserOption::class, mapOf("version" to null)),
|
"mai2_profile_option" to ImportClass(Mai2UserOption::class, mapOf("version" to null)),
|
||||||
"mai2_score_best" to ImportClass(Mai2UserMusicDetail::class),
|
"mai2_score_best" to ImportClass(Mai2UserMusicDetail::class),
|
||||||
"mai2_score_course" to ImportClass(Mai2UserCourse::class),
|
"mai2_score_course" to ImportClass(Mai2UserCourse::class),
|
||||||
)
|
),
|
||||||
|
customExporters = run {
|
||||||
|
mapOf(
|
||||||
|
Maimai2DataExport::userPlaylogList to { user: Mai2UserDetail, options: ExportOptions ->
|
||||||
|
if (options.playlogSince != null) {
|
||||||
|
repos.userPlaylog.findByUserAndUserPlayDateAfter(user, options.playlogSince)
|
||||||
|
} else {
|
||||||
|
repos.userPlaylog.findByUser(user)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
) as Map<kotlin.reflect.KMutableProperty1<Maimai2DataExport, Any>, (Mai2UserDetail, ExportOptions) -> Any?>
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
override fun createEmpty() = Maimai2DataExport()
|
override fun createEmpty() = Maimai2DataExport()
|
||||||
override val userDataRepo = repos.userData
|
override val userDataRepo = repos.userData
|
||||||
@ -74,4 +86,4 @@ data class Maimai2DataExport(
|
|||||||
mutableListOf(), mutableListOf(), mutableListOf(), mutableListOf(), mutableListOf(), mutableListOf(),
|
mutableListOf(), mutableListOf(), mutableListOf(), mutableListOf(), mutableListOf(), mutableListOf(),
|
||||||
mutableListOf(), mutableListOf(), mutableListOf(), mutableListOf(), mutableListOf(), mutableListOf(),
|
mutableListOf(), mutableListOf(), mutableListOf(), mutableListOf(), mutableListOf(), mutableListOf(),
|
||||||
mutableListOf())
|
mutableListOf())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -104,6 +104,7 @@ interface Mai2UserPlaylogRepo : GenericPlaylogRepo<Mai2UserPlaylog>, Mai2UserLin
|
|||||||
musicId: Int,
|
musicId: Int,
|
||||||
userPlayDate: String
|
userPlayDate: String
|
||||||
): MutableList<Mai2UserPlaylog>
|
): MutableList<Mai2UserPlaylog>
|
||||||
|
fun findByUserAndUserPlayDateAfter(user: Mai2UserDetail, userPlayDate: String): List<Mai2UserPlaylog>
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Mai2UserPrintDetailRepo : JpaRepository<Mai2UserPrintDetail, Long>
|
interface Mai2UserPrintDetailRepo : JpaRepository<Mai2UserPrintDetail, Long>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user