forked from Cookies_Github_mirror/AquaDX
[+] Add field isBound to Card
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.general.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import icu.samnyan.aqua.net.db.AquaNetUser;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Entity(name = "SegaCard")
|
||||
@Table(name = "sega_card")
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Card implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@JsonIgnore
|
||||
private long id;
|
||||
|
||||
// A external id
|
||||
@Column(name = "ext_id", unique = true)
|
||||
@JsonIgnore // Sensitive information
|
||||
private Long extId;
|
||||
|
||||
// Access Code
|
||||
@Column(unique = true)
|
||||
private String luid;
|
||||
|
||||
@Column(name = "register_time")
|
||||
private LocalDateTime registerTime;
|
||||
|
||||
@Column(name = "access_time")
|
||||
private LocalDateTime accessTime;
|
||||
|
||||
// Defines the AquaNet user that this card is bound to
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "net_user_id")
|
||||
@JsonIgnore
|
||||
private AquaNetUser aquaUser;
|
||||
}
|
||||
48
src/main/java/icu/samnyan/aqua/sega/general/model/Card.kt
Normal file
48
src/main/java/icu/samnyan/aqua/sega/general/model/Card.kt
Normal file
@@ -0,0 +1,48 @@
|
||||
package icu.samnyan.aqua.sega.general.model
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
import icu.samnyan.aqua.net.db.AquaNetUser
|
||||
import jakarta.persistence.*
|
||||
import java.io.Serial
|
||||
import java.io.Serializable
|
||||
import java.time.LocalDateTime
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Entity(name = "SegaCard")
|
||||
@Table(name = "sega_card")
|
||||
class Card(
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@JsonIgnore
|
||||
val id: Long = 0,
|
||||
|
||||
// A external id
|
||||
@Column(name = "ext_id", unique = true, nullable = false)
|
||||
@JsonIgnore // Sensitive information
|
||||
var extId: Long = 0,
|
||||
|
||||
// Access Code
|
||||
@Column(unique = true, nullable = false)
|
||||
var luid: String = "",
|
||||
|
||||
@Column(name = "register_time", nullable = false)
|
||||
var registerTime: LocalDateTime = LocalDateTime.now(),
|
||||
|
||||
@Column(name = "access_time", nullable = false)
|
||||
var accessTime: LocalDateTime = registerTime,
|
||||
|
||||
// Defines the AquaNet user that this card is bound to
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "net_user_id")
|
||||
@JsonIgnore
|
||||
var aquaUser: AquaNetUser? = null,
|
||||
): Serializable {
|
||||
companion object {
|
||||
@Serial
|
||||
private val serialVersionUID = 1L
|
||||
}
|
||||
|
||||
val isBound get() = aquaUser != null
|
||||
}
|
||||
@@ -40,7 +40,7 @@ class CardService(val cardRepo: CardRepository) {
|
||||
* @param accessCode String represent of an access code
|
||||
* @return a new registered Card
|
||||
*/
|
||||
fun registerByAccessCode(accessCode: String?): Card = cardRepo.save(Card().apply {
|
||||
fun registerByAccessCode(accessCode: String): Card = cardRepo.save(Card().apply {
|
||||
luid = accessCode
|
||||
extId = randExtID()
|
||||
registerTime = LocalDateTime.now()
|
||||
|
||||
Reference in New Issue
Block a user