Added base entities
This commit is contained in:
parent
0d4d5cfefd
commit
25342e97f1
58
src/main/kotlin/uk/co/neviyn/booru/Entity.kt
Normal file
58
src/main/kotlin/uk/co/neviyn/booru/Entity.kt
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
package uk.co.neviyn.booru
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||||
|
import javax.persistence.Column
|
||||||
|
import javax.persistence.Entity
|
||||||
|
import javax.persistence.Id
|
||||||
|
import javax.persistence.JoinColumn
|
||||||
|
import javax.persistence.JoinTable
|
||||||
|
import javax.persistence.ManyToMany
|
||||||
|
import javax.persistence.ManyToOne
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
open class User(
|
||||||
|
@Column(unique = true)
|
||||||
|
open var name: String = "",
|
||||||
|
open var email: String = "",
|
||||||
|
@JsonIgnore
|
||||||
|
open var password: String = "",
|
||||||
|
@ManyToMany
|
||||||
|
@JoinTable(
|
||||||
|
name = "user_roles",
|
||||||
|
joinColumns = [JoinColumn(name = "user_id", referencedColumnName = "id")],
|
||||||
|
inverseJoinColumns = [JoinColumn(name = "role_id", referencedColumnName = "id")]
|
||||||
|
)
|
||||||
|
open var roles: MutableSet<Role> = mutableSetOf(),
|
||||||
|
@Id open var id: Long = -1
|
||||||
|
)
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
open class Role(
|
||||||
|
@Column(unique = true)
|
||||||
|
open var name: String = "",
|
||||||
|
@Id open var id: Long = -1
|
||||||
|
)
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
open class Image(
|
||||||
|
@Column(unique = true)
|
||||||
|
open var filename: String = "",
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "uploader")
|
||||||
|
open var uploader: User = User(),
|
||||||
|
@ManyToMany
|
||||||
|
@JoinTable(
|
||||||
|
name = "tag_image",
|
||||||
|
joinColumns = [JoinColumn(name = "image_id", referencedColumnName = "id")],
|
||||||
|
inverseJoinColumns = [JoinColumn(name = "tag_id", referencedColumnName = "id")]
|
||||||
|
)
|
||||||
|
open var tags: MutableSet<Tag> = mutableSetOf(),
|
||||||
|
@Id open var id: Long = -1
|
||||||
|
)
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
open class Tag(
|
||||||
|
@Column(unique = true)
|
||||||
|
open var tag: String = "",
|
||||||
|
@Id open var id: Long = -1
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user