[+] Unlock option database model

pull/23/head
Azalea 2024-03-18 01:31:28 -04:00
parent a952674df7
commit 752d65557f
3 changed files with 58 additions and 4 deletions

View File

@ -0,0 +1,35 @@
package icu.samnyan.aqua.net.db
import com.fasterxml.jackson.annotation.JsonIgnore
import ext.SettingField
import jakarta.persistence.Entity
import jakarta.persistence.GeneratedValue
import jakarta.persistence.GenerationType
import jakarta.persistence.Id
import org.springframework.data.jpa.repository.JpaRepository
@Entity
class AquaGameOptions(
@Id @JsonIgnore
@GeneratedValue(strategy = GenerationType.IDENTITY)
var id: Long = 0,
@SettingField("Unlock All Music",
"Unlock all music and master difficulty in game")
val unlockMusic: Boolean = false,
@SettingField("Unlock All Chara",
"Unlock all characters and partners in game")
val unlockChara: Boolean = false,
@SettingField("Unlock All Collectables",
"Unlock all collectables (nameplate, title, icon, frame) in game. " +
"This setting is not relevant in chusan because in-game user box is disabled in chusan.")
val unlockCollectables: Boolean = false,
@SettingField("Unlock All Tickets" ,
"Unlock all map tickets (the game still limits which tickets can be used)")
val unlockTickets: Boolean = false,
)
interface AquaGameOptionsRepository : JpaRepository<AquaGameOptions, Long>

View File

@ -11,7 +11,6 @@ import icu.samnyan.aqua.sega.general.model.Card
import jakarta.persistence.*
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.security.crypto.password.PasswordEncoder
import org.springframework.stereotype.Repository
import org.springframework.stereotype.Service
import java.io.Serializable
import kotlin.jvm.optionals.getOrNull
@ -19,8 +18,7 @@ import kotlin.reflect.KFunction
import kotlin.reflect.KMutableProperty
import kotlin.reflect.full.functions
@Entity(name = "AquaNetUser")
@Table(name = "aqua_net_user")
@Entity
class AquaNetUser(
@JsonIgnore
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
@ -75,6 +73,10 @@ class AquaNetUser(
@JsonIgnore
@OneToMany(mappedBy = "user", cascade = [CascadeType.ALL])
var keychipSessions: MutableList<KeychipSession> = mutableListOf(),
@OneToOne(cascade = [CascadeType.ALL])
@JoinColumn(name = "gameOptions", unique = true, nullable = true)
var gameOptions: AquaGameOptions? = null
) : Serializable {
val computedName get() = displayName.ifEmpty { username }
@ -89,7 +91,6 @@ class AquaNetUser(
)
}
@Repository("AquaNetUserRepository")
interface AquaNetUserRepo : JpaRepository<AquaNetUser, Long> {
fun findByAuId(auId: Long): AquaNetUser?
fun findByEmailIgnoreCase(email: String): AquaNetUser?

View File

@ -0,0 +1,18 @@
CREATE TABLE aqua_game_options
(
id BIGINT AUTO_INCREMENT NOT NULL,
unlock_music BIT(1) NOT NULL,
unlock_chara BIT(1) NOT NULL,
unlock_collectables BIT(1) NOT NULL,
unlock_tickets BIT(1) NOT NULL,
CONSTRAINT pk_aquagameoptions PRIMARY KEY (id)
);
ALTER TABLE aqua_net_user
ADD game_options BIGINT NULL;
ALTER TABLE aqua_net_user
ADD CONSTRAINT uc_aquanetuser_gameoptions UNIQUE (game_options);
ALTER TABLE aqua_net_user
ADD CONSTRAINT FK_AQUANETUSER_ON_GAMEOPTIONS FOREIGN KEY (game_options) REFERENCES aqua_game_options (id);