mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-10 05:07:27 +08:00
[+] AquaNetUser JPA entity
This commit is contained in:
42
src/main/java/icu/samnyan/aqua/net/db/AquaNetUser.kt
Normal file
42
src/main/java/icu/samnyan/aqua/net/db/AquaNetUser.kt
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
package icu.samnyan.aqua.net.db
|
||||||
|
|
||||||
|
import icu.samnyan.aqua.sega.general.model.Card
|
||||||
|
import jakarta.persistence.*
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
|
import org.springframework.stereotype.Repository
|
||||||
|
import java.io.Serializable
|
||||||
|
|
||||||
|
@Entity(name = "AquaNetUser")
|
||||||
|
@Table(name = "aqua_net_user")
|
||||||
|
class AquaNetUser(
|
||||||
|
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
var auId: Int = 0,
|
||||||
|
|
||||||
|
// Login credentials
|
||||||
|
@Column(nullable = false, unique = true) var email: String = "",
|
||||||
|
var pwHash: String = "",
|
||||||
|
|
||||||
|
var displayName: String = "",
|
||||||
|
|
||||||
|
// Country code at most 3 characters
|
||||||
|
@Column(length = 3) var country: String = "",
|
||||||
|
|
||||||
|
// Last login time
|
||||||
|
var lastLogin: Long = 0L,
|
||||||
|
|
||||||
|
// Registration time
|
||||||
|
var regTime: Long = 0L,
|
||||||
|
|
||||||
|
// Profile fields
|
||||||
|
var profileLocation: String = "",
|
||||||
|
var profileBio: String = "",
|
||||||
|
|
||||||
|
// One user can have multiple cards
|
||||||
|
@OneToMany(mappedBy = "aquaNetUser", cascade = [CascadeType.ALL])
|
||||||
|
var cards: MutableList<Card> = mutableListOf()
|
||||||
|
) : Serializable
|
||||||
|
|
||||||
|
@Repository("AquaNetUserRepository")
|
||||||
|
interface AquaNetUserRepo : JpaRepository<AquaNetUser, Int> {
|
||||||
|
fun existsByEmail(email: String): Boolean
|
||||||
|
}
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
package icu.samnyan.aqua.sega.general.model;
|
package icu.samnyan.aqua.sega.general.model;
|
||||||
|
|
||||||
|
import icu.samnyan.aqua.net.db.AquaNetUser;
|
||||||
|
import jakarta.persistence.*;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@@ -18,6 +20,7 @@ import java.time.LocalDateTime;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class Card implements Serializable {
|
public class Card implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@@ -38,4 +41,8 @@ public class Card implements Serializable {
|
|||||||
@Column(name = "access_time")
|
@Column(name = "access_time")
|
||||||
private LocalDateTime accessTime;
|
private LocalDateTime accessTime;
|
||||||
|
|
||||||
|
// Defines the AquaNet user that this card is bound to
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "net_user_id")
|
||||||
|
private AquaNetUser aquaUser;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user