feat: 完成数据库实体类定义
parent
7f7e32db59
commit
254e76435a
|
@ -0,0 +1,22 @@
|
||||||
|
package cn.edu.hfut.auto.knowledge.entity
|
||||||
|
|
||||||
|
import org.babyfish.jimmer.sql.Entity
|
||||||
|
import org.babyfish.jimmer.sql.GeneratedValue
|
||||||
|
import org.babyfish.jimmer.sql.Id
|
||||||
|
import org.babyfish.jimmer.sql.ManyToOne
|
||||||
|
import org.babyfish.jimmer.sql.meta.UUIDIdGenerator
|
||||||
|
import java.time.LocalDateTime
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
interface Comment {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(generatorType = UUIDIdGenerator::class)
|
||||||
|
val id: UUID
|
||||||
|
val content: String
|
||||||
|
@ManyToOne
|
||||||
|
val author: User
|
||||||
|
@ManyToOne
|
||||||
|
val note: Note
|
||||||
|
val createTime: LocalDateTime
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package cn.edu.hfut.auto.knowledge.entity
|
||||||
|
|
||||||
|
import org.babyfish.jimmer.sql.*
|
||||||
|
import org.babyfish.jimmer.sql.kt.fetcher.newFetcher
|
||||||
|
import org.babyfish.jimmer.sql.meta.UUIDIdGenerator
|
||||||
|
import java.time.LocalDateTime
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
interface Knowledge {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(generatorType = UUIDIdGenerator::class)
|
||||||
|
val id: UUID
|
||||||
|
@Key
|
||||||
|
val name: String
|
||||||
|
val createTime: LocalDateTime
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@Key
|
||||||
|
val parent: Knowledge?
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "parent")
|
||||||
|
val children: List<Knowledge>
|
||||||
|
|
||||||
|
@OneToOne(mappedBy = "knowledge")
|
||||||
|
val knowledgeFileAttribute: KnowledgeFileAttribute?
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val BRIEF_FETCHER = newFetcher(Knowledge::class).by {
|
||||||
|
allScalarFields()
|
||||||
|
knowledgeFileAttribute()
|
||||||
|
}
|
||||||
|
val AS_PARENT_FETCHER = newFetcher(Knowledge::class).by {
|
||||||
|
allScalarFields()
|
||||||
|
children(BRIEF_FETCHER)
|
||||||
|
knowledgeFileAttribute()
|
||||||
|
}
|
||||||
|
val AS_CHILD_FETCHER = newFetcher(Knowledge::class).by {
|
||||||
|
allScalarFields()
|
||||||
|
parent(BRIEF_FETCHER)
|
||||||
|
knowledgeFileAttribute()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package cn.edu.hfut.auto.knowledge.entity
|
||||||
|
|
||||||
|
import org.babyfish.jimmer.sql.*
|
||||||
|
import org.babyfish.jimmer.sql.meta.UUIDIdGenerator
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
interface KnowledgeFileAttribute {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(generatorType = UUIDIdGenerator::class)
|
||||||
|
val id: UUID
|
||||||
|
val suffix: String
|
||||||
|
val size: Long
|
||||||
|
val brief: String
|
||||||
|
val pageView: Long
|
||||||
|
|
||||||
|
@OneToOne
|
||||||
|
val knowledge: Knowledge
|
||||||
|
|
||||||
|
@ManyToMany
|
||||||
|
@JoinTable
|
||||||
|
val tags: List<Tag>
|
||||||
|
|
||||||
|
@ManyToMany
|
||||||
|
@JoinTable(name = "knowledge_file_attribute_starer_mapping")
|
||||||
|
val starers: List<User>
|
||||||
|
|
||||||
|
@ManyToMany(mappedBy = "knowledgeFiles")
|
||||||
|
val notes: List<Note>
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package cn.edu.hfut.auto.knowledge.entity
|
||||||
|
|
||||||
|
import org.babyfish.jimmer.sql.*
|
||||||
|
import org.babyfish.jimmer.sql.meta.UUIDIdGenerator
|
||||||
|
import java.time.LocalDateTime
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
interface Note {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(generatorType = UUIDIdGenerator::class)
|
||||||
|
val id: UUID
|
||||||
|
val title: String
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
val author: User
|
||||||
|
val createTime: LocalDateTime
|
||||||
|
val updateTime: LocalDateTime
|
||||||
|
val pageView: Long
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "note")
|
||||||
|
val comments: List<Comment>
|
||||||
|
|
||||||
|
@ManyToMany
|
||||||
|
@JoinTable
|
||||||
|
val tags: List<Tag>
|
||||||
|
|
||||||
|
@ManyToMany
|
||||||
|
@JoinTable(name = "note_knowledge_file_mapping")
|
||||||
|
val knowledgeFiles: List<KnowledgeFileAttribute>
|
||||||
|
|
||||||
|
@ManyToMany
|
||||||
|
@JoinTable(name = "note_starer_mapping")
|
||||||
|
val starers: List<User>
|
||||||
|
|
||||||
|
@ManyToMany
|
||||||
|
@JoinTable(name = "note_liker_mapping")
|
||||||
|
val likers: List<User>
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package cn.edu.hfut.auto.knowledge.entity
|
||||||
|
|
||||||
|
import org.babyfish.jimmer.sql.Entity
|
||||||
|
import org.babyfish.jimmer.sql.GeneratedValue
|
||||||
|
import org.babyfish.jimmer.sql.Id
|
||||||
|
import org.babyfish.jimmer.sql.ManyToOne
|
||||||
|
import org.babyfish.jimmer.sql.meta.UUIDIdGenerator
|
||||||
|
import java.time.LocalDateTime
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
interface Notice {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(generatorType = UUIDIdGenerator::class)
|
||||||
|
val id: UUID
|
||||||
|
val viewed: Boolean
|
||||||
|
val createTime: LocalDateTime
|
||||||
|
@ManyToOne
|
||||||
|
val note: Note
|
||||||
|
@ManyToOne
|
||||||
|
val comment: Comment
|
||||||
|
@ManyToOne
|
||||||
|
val targetUser: User
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package cn.edu.hfut.auto.knowledge.entity
|
||||||
|
|
||||||
|
import org.babyfish.jimmer.sql.Entity
|
||||||
|
import org.babyfish.jimmer.sql.GeneratedValue
|
||||||
|
import org.babyfish.jimmer.sql.GenerationType
|
||||||
|
import org.babyfish.jimmer.sql.Id
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
interface Tag {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
val id: Long
|
||||||
|
val name: String
|
||||||
|
}
|
|
@ -9,9 +9,23 @@ interface User {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
val id: Long
|
val id: Long
|
||||||
|
|
||||||
@Key
|
@Key
|
||||||
val username: String
|
val username: String
|
||||||
|
|
||||||
@get:JsonIgnore
|
@get:JsonIgnore
|
||||||
val password: String
|
val password: String
|
||||||
val level: Short
|
val level: Short
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "author")
|
||||||
|
val notes: List<Note>
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "targetUser")
|
||||||
|
val notices: List<Notice>
|
||||||
|
|
||||||
|
@ManyToMany(mappedBy = "starers")
|
||||||
|
val starredKnowledge: List<KnowledgeFileAttribute>
|
||||||
|
|
||||||
|
@ManyToMany(mappedBy = "starers")
|
||||||
|
val starredNotes: List<Note>
|
||||||
}
|
}
|
Loading…
Reference in New Issue