feat: add universities and restaurants
This commit is contained in:
@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.bissendorf.co/bissendorf/unifood/m/v2/core/handler"
|
||||
"git.bissendorf.co/bissendorf/unifood/m/v2/core/interfaces"
|
||||
"git.bissendorf.co/bissendorf/unifood/m/v2/core/interfaces/params"
|
||||
"git.bissendorf.co/bissendorf/unifood/m/v2/model/external/stwbremen"
|
||||
@ -19,20 +20,15 @@ type MealsHandler struct {
|
||||
QueryClient interfaces.QueryClient[[]stwbremen.Meal]
|
||||
}
|
||||
|
||||
const (
|
||||
paramDate = "date"
|
||||
paramLocation = "location"
|
||||
)
|
||||
|
||||
func (h *MealsHandler) Get(ctx context.Context, params params.Container) (*interfaces.ResourceList, error) {
|
||||
func (h *MealsHandler) Get(ctx context.Context, name string, params params.Container) (*interfaces.ResourceList, error) {
|
||||
// Read parameters
|
||||
p, err := params.GetValue(paramDate)
|
||||
p, err := params.GetValue(handler.ParamDate)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to parse date parameter: %w", err)
|
||||
}
|
||||
date := p.(time.Time)
|
||||
|
||||
location, err := params.GetValue(paramLocation)
|
||||
location, err := params.GetValue(handler.ParamLocation)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to parse location parameter: %w", err)
|
||||
}
|
||||
@ -72,16 +68,16 @@ func (h *MealsHandler) Get(ctx context.Context, params params.Container) (*inter
|
||||
func (h *MealsHandler) GetParametersForVerb(verb interfaces.Verb) []params.Registration {
|
||||
return []params.Registration{
|
||||
{
|
||||
Name: paramDate,
|
||||
Name: handler.ParamDate,
|
||||
ShortHand: "d",
|
||||
Description: "Menu date",
|
||||
Description: "Meal date",
|
||||
DefaultFunc: func() string { return time.Now().Format(time.DateOnly) },
|
||||
ParseFunc: func(value string) (any, error) { return time.Parse(time.DateOnly, value) },
|
||||
},
|
||||
{
|
||||
Name: paramLocation,
|
||||
Name: handler.ParamLocation,
|
||||
ShortHand: "l",
|
||||
Description: "Define the restaurant",
|
||||
Description: "Select a restaurant",
|
||||
DefaultFunc: func() string { return "330" },
|
||||
ParseFunc: params.ParseString,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user