feat: add universities and restaurants (#4)
Features: - Allow to search for individual resources by their name - Add new resources and their handler: Universities, Restaurants - Added new parameter to reverse output order Reviewed-on: #4 Co-authored-by: bdoerfchen <git@bissendorf.co> Co-committed-by: bdoerfchen <git@bissendorf.co>
This commit is contained in:
@ -55,9 +55,10 @@ type ingredient struct {
|
||||
Additionals []string
|
||||
}
|
||||
|
||||
func (d *Meal) Kind() string { return ResourceMeal }
|
||||
func (d *Meal) Name() string { return d.Title }
|
||||
func (d *Meal) Kind() string { return ResourceMeal }
|
||||
func (d *Meal) ItemName() string { return d.Title }
|
||||
|
||||
// Table output
|
||||
func (d *Meal) ColumnNames() []string { return []string{"Location", "Date", "Counter", "Price"} }
|
||||
func (d *Meal) Columns() []any {
|
||||
return []any{d.Location, d.Date.Format(time.DateOnly), d.Counter, d.Prices["Studierende"]}
|
||||
|
||||
@ -10,9 +10,10 @@ type Resource struct {
|
||||
Description string
|
||||
}
|
||||
|
||||
func (r *Resource) Kind() string { return ResourceResource }
|
||||
func (r *Resource) Name() string { return r.ResourceName }
|
||||
func (r *Resource) Kind() string { return ResourceResource }
|
||||
func (r *Resource) ItemName() string { return r.ResourceName }
|
||||
|
||||
// Table output
|
||||
func (r *Resource) ColumnNames() []string { return []string{"Aliases", "Description"} }
|
||||
func (r *Resource) Columns() []any {
|
||||
return []any{strings.Join(r.Aliases, ", "), r.Description}
|
||||
|
||||
21
model/resources/restaurant.go
Normal file
21
model/resources/restaurant.go
Normal file
@ -0,0 +1,21 @@
|
||||
package resources
|
||||
|
||||
const ResourceRestaurant = "restaurant"
|
||||
|
||||
type Restaurant struct {
|
||||
Name string
|
||||
Title string
|
||||
ID string
|
||||
Address string
|
||||
Image string
|
||||
OpeningHours any
|
||||
}
|
||||
|
||||
func (r *Restaurant) Kind() string { return ResourceRestaurant }
|
||||
func (r *Restaurant) ItemName() string { return r.Name }
|
||||
|
||||
// Table output
|
||||
func (r *Restaurant) ColumnNames() []string { return []string{"ID", "Title"} }
|
||||
func (r *Restaurant) Columns() []any {
|
||||
return []any{r.ID, r.Title}
|
||||
}
|
||||
19
model/resources/university.go
Normal file
19
model/resources/university.go
Normal file
@ -0,0 +1,19 @@
|
||||
package resources
|
||||
|
||||
import "strings"
|
||||
|
||||
const ResourceUniversity = "university"
|
||||
|
||||
type University struct {
|
||||
Name string
|
||||
Restaurants []string
|
||||
}
|
||||
|
||||
func (u *University) Kind() string { return ResourceUniversity }
|
||||
func (u *University) ItemName() string { return u.Name }
|
||||
|
||||
// Table output
|
||||
func (u *University) ColumnNames() []string { return []string{"Restaurants"} }
|
||||
func (u *University) Columns() []any {
|
||||
return []any{strings.Join(u.Restaurants, "\r\n")}
|
||||
}
|
||||
Reference in New Issue
Block a user