Reorganization of backend + new routes

This commit is contained in:
cdricms
2025-01-29 18:09:41 +01:00
parent 7c66353e63
commit 8110172a38
67 changed files with 1124 additions and 400 deletions

View File

@@ -2,15 +2,15 @@ package events
import (
"context"
"fmt"
"net/http"
core "fr.latosa-escrima/api/core"
core "fr.latosa-escrima/core"
"fr.latosa-escrima/core/models"
)
func HandleEvent(w http.ResponseWriter, r *http.Request) {
event_uuid := r.PathValue("event_uuid")
var event core.Event
var event models.Event
_, err := core.DB.NewSelect().Model(&event).Where("uuid = ?", event_uuid).ScanAndCount(context.Background())
if err != nil {
core.JSONError{
@@ -27,22 +27,3 @@ func HandleEvent(w http.ResponseWriter, r *http.Request) {
}.Respond(w, http.StatusOK)
return
}
func HandleEvents(w http.ResponseWriter, r *http.Request) {
var events []core.Event
rowsCount, err := core.DB.NewSelect().Model(&events).ScanAndCount(context.Background())
if err != nil {
core.JSONError{
Status: core.Error,
Message: err.Error(),
}.Respond(w, http.StatusInternalServerError)
return
}
core.JSONSuccess{
Status: core.Success,
Message: fmt.Sprintf("%d Event successfully sent", rowsCount),
Data: events,
}.Respond(w, http.StatusOK)
return
}