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

@@ -1 +1,41 @@
package permissions
import (
"context"
"net/http"
"fr.latosa-escrima/core"
"fr.latosa-escrima/core/models"
)
func HandlePermission(w http.ResponseWriter, r *http.Request) {
id := r.PathValue("permission_id")
var permission models.Permission
count, err := core.DB.NewSelect().
Model(&permission).
Where("id = ?", id).
Limit(1).
ScanAndCount(context.Background())
if count == 0 {
core.JSONSuccess{
Status: core.Success,
Message: "Permission not found.",
}.Respond(w, http.StatusNotFound)
return
}
if err != nil {
core.JSONError{
Status: core.Error,
Message: err.Error(),
}.Respond(w, http.StatusInternalServerError)
return
}
core.JSONSuccess{
Status: core.Success,
Message: "Permission found.",
Data: permission,
}.Respond(w, http.StatusOK)
}