From 25342e97f1e1c1f115d9ba2436a62d63b7079e46 Mon Sep 17 00:00:00 2001 From: neviyn Date: Thu, 29 Apr 2021 00:19:57 +0100 Subject: [PATCH] Added base entities --- src/main/kotlin/uk/co/neviyn/booru/Entity.kt | 58 ++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/main/kotlin/uk/co/neviyn/booru/Entity.kt diff --git a/src/main/kotlin/uk/co/neviyn/booru/Entity.kt b/src/main/kotlin/uk/co/neviyn/booru/Entity.kt new file mode 100644 index 0000000..5c4da6b --- /dev/null +++ b/src/main/kotlin/uk/co/neviyn/booru/Entity.kt @@ -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 = 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 = mutableSetOf(), + @Id open var id: Long = -1 +) + +@Entity +open class Tag( + @Column(unique = true) + open var tag: String = "", + @Id open var id: Long = -1 +) \ No newline at end of file