[RF] move userMusicFromList to GameApiController and add GenericUserMusicRepo

This commit is contained in:
Clansty
2025-01-05 19:54:15 +08:00
parent 7083e1a117
commit ccd88a10ab
14 changed files with 42 additions and 18 deletions

View File

@@ -2,6 +2,7 @@ package icu.samnyan.aqua.sega.wacca.model.db
import icu.samnyan.aqua.net.games.GenericPlaylogRepo
import icu.samnyan.aqua.net.games.GenericUserDataRepo
import icu.samnyan.aqua.net.games.GenericUserMusicRepo
import jakarta.transaction.Transactional
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query
@@ -32,7 +33,7 @@ interface WcUserItemRepo : IWaccaUserLinked<WcUserItem> {
fun findByUserAndType(user: WaccaUser, type: Int): List<WcUserItem>
fun findByUserAndItemIdAndType(user: WaccaUser, itemId: Int, type: Int): WcUserItem?
}
interface WcUserBestScoreRepo : IWaccaUserLinked<WcUserScore> {
interface WcUserBestScoreRepo : IWaccaUserLinked<WcUserScore>, GenericUserMusicRepo<WcUserScore> {
fun findByUserAndMusicIdAndLevel(user: WaccaUser, songId: Int, level: Int): WcUserScore?
@Query("SELECT SUM(achievement) FROM WcUserScore WHERE user = :user")
fun sumScoreByUser(user: WaccaUser): Long

View File

@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore
import ext.*
import icu.samnyan.aqua.net.games.BaseEntity
import icu.samnyan.aqua.net.games.IGenericGamePlaylog
import icu.samnyan.aqua.net.games.IGenericUserMusic
import icu.samnyan.aqua.sega.general.IntegerListConverter
import icu.samnyan.aqua.sega.wacca.WaccaItemType
import icu.samnyan.aqua.sega.wacca.WaccaItemType.*
@@ -92,8 +93,8 @@ class WcUserItem(
}
@Entity @Table(name = "wacca_user_score", uniqueConstraints = [UC("", ["user_id", "music_id", "level"])])
class WcUserScore : WaccaUserEntity() {
var musicId = 0
class WcUserScore : WaccaUserEntity(), IGenericUserMusic {
override var musicId = 0
var level = 0 // aka difficulty
var achievement = 0