[+] Maimai item unlock

This commit is contained in:
Azalea
2024-03-18 05:31:55 -04:00
parent af83cf552e
commit b3955731c2
6 changed files with 84 additions and 32 deletions

View File

@@ -12,6 +12,7 @@ import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonNamingStrategy
import org.apache.tika.Tika
import org.apache.tika.mime.MimeTypes
import org.slf4j.LoggerFactory
import org.springframework.http.HttpStatus
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestHeader
@@ -67,6 +68,16 @@ val HTTP = HttpClient(CIO) {
val TIKA = Tika()
val MIMES = MimeTypes.getDefaultMimeTypes()
// Class resource
object Ext {
val log = LoggerFactory.getLogger(Ext::class.java)
}
fun res(name: Str) = Ext::class.java.getResourceAsStream(name)
fun resStr(name: Str) = res(name)?.reader()?.readText()
inline fun <reified T> resJson(name: Str, warn: Boolean = true) = resStr(name)?.let {
JSON.decodeFromString<T>(it)
} ?: run { if (warn) Ext.log.warn("Resource $name is not found"); null }
// Date and time
fun millis() = System.currentTimeMillis()
val DATE_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd")