FEATURE: Add Route for Public Event Info
This commit is contained in:
parent
f814888f1e
commit
407deace22
4 changed files with 24 additions and 1 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"strconv"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/jinzhu/copier"
|
||||
"ulmer-furs.de/pretix-proxy/v2/app/service"
|
||||
"ulmer-furs.de/pretix-proxy/v2/app/util"
|
||||
"ulmer-furs.de/pretix-proxy/v2/entities"
|
||||
|
@ -32,6 +33,20 @@ func ReturnAllEvents(c *fiber.Ctx) error {
|
|||
return c.SendStatus(200)
|
||||
}
|
||||
|
||||
func ReturnAllEventsPublic(c *fiber.Ctx) error {
|
||||
events, err := service.Get_all_db_event()
|
||||
if err != nil {
|
||||
return c.Status(500).SendString("Internal Server Error")
|
||||
}
|
||||
publicEvets := new([]entities.Db_Event_Public)
|
||||
err = copier.Copy(publicEvets, events)
|
||||
if err != nil {
|
||||
return c.Status(500).SendString("Internal Server Error")
|
||||
}
|
||||
c.JSON(publicEvets)
|
||||
return c.SendStatus(fiber.StatusOK)
|
||||
}
|
||||
|
||||
func ReturnEventById(c *fiber.Ctx) error {
|
||||
id := c.Params("id")
|
||||
id_int, err := strconv.Atoi(id)
|
||||
|
|
|
@ -6,9 +6,10 @@ import (
|
|||
)
|
||||
|
||||
func PublicRoutes(app *fiber.App) {
|
||||
apiv1 := app.Group("/api/v1")
|
||||
apiv1 := app.Group("/api/v1/public")
|
||||
attendies := apiv1.Group("/attendies")
|
||||
apiv1.Post("/login", controller.LoginUser)
|
||||
apiv1.Get("/event", controller.ReturnAllEventsPublic)
|
||||
apiv1.Get("/ping", controller.Ping)
|
||||
attendies.Get("/:name", controller.GetAttendiesByEvent)
|
||||
}
|
||||
|
|
|
@ -19,3 +19,9 @@ type Db_Event struct {
|
|||
OptionIdSpecialAnimal string `gorm:"column:option_id_special_animal;not null" validate:"required_if=EnforceRequired true"`
|
||||
EnforceRequired bool `gorm:"-"`
|
||||
}
|
||||
|
||||
type Db_Event_Public struct {
|
||||
Name string
|
||||
Organizer string
|
||||
Event string
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ require (
|
|||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/gofiber/contrib/jwt v1.0.7 // indirect
|
||||
github.com/golang-jwt/jwt/v5 v5.1.0 // indirect
|
||||
github.com/jinzhu/copier v0.4.0 // indirect
|
||||
github.com/leodido/go-urn v1.2.4 // indirect
|
||||
golang.org/x/crypto v0.15.0 // indirect
|
||||
golang.org/x/net v0.10.0 // indirect
|
||||
|
|
Loading…
Reference in a new issue