|
@ -1,11 +1,39 @@ |
|
|
package models |
|
|
package models |
|
|
|
|
|
|
|
|
|
|
|
import anorm._ |
|
|
|
|
|
import anorm.SqlParser._ |
|
|
|
|
|
|
|
|
|
|
|
import play.api.db._ |
|
|
|
|
|
import play.api.Play.current |
|
|
|
|
|
|
|
|
case class Task(id:Long, label:String) |
|
|
case class Task(id:Long, label:String) |
|
|
|
|
|
|
|
|
object Task { |
|
|
object Task { |
|
|
def all(): List[Task] = Nil |
|
|
|
|
|
|
|
|
|
|
|
def create(label:String) {} |
|
|
|
|
|
|
|
|
val task = { |
|
|
|
|
|
get[Long]("id") ~ |
|
|
|
|
|
get[String]("label") map { |
|
|
|
|
|
case id~label => Task(id, label) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
def all(): List[Task] = DB.withConnection { implicit c => |
|
|
|
|
|
SQL("select * from task").as(task *) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
def delete(id:Long) {} |
|
|
|
|
|
|
|
|
def create(label:String) { |
|
|
|
|
|
DB.withConnection { implicit c => |
|
|
|
|
|
SQL("insert into task (label) values ({label})").on( |
|
|
|
|
|
'label -> label |
|
|
|
|
|
).executeUpdate() |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
def delete(id:Long) { |
|
|
|
|
|
DB.withConnection { implicit c => |
|
|
|
|
|
SQL("delete from task where id = {id}").on( |
|
|
|
|
|
'id -> id |
|
|
|
|
|
).executeUpdate() |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |