szoe-pontok/database/task/task.go
2024-10-10 23:15:49 +02:00

30 lines
621 B
Go

package task
import (
"git.tek.govt.hu/dowerx/szoe-pontok/database"
"git.tek.govt.hu/dowerx/szoe-pontok/model"
)
func Add(task model.Task) error {
db := database.GetDB()
_, err := db.NamedExec(
`insert into "task" ("description", "points", "recipient", "issuer") values
(:description, :points,
(select "id" from "user" where "neptun" = :recipient),
(select "id" from "user" where "neptun" = :issuer)
)`, task)
return err
}
func Remove(id int) error {
db := database.GetDB()
_, err := db.NamedExec(
`delete from "task" where "id" = :id`, map[string]interface{}{
"id": id,
})
return err
}