Merge branch 'feature/chapters'
This commit is contained in:
commit
a60fc317f3
@ -1,9 +1,13 @@
|
||||
CREATE TABLE `Tags`
|
||||
CREATE TABLE `Chapters`
|
||||
(
|
||||
`id` int PRIMARY KEY AUTO_INCREMENT,
|
||||
`name` varchar(50) NOT NULL,
|
||||
`note_id` int NOT NULL
|
||||
`number` int NOT NULL,
|
||||
`content` text NOT NULL,
|
||||
`note_id` int NOT NULL
|
||||
);
|
||||
|
||||
ALTER TABLE `Tags`
|
||||
ADD FOREIGN KEY (`note_id`) REFERENCES `Notes` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
|
||||
ALTER TABLE `Chapters`
|
||||
ADD FOREIGN KEY (`note_id`) REFERENCES `Notes` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
|
||||
|
||||
ALTER TABLE `Notes`
|
||||
DROP COLUMN `content`;
|
||||
@ -43,7 +43,6 @@ class NoteController(kodein: Kodein) : KodeinController(kodein) {
|
||||
|
||||
val note = Note {
|
||||
this.title = body.title
|
||||
this.content = body.content
|
||||
this.user = user
|
||||
}
|
||||
|
||||
|
||||
12
api/src/entities/Chapter.kt
Normal file
12
api/src/entities/Chapter.kt
Normal file
@ -0,0 +1,12 @@
|
||||
package be.vandewalleh.entities
|
||||
|
||||
import me.liuwj.ktorm.entity.Entity
|
||||
|
||||
interface Chapter : Entity<Chapter> {
|
||||
companion object : Entity.Factory<Chapter>()
|
||||
|
||||
val id: Int
|
||||
var number: Int
|
||||
var content: String
|
||||
var note: Note
|
||||
}
|
||||
@ -8,7 +8,6 @@ interface Note : Entity<Note> {
|
||||
|
||||
val id: Int
|
||||
var title: String
|
||||
var content: String
|
||||
var user: User
|
||||
var lastViewed: LocalDateTime?
|
||||
}
|
||||
15
api/src/tables/Chapters.kt
Normal file
15
api/src/tables/Chapters.kt
Normal file
@ -0,0 +1,15 @@
|
||||
package be.vandewalleh.tables
|
||||
|
||||
import be.vandewalleh.entities.Chapter
|
||||
import be.vandewalleh.entities.Tag
|
||||
import me.liuwj.ktorm.schema.Table
|
||||
import me.liuwj.ktorm.schema.int
|
||||
import me.liuwj.ktorm.schema.text
|
||||
import me.liuwj.ktorm.schema.varchar
|
||||
|
||||
object Chapters : Table<Chapter>("Chapters") {
|
||||
val id by int("id").primaryKey().bindTo { it.id }
|
||||
val number by int("number").bindTo { it.number }
|
||||
val content by text("content").bindTo { it.content }
|
||||
val noteId by int("note_id").references(Notes) { it.note }
|
||||
}
|
||||
@ -6,7 +6,6 @@ import me.liuwj.ktorm.schema.*
|
||||
object Notes : Table<Note>("Notes") {
|
||||
val id by int("id").primaryKey().bindTo { it.id }
|
||||
val title by varchar("title").bindTo { it.title }
|
||||
val content by text("content").bindTo { it.content }
|
||||
val user by int("user_id").references(Users) { it.user }
|
||||
val lastViewed by datetime("last_viewed").bindTo { it.lastViewed }
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user