[+] Wacca user/status/get

This commit is contained in:
Azalea 2024-03-28 02:10:25 -04:00
parent 1cdbed51cd
commit 93f6bf8ba3
3 changed files with 25 additions and 6 deletions

View File

@ -34,7 +34,8 @@ class WaccaServer(val rp: WaccaRepos) {
infix fun String.cached(block: () -> Any) { cacheMap[this.lowercase()] = block().toJson() } infix fun String.cached(block: () -> Any) { cacheMap[this.lowercase()] = block().toJson() }
/** Convert "3.07.01.JPN.26935.S" into "3.7.1" */ /** Convert "3.07.01.JPN.26935.S" into "3.7.1" */
fun String.shortVer() = split('.').let { "${it[0]}.${it[1].trimStart('0')}.${it[2].trimStart('0')}" } fun String.shortVer() = split('.').let { if (it.size < 3) "1.0.0" else
"${it[0]}.${it[1].toInt()}.${it[2].toInt()}" }
/** Generate response message */ /** Generate response message */
fun resp(paramsJson: String, status: Int = 0, message: String = ""): ResponseEntity<String> { fun resp(paramsJson: String, status: Int = 0, message: String = ""): ResponseEntity<String> {
@ -79,12 +80,13 @@ fun WaccaServer.api() {
val u = ru ?: WaccaUser() val u = ru ?: WaccaUser()
val o = options(ru) val o = options(ru)
u.run { ls( u.run { ls(
ls(uid, username, "userType" - 1, xp, danLevel, danType, wp, "titlePartIds" - ls(0, 0, 0), ls(u.id, username, "userType" - 1, xp, danLevel, danType, wp, "titlePartIds" - ls(0, 0, 0),
loginCount, loginCountDays, loginCountConsec, loginCountDaysConsec, vipExpireTime, loginCountToday, rating), loginCount, loginCountDays, loginCountConsec, loginCountDaysConsec, vipExpireTime, loginCountToday, rating),
o[SET_TITLE_ID], o[SET_ICON_ID], o[SET_TITLE_ID], o[SET_ICON_ID],
"status" - if (ru == null) 1 else 0, // 0 = GOOD, 1 = Register "status" - if (ru == null) 1 else 0, // 0 = GOOD, 1 = Register
// 0 = Version GOOD, 1 = Game is newer, 2 = Game is older // 0 = Version GOOD, 1 = Game is newer, 2 = Game is older
"version" - ls(req.appVersion.shortVer().compareTo(lastGameVer.shortVer()), lastGameVer.shortVer()) "version" - ls(req.appVersion.shortVer().compareTo(lastGameVer.shortVer()), lastGameVer.shortVer()),
o.map { (k, v) -> ls(k, v) }
) } ) }
} }
} }

View File

@ -3,6 +3,7 @@ package icu.samnyan.aqua.sega.wacca.model.db
import icu.samnyan.aqua.net.games.BaseEntity import icu.samnyan.aqua.net.games.BaseEntity
import icu.samnyan.aqua.sega.general.model.Card import icu.samnyan.aqua.sega.general.model.Card
import jakarta.persistence.* import jakarta.persistence.*
import java.util.Date
/** /**
* General user information * General user information
@ -26,7 +27,8 @@ class WaccaUser : BaseEntity() {
var title1 = 0 var title1 = 0
var title2 = 0 var title2 = 0
var rating = 0 var rating = 0
var vipExpireTime: String = "" @Temporal(TemporalType.TIME)
var vipExpireTime: Date = Date(0)
var alwaysVip = false var alwaysVip = false
var loginCount = 0 var loginCount = 0
var loginCountConsec = 0 var loginCountConsec = 0
@ -42,7 +44,7 @@ class WaccaUser : BaseEntity() {
var friendView2 = 0 var friendView2 = 0
var friendView3 = 0 var friendView3 = 0
@Column(length = 50) @Column(length = 50)
var lastGameVer = "" var lastGameVer = "1.0.0"
var lastSongId = 0 var lastSongId = 0
var lastSongDifficulty = 0 var lastSongDifficulty = 0
var lastFolderOrder = 0 var lastFolderOrder = 0

View File

@ -32,7 +32,22 @@ class WaccaTest : StringSpec({
if (uid == 0L) uid = registerUser() if (uid == 0L) uid = registerUser()
} }
"housing/get" { "housing/get #1" {
post("housing/get", "[]").res shouldBe "[39, 0]".jsonArray() post("housing/get", "[]").res shouldBe "[39, 0]".jsonArray()
} }
"housing/start #1" {
post("housing/start", """["", "2024/03/24 10:39:36, ApiUserStatusLogout,0\\n2024/03/24 10:51:06, ApiUserStatusLogout,0\\n2024/03/24 10:54:19, ApiUserStatusLogout,0\\n2024/03/24 10:59:33, ApiAdvertiseGetNews,0\\n2024/03/24 11:10:31, ApiAdvertiseGetNews,0\\n2024/03/24 11:11:04, ApiUserStatusLogout,0\\n2024/03/24 11:19:51, ,0\\n2024/03/24 11:20:14, ApiAdvertiseGetNews,0\\n", "", [[1, "SERVER"], [2, "JPN"]]]""").res shouldBe
"[1, [1269, 1007, 1270, 1002, 1020, 1003, 1008, 1211, 1018, 1092, 1056, 32, 1260, 1230, 1258, 1251, 2212, 1264, 1125, 1037, 2001, 1272, 1126, 1119, 1104, 1070, 1047, 1044, 1027, 1004, 1001, 24, 2068, 2062, 2021, 1275, 1249, 1207, 1203, 1107, 1021, 1009, 9, 4, 3, 23, 22, 2014, 13, 1276, 1247, 1240, 1237, 1128, 1114, 1110, 1109, 1102, 1045, 1043, 1036, 1035, 1030, 1023, 1015]]".jsonArray()
}
"advertise/GetNews #1" {
post("advertise/GetNews", "[]").res shouldBe
"[[], [], [], [], [], [], [], [], []]".jsonArray()
}
"user/status/get #1" {
post("user/status/get", """["$uid"]""").res shouldBe
"""[[0, "", 1, 0, 0, 0, 0, [0, 0, 0], 0, 0, 0, 0, 0, 0, 0], 104001, 102001, 1, [2, "1.0.0"], []]""".jsonArray()
}
}) })