2024-10-10 21:06:50 +00:00
|
|
|
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
|
|
|
|
}
|
2024-10-10 21:15:49 +00:00
|
|
|
func Remove(id int) error {
|
|
|
|
db := database.GetDB()
|
|
|
|
|
|
|
|
_, err := db.NamedExec(
|
|
|
|
`delete from "task" where "id" = :id`, map[string]interface{}{
|
|
|
|
"id": id,
|
|
|
|
})
|
|
|
|
|
|
|
|
return err
|
|
|
|
}
|