add eventtitle
This commit is contained in:
28
main.go
28
main.go
@@ -13,6 +13,11 @@ import (
|
|||||||
|
|
||||||
func GetDefaultTasks() []Task {
|
func GetDefaultTasks() []Task {
|
||||||
return []Task{
|
return []Task{
|
||||||
|
{
|
||||||
|
Name: "Title",
|
||||||
|
Description: ``,
|
||||||
|
IsOptional: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Name: "Promotion",
|
Name: "Promotion",
|
||||||
Description: `
|
Description: `
|
||||||
@@ -100,17 +105,18 @@ func CreateTasklist(title string, db *sql.DB) Tasklist {
|
|||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
defer stmt.Close()
|
defer stmt.Close()
|
||||||
var promotion, opening, entering, preparekuefa, cookkuefa, cleanup, weeklytoilet string
|
var eventtitle, promotion, opening, entering, preparekuefa, cookkuefa, cleanup, weeklytoilet string
|
||||||
err = stmt.QueryRow(title).Scan(&promotion, &opening, &entering, &preparekuefa, &cookkuefa, &cleanup, &weeklytoilet)
|
err = stmt.QueryRow(title).Scan(&eventtitle, &promotion, &opening, &entering, &preparekuefa, &cookkuefa, &cleanup, &weeklytoilet)
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
tasks[0].Value = promotion
|
tasks[0].Value = eventtitle
|
||||||
tasks[1].Value = opening
|
tasks[1].Value = promotion
|
||||||
tasks[2].Value = entering
|
tasks[2].Value = opening
|
||||||
tasks[3].Value = preparekuefa
|
tasks[3].Value = entering
|
||||||
tasks[4].Value = cookkuefa
|
tasks[4].Value = preparekuefa
|
||||||
tasks[5].Value = cleanup
|
tasks[5].Value = cookkuefa
|
||||||
tasks[6].Value = weeklytoilet
|
tasks[6].Value = cleanup
|
||||||
|
tasks[7].Value = weeklytoilet
|
||||||
}
|
}
|
||||||
|
|
||||||
return Tasklist{
|
return Tasklist{
|
||||||
@@ -129,12 +135,12 @@ func InsertToDB(tasklist Tasklist, db *sql.DB) {
|
|||||||
var name string
|
var name string
|
||||||
err = stmt.QueryRow(tasklist.Title).Scan(&name)
|
err = stmt.QueryRow(tasklist.Title).Scan(&name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
db.Exec("insert into tasklists(name, "+GetTaskNameString(", ")+") values(?, ?, ?, ?, ?, ?, ?, ?)", tasklist.Title, tasklist.Tasks[0].Value, tasklist.Tasks[1].Value, tasklist.Tasks[2].Value, tasklist.Tasks[3].Value, tasklist.Tasks[4].Value, tasklist.Tasks[5].Value, tasklist.Tasks[6].Value)
|
db.Exec("insert into tasklists(name, "+GetTaskNameString(", ")+") values(?, ?, ?, ?, ?, ?, ?, ?, ?)", tasklist.Title, tasklist.Tasks[0].Value, tasklist.Tasks[1].Value, tasklist.Tasks[2].Value, tasklist.Tasks[3].Value, tasklist.Tasks[4].Value, tasklist.Tasks[5].Value, tasklist.Tasks[6].Value, tasklist.Tasks[7].Value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error during insert: ", err)
|
fmt.Println("Error during insert: ", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_, err := db.Exec("update tasklists set "+GetTaskNameString(" = ?,")+" = ? where name = ?", tasklist.Tasks[0].Value, tasklist.Tasks[1].Value, tasklist.Tasks[2].Value, tasklist.Tasks[3].Value, tasklist.Tasks[4].Value, tasklist.Tasks[5].Value, tasklist.Tasks[6].Value, tasklist.Title)
|
_, err := db.Exec("update tasklists set "+GetTaskNameString(" = ?,")+" = ? where name = ?", tasklist.Tasks[0].Value, tasklist.Tasks[1].Value, tasklist.Tasks[2].Value, tasklist.Tasks[3].Value, tasklist.Tasks[4].Value, tasklist.Tasks[5].Value, tasklist.Tasks[6].Value, tasklist.Tasks[7], tasklist.Title)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error during update: ", err)
|
fmt.Println("Error during update: ", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user