mirror of
https://github.com/MewoLab/AquaDX.git
synced 2025-10-25 12:02:40 +00:00
Compare commits
2 Commits
3d95a84739
...
6ca419dd5b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ca419dd5b | ||
|
|
fc3f2171ee |
@ -2,7 +2,7 @@
|
||||
import { USER} from "../../libs/sdk";
|
||||
import { ts } from "../../libs/i18n";
|
||||
import StatusOverlays from "../StatusOverlays.svelte";
|
||||
let regionId = 0;
|
||||
let regionId = $state(0);
|
||||
let submitting = ""
|
||||
let error: string;
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
</label>
|
||||
<select bind:value={regionId} on:change={saveNewRegion}>
|
||||
<option value={0} disabled selected>{ts("settings.regionSelector.select")}</option>
|
||||
{#each prefectures.filter(p=>p!=="None") as prefecture, index}
|
||||
{#each prefectures.slice(1) as prefecture, index}
|
||||
<option value={index}>{prefecture}</option>
|
||||
{/each}
|
||||
</select>
|
||||
|
||||
@ -83,7 +83,6 @@ fun ChusanController.chusanInit() {
|
||||
"GetUserCtoCPlay" { """{"userId":"${data["userId"]}","orderBy":"0","count":"0","userCtoCPlayList":[]}""" }
|
||||
"GetUserRivalMusic" { """{"userId":"${data["userId"]}","rivalId":"0","length":"0","nextIndex":"0","userRivalMusicList":[]}""" }
|
||||
"GetUserRivalData" { """{"userId":"${data["userId"]}","length":"0","userRivalData":[]}""" }
|
||||
"GetUserRegion" { """{"userId":"${data["userId"]}","length":"0","userRegionList":[]}""" }
|
||||
"GetUserPrintedCard" { """{"userId":"${data["userId"]}","length":0,"nextIndex":-1,"userPrintedCardList":[]}""" }
|
||||
|
||||
// Net battle data
|
||||
|
||||
@ -30,22 +30,14 @@ fun ChusanController.upsertApiInit() {
|
||||
}.also { db.userData.saveAndFlush(it) }
|
||||
|
||||
// Only save if it is a valid region and the user has played at least a song
|
||||
if (req.userPlaylogList?.isNotEmpty() == true) {
|
||||
val region = req.userPlaylogList!![0].regionId
|
||||
|
||||
val userRegion = db.userRegions.findByUserIdAndRegionId(u.id, region)
|
||||
if (userRegion.isPresent) {
|
||||
userRegion.get().apply {
|
||||
playCount += 1
|
||||
db.userRegions.save(this)
|
||||
}
|
||||
} else {
|
||||
db.userRegions.save(UserRegions().apply {
|
||||
user = u
|
||||
regionId = region
|
||||
playCount = 1
|
||||
})
|
||||
req.userPlaylogList?.firstOrNull()?.regionId?.let { rid ->
|
||||
val region = db.userRegions.findByUserAndRegionId(u, rid)?.apply {
|
||||
playCount += 1
|
||||
} ?: UserRegions().apply {
|
||||
user = u
|
||||
regionId = rid
|
||||
}
|
||||
db.userRegions.save(region)
|
||||
}
|
||||
|
||||
versionHelper[u.lastClientId] = u.lastDataVersion
|
||||
|
||||
@ -175,7 +175,7 @@ interface Chu3GameLoginBonusRepo : JpaRepository<GameLoginBonus, Int> {
|
||||
}
|
||||
|
||||
interface Chu3UserRegionsRepo: Chu3UserLinked<UserRegions> {
|
||||
fun findByUserIdAndRegionId(userId: Long, regionId: Int): Optional<UserRegions>
|
||||
fun findByUserAndRegionId(user: Chu3UserData, regionId: Int): UserRegions?
|
||||
}
|
||||
|
||||
@Component
|
||||
|
||||
@ -9,6 +9,6 @@ import java.time.LocalDate
|
||||
@Table(name = "chusan_user_regions", uniqueConstraints = [UniqueConstraint(columnNames = ["user_id", "region_id"])])
|
||||
class UserRegions : Chu3UserEntity() {
|
||||
var regionId = 0
|
||||
var playCount = 0
|
||||
var playCount = 1
|
||||
var created: String = LocalDate.now().toString()
|
||||
}
|
||||
|
||||
@ -33,7 +33,10 @@ data class PagedProcessor(val add: JDict?, val fn: PagedHandler, var post: PageP
|
||||
// A very :3 way of declaring APIs
|
||||
abstract class MeowApi(val serialize: (String, Any) -> String) {
|
||||
val initH = mutableMapOf<String, SpecialHandler>()
|
||||
infix operator fun String.invoke(fn: SpecialHandler) = initH.set("${this}Api", fn)
|
||||
infix operator fun String.invoke(fn: SpecialHandler) {
|
||||
if (initH.containsKey("${this}Api")) error("Duplicate API $this found! Someone is not smart 👀")
|
||||
initH["${this}Api"] = fn
|
||||
}
|
||||
infix fun String.static(fn: () -> Any) = serialize(this, fn()).let { resp -> this { resp } }
|
||||
|
||||
// Page Cache: {cache key: (timestamp, full list)}
|
||||
|
||||
@ -11,6 +11,8 @@ import icu.samnyan.aqua.sega.maimai2.model.userdata.UserRegions
|
||||
import java.time.LocalDate
|
||||
|
||||
fun Maimai2ServletController.initApis() {
|
||||
val log = logger()
|
||||
|
||||
"GetUserExtend" { mapOf(
|
||||
"userId" to uid,
|
||||
"userExtend" to (db.userExtend.findSingleByUser_Card_ExtId(uid)() ?: (404 - "User not found"))
|
||||
@ -139,25 +141,14 @@ fun Maimai2ServletController.initApis() {
|
||||
val region = data["regionId"] as? Int
|
||||
|
||||
// Only save if it is a valid region and the user has played at least a song
|
||||
if (region!=null && region > 0 && d != null) {
|
||||
val userRegion = db.userRegions.findByUserIdAndRegionId(uid, region)
|
||||
if (userRegion.isPresent) {
|
||||
userRegion.get().apply {
|
||||
playCount += 1
|
||||
db.userRegions.save(this)
|
||||
}
|
||||
} else {
|
||||
logger().info("user: $d")
|
||||
logger().info("region: $region")
|
||||
|
||||
// Create a new user region row
|
||||
// Crea una nueva fila de región de usuario
|
||||
db.userRegions.save(UserRegions().apply {
|
||||
user = d
|
||||
regionId = region
|
||||
playCount = 1
|
||||
})
|
||||
if (region != null && region > 0 && d != null) {
|
||||
val region = db.userRegions.findByUserAndRegionId(d, region)?.apply {
|
||||
playCount += 1
|
||||
} ?: UserRegions().apply {
|
||||
user = d
|
||||
regionId = region
|
||||
}
|
||||
db.userRegions.save(region)
|
||||
}
|
||||
|
||||
res
|
||||
@ -208,7 +199,7 @@ fun Maimai2ServletController.initApis() {
|
||||
logger().info("Getting user regions for user $uid")
|
||||
db.userRegions.findByUser_Card_ExtId(uid)
|
||||
.map { mapOf("regionId" to it.regionId, "playCount" to it.playCount) }
|
||||
.let { mapOf("userId" to uid, "userRegionList" to it) }
|
||||
.let { mapOf("userId" to uid, "length" to it.size, "userRegionList" to it) }
|
||||
}
|
||||
|
||||
"GetUserIntimate".unpaged {
|
||||
@ -371,4 +362,4 @@ fun Maimai2ServletController.initApis() {
|
||||
"userRecommendSelectionMusicIdList" to (net.recommendedMusic[user.id] ?: empty)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,8 +57,6 @@ interface Mai2UserExtendRepo : Mai2UserLinked<Mai2UserExtend>
|
||||
interface Mai2UserFavoriteRepo : Mai2UserLinked<Mai2UserFavorite> {
|
||||
fun findByUserAndItemKind(user: Mai2UserDetail, kind: Int): Optional<Mai2UserFavorite>
|
||||
|
||||
fun findByUserIdAndItemKind(userId: Long, kind: Int): List<Mai2UserFavorite>
|
||||
|
||||
fun findByUser_Card_ExtIdAndItemKind(userId: Long, kind: Int): Optional<Mai2UserFavorite>
|
||||
}
|
||||
|
||||
@ -128,7 +126,7 @@ interface Mai2GameEventRepo : JpaRepository<Mai2GameEvent, Int> {
|
||||
interface Mai2GameSellingCardRepo : JpaRepository<Mai2GameSellingCard, Long>
|
||||
|
||||
interface Mai2UserRegionsRepo: Mai2UserLinked<UserRegions> {
|
||||
fun findByUserIdAndRegionId(userId: Long, regionId: Int): Optional<UserRegions>
|
||||
fun findByUserAndRegionId(user: Mai2UserDetail, regionId: Int): UserRegions?
|
||||
}
|
||||
|
||||
@Component
|
||||
|
||||
@ -559,7 +559,7 @@ class Mai2UserIntimate : Mai2UserEntity() {
|
||||
)
|
||||
class UserRegions : Mai2UserEntity() {
|
||||
var regionId = 0
|
||||
var playCount = 0
|
||||
var playCount = 1
|
||||
var created: String = LocalDate.now().toString()
|
||||
}
|
||||
|
||||
|
||||
@ -69,10 +69,4 @@ fun OngekiController.ongekiInit() {
|
||||
"GetClientTestmode" {
|
||||
empty.staticLst("clientTestmodeList") + mapOf("placeId" to data["placeId"])
|
||||
}
|
||||
|
||||
"GetUserRegion" {
|
||||
db.regions.findByUser_Card_ExtId(uid)
|
||||
.map { mapOf("regionId" to it.regionId, "playCount" to it.playCount) }
|
||||
.staticLst("userRegionList") + mapOf("userId" to uid)
|
||||
}
|
||||
}
|
||||
@ -148,7 +148,7 @@ interface OgkUserTrainingRoomRepo : OngekiUserLinked<UserTrainingRoom> {
|
||||
}
|
||||
|
||||
interface OgkUserRegionsRepo: OngekiUserLinked<UserRegions> {
|
||||
fun findByUserIdAndRegionId(userId: Long, regionId: Int): Optional<UserRegions>
|
||||
fun findByUserAndRegionId(user: UserData, regionId: Int): UserRegions?
|
||||
}
|
||||
|
||||
// Re:Fresh
|
||||
|
||||
@ -40,19 +40,13 @@ fun OngekiController.initUpsertAll() {
|
||||
|
||||
// Only save if it is a valid region and the user has played at least a song
|
||||
if (region > 0 && all.userPlaylogList?.isNotEmpty() == true) {
|
||||
val userRegion = db.regions.findByUserIdAndRegionId(u.id, region)
|
||||
if (userRegion.isPresent) {
|
||||
userRegion.get().apply {
|
||||
playCount += 1
|
||||
db.regions.save(this)
|
||||
}
|
||||
} else {
|
||||
db.regions.save(UserRegions().apply {
|
||||
user = u
|
||||
regionId = region
|
||||
playCount = 1
|
||||
})
|
||||
val region = db.regions.findByUserAndRegionId(u, region)?.apply {
|
||||
playCount += 1
|
||||
} ?:UserRegions().apply {
|
||||
user = u
|
||||
regionId = region
|
||||
}
|
||||
db.regions.save(region)
|
||||
}
|
||||
|
||||
all.run {
|
||||
|
||||
@ -41,7 +41,10 @@ fun OngekiController.initUser() {
|
||||
|
||||
"GetUserBpBase".unpaged { empty }
|
||||
"GetUserRatinglog".unpaged { empty }
|
||||
"GetUserRegion".unpaged { empty }
|
||||
"GetUserRegion".unpaged {
|
||||
db.regions.findByUser_Card_ExtId(uid)
|
||||
.map { mapOf("regionId" to it.regionId, "playCount" to it.playCount) }
|
||||
}
|
||||
|
||||
"GetUserTradeItem".unpaged {
|
||||
val start = parsing { data["startChapterId"]!!.int }
|
||||
|
||||
@ -521,6 +521,6 @@ class UserSkin : OngekiUserEntity() {
|
||||
)
|
||||
class UserRegions : OngekiUserEntity() {
|
||||
var regionId = 0
|
||||
var playCount = 0
|
||||
var playCount = 1
|
||||
var created: String = LocalDate.now().toString()
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user