34 lines
633 B
Go
34 lines
633 B
Go
package main
|
|
|
|
import (
|
|
"github.com/labstack/echo"
|
|
"net/http"
|
|
"strconv"
|
|
)
|
|
|
|
func deleteKonfi(c echo.Context) error {
|
|
//Datenbankverbindung aufbauen
|
|
db := DBinit()
|
|
|
|
rw := c.Response()
|
|
r := c.Request()
|
|
|
|
//Session init
|
|
sess := GlobalSessions.SessionStart(rw, r)
|
|
logged := sess.Get("login")
|
|
|
|
//Wenn das password stimmt
|
|
if logged != nil{
|
|
id, _ := strconv.Atoi(c.FormValue("id"))
|
|
|
|
//Löschen
|
|
_, err := db.Id(id).Delete(&Kofi{})
|
|
if err == nil {
|
|
return c.JSON(http.StatusOK, Message{"success"})
|
|
}
|
|
return c.JSON(http.StatusOK, Message{"Error."})
|
|
} else {
|
|
return c.JSON(http.StatusOK, Message{"Login first."})
|
|
}
|
|
}
|