events api file init
This commit is contained in:
36
backend/api/delete_event.go
Normal file
36
backend/api/delete_event.go
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"fr.latosa-escrima/api/core"
|
||||
)
|
||||
|
||||
func HandleDeleteEvent(w http.ResponseWriter, r *http.Request) {
|
||||
uuid := r.PathValue("event_uuid")
|
||||
var event core.Event
|
||||
res, err := core.DB.NewDelete().
|
||||
Model(&event).
|
||||
Where("id = ?", uuid).
|
||||
Returning("*").
|
||||
Exec(context.Background())
|
||||
if err != nil {
|
||||
core.JSONError{
|
||||
Status: core.Error,
|
||||
Message: err.Error(),
|
||||
}.Respond(w, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
log.Println(res)
|
||||
|
||||
// TODO sql request to remove content
|
||||
|
||||
core.JSONSuccess{
|
||||
Status: core.Success,
|
||||
Message: "Event deleted.",
|
||||
}.Respond(w, http.StatusOK)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user