1
0
forked from zv0n/lunch-go

Add id to restaurant

This commit is contained in:
zvon 2023-08-25 17:43:15 +02:00
parent 82bf2a1ea4
commit 07b6b6722d
3 changed files with 7 additions and 18 deletions

View File

@ -15,17 +15,10 @@ type FreshRestaurant struct {
Restaurant
}
func MakeFreshRestaurant(url string, name string) FreshRestaurant {
restaurant := FreshRestaurant{}
restaurant.SetDefaultValues()
restaurant.url = url
restaurant.name = name
return restaurant
}
func NewFreshRestaurant(url string, name string) *FreshRestaurant {
func NewFreshRestaurant(url string, name string, id int) *FreshRestaurant {
restaurant := new(FreshRestaurant)
restaurant.SetDefaultValues()
restaurant.id = id
restaurant.url = url
restaurant.name = name
return restaurant

View File

@ -14,17 +14,10 @@ type MenickaRestaurant struct {
Restaurant
}
func MakeMenickaRestaurant(url string, name string) MenickaRestaurant {
restaurant := MenickaRestaurant{}
restaurant.SetDefaultValues()
restaurant.url = url
restaurant.name = name
return restaurant
}
func NewMenickaRestaurant(url string, name string) *MenickaRestaurant {
func NewMenickaRestaurant(url string, name string, id int) *MenickaRestaurant {
restaurant := new(MenickaRestaurant)
restaurant.SetDefaultValues()
restaurant.id = id
restaurant.url = url
restaurant.name = name
return restaurant

View File

@ -16,6 +16,7 @@ type RestaurantInterface interface {
type Restaurant struct {
RestaurantInterface
id int
url string
name string
menus [7]Menu
@ -23,6 +24,7 @@ type Restaurant struct {
}
type RestaurantJSON struct {
Id int `json:"id"`
Restaurant string `json:"restaurant"`
DailyMenus []Menu `json:"dailymenus"`
PermanentMeals []Meal `json:"permanentmeals"`
@ -55,6 +57,7 @@ func (restaurant *Restaurant) clearMenus() {
func (restaurant *Restaurant) MarshalJSON() ([]byte, error) {
return json.Marshal(&RestaurantJSON{
Id: restaurant.id,
Restaurant: restaurant.name,
DailyMenus: restaurant.menus[:],
PermanentMeals: restaurant.permanent,