forked from zv0n/lunch-go
Add id to restaurant
This commit is contained in:
parent
82bf2a1ea4
commit
07b6b6722d
@ -15,17 +15,10 @@ type FreshRestaurant struct {
|
|||||||
Restaurant
|
Restaurant
|
||||||
}
|
}
|
||||||
|
|
||||||
func MakeFreshRestaurant(url string, name string) FreshRestaurant {
|
func NewFreshRestaurant(url string, name string, id int) *FreshRestaurant {
|
||||||
restaurant := FreshRestaurant{}
|
|
||||||
restaurant.SetDefaultValues()
|
|
||||||
restaurant.url = url
|
|
||||||
restaurant.name = name
|
|
||||||
return restaurant
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewFreshRestaurant(url string, name string) *FreshRestaurant {
|
|
||||||
restaurant := new(FreshRestaurant)
|
restaurant := new(FreshRestaurant)
|
||||||
restaurant.SetDefaultValues()
|
restaurant.SetDefaultValues()
|
||||||
|
restaurant.id = id
|
||||||
restaurant.url = url
|
restaurant.url = url
|
||||||
restaurant.name = name
|
restaurant.name = name
|
||||||
return restaurant
|
return restaurant
|
||||||
|
@ -14,17 +14,10 @@ type MenickaRestaurant struct {
|
|||||||
Restaurant
|
Restaurant
|
||||||
}
|
}
|
||||||
|
|
||||||
func MakeMenickaRestaurant(url string, name string) MenickaRestaurant {
|
func NewMenickaRestaurant(url string, name string, id int) *MenickaRestaurant {
|
||||||
restaurant := MenickaRestaurant{}
|
|
||||||
restaurant.SetDefaultValues()
|
|
||||||
restaurant.url = url
|
|
||||||
restaurant.name = name
|
|
||||||
return restaurant
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewMenickaRestaurant(url string, name string) *MenickaRestaurant {
|
|
||||||
restaurant := new(MenickaRestaurant)
|
restaurant := new(MenickaRestaurant)
|
||||||
restaurant.SetDefaultValues()
|
restaurant.SetDefaultValues()
|
||||||
|
restaurant.id = id
|
||||||
restaurant.url = url
|
restaurant.url = url
|
||||||
restaurant.name = name
|
restaurant.name = name
|
||||||
return restaurant
|
return restaurant
|
||||||
|
@ -16,6 +16,7 @@ type RestaurantInterface interface {
|
|||||||
|
|
||||||
type Restaurant struct {
|
type Restaurant struct {
|
||||||
RestaurantInterface
|
RestaurantInterface
|
||||||
|
id int
|
||||||
url string
|
url string
|
||||||
name string
|
name string
|
||||||
menus [7]Menu
|
menus [7]Menu
|
||||||
@ -23,6 +24,7 @@ type Restaurant struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type RestaurantJSON struct {
|
type RestaurantJSON struct {
|
||||||
|
Id int `json:"id"`
|
||||||
Restaurant string `json:"restaurant"`
|
Restaurant string `json:"restaurant"`
|
||||||
DailyMenus []Menu `json:"dailymenus"`
|
DailyMenus []Menu `json:"dailymenus"`
|
||||||
PermanentMeals []Meal `json:"permanentmeals"`
|
PermanentMeals []Meal `json:"permanentmeals"`
|
||||||
@ -55,6 +57,7 @@ func (restaurant *Restaurant) clearMenus() {
|
|||||||
|
|
||||||
func (restaurant *Restaurant) MarshalJSON() ([]byte, error) {
|
func (restaurant *Restaurant) MarshalJSON() ([]byte, error) {
|
||||||
return json.Marshal(&RestaurantJSON{
|
return json.Marshal(&RestaurantJSON{
|
||||||
|
Id: restaurant.id,
|
||||||
Restaurant: restaurant.name,
|
Restaurant: restaurant.name,
|
||||||
DailyMenus: restaurant.menus[:],
|
DailyMenus: restaurant.menus[:],
|
||||||
PermanentMeals: restaurant.permanent,
|
PermanentMeals: restaurant.permanent,
|
||||||
|
Loading…
Reference in New Issue
Block a user