Migrated to nuxt-js frontend framework
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
CREATE TABLE `Tags`
|
||||
(
|
||||
`id` int PRIMARY KEY AUTO_INCREMENT,
|
||||
`name` varchar(50) NOT NULL,
|
||||
`note_id` int NOT NULL
|
||||
);
|
||||
|
||||
ALTER TABLE `Tags`
|
||||
ADD FOREIGN KEY (`note_id`) REFERENCES `Notes` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
|
||||
@@ -38,10 +38,10 @@ fun Application.module() {
|
||||
log.debug(kodein.container.tree.bindings.description())
|
||||
|
||||
// TODO, clean this (migration)
|
||||
val feature: Feature by kodein.instance()
|
||||
val feature by kodein.instance<Feature>()
|
||||
feature.execute()
|
||||
|
||||
val controllers: Set<KodeinController> by kodein.instance()
|
||||
val controllers by kodein.instance<Set<KodeinController>>()
|
||||
|
||||
routing {
|
||||
controllers.forEach {
|
||||
|
||||
@@ -39,21 +39,24 @@ class NoteController(kodein: Kodein) : KodeinController(kodein) {
|
||||
.find { Users.email eq email }
|
||||
?: return@post call.respond(HttpStatusCode.Forbidden, ApiError.DeletedUserError)
|
||||
|
||||
val transaction = db.useTransaction {
|
||||
|
||||
val note = Note {
|
||||
this.title = body.title
|
||||
this.content = body.content
|
||||
this.user = user
|
||||
}
|
||||
|
||||
db.sequenceOf(Notes).add(note)
|
||||
|
||||
body.tags.forEach { tagName ->
|
||||
val tag = Tag {
|
||||
this.name = tagName
|
||||
this.note = note
|
||||
val note = Note {
|
||||
this.title = body.title
|
||||
this.content = body.content
|
||||
this.user = user
|
||||
}
|
||||
db.sequenceOf(Tags).add(tag)
|
||||
|
||||
db.sequenceOf(Notes).add(note)
|
||||
|
||||
body.tags.forEach { tagName ->
|
||||
val tag = Tag {
|
||||
this.name = tagName
|
||||
this.note = note
|
||||
}
|
||||
db.sequenceOf(Tags).add(tag)
|
||||
}
|
||||
1
|
||||
}
|
||||
|
||||
return@post call.respond(Response("created"))
|
||||
|
||||
Reference in New Issue
Block a user