adder

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CityState

type CityState struct {
	Name  string `json:"name" schema:"city"`
	State string `json:"state" schema:"state"`
}

type ErrDuplicate

type ErrDuplicate struct {
	// contains filtered or unexported fields
}

ErrDuplicate is used when a resturant already exists.

func (*ErrDuplicate) Error

func (m *ErrDuplicate) Error() string

type GmapsPlace

type GmapsPlace struct {
	PlaceID              string  `json:"place_id"`
	BusinessStatus       string  `json:"business_status"`
	FormattedPhoneNumber string  `json:"formatted_phone_number"`
	Name                 string  `json:"name"`
	PriceLevel           int     `json:"price_level"`
	Rating               float32 `json:"rating"`
	URL                  string  `json:"url"`
	UserRatingsTotal     int     `json:"user_ratings_total"`
	UTCOffset            int     `json:"utc_offset"`
	Website              string  `json:"website"`
	RestaurantID         int64   `json:"restaurant_id"`
}

type Map added in v1.0.0

type Map interface {
	PlaceDetails(string) (mapper.PlaceDetail, error)
}

type Repository

type Repository interface {
	Begin()
	Commit()
	Rollback()
	// AddRestaurant saves a given restaurant to the repository.
	AddRestaurant(Restaurant) int64
	// IsDuplicateRestaurant checks if a restaurant with the same name in the same city and state is already in the db
	IsDuplicateRestaurant(Restaurant) bool
	// GetCityIDByNameAndState gets the id of a city with the same name and state from the database
	GetCityIDByNameAndState(string, string) int64
	AddCity(string, string) int64
	AddGmapsPlace(GmapsPlace) int64
	AddVisit(Visit) int64
	AddVisitUser(VisitUser) int64
	GetRestaurant(int64) lister.Restaurant
	GetUser(int64) lister.User
	GetUserBy(string, string) lister.User
	AddUser(User) int64
}

Repository provides access to restaurant repository.

type Restaurant

type Restaurant struct {
	Name           string     `json:"name" schema:"name,required"`
	Cuisine        string     `json:"cuisine" schema:"cuisine,required"`
	BusinessStatus int        `json:"business_status" schema:"businessStatus"`
	Note           string     `json:"note" schema:"note"`
	Address        string     `json:"address" schema:"address"`
	Zipcode        string     `json:"zipcode" schema:"zipCode"`
	CityState      CityState  `json:"city_state" schema:"cityState"`
	Latitude       float32    `json:"latitude" schema:"latitude"`
	Longitude      float32    `json:"longitude" schema:"longitude"`
	GmapsPlace     GmapsPlace `json:"gmaps_place"`
	CityID         int64      `json:"city_id"`
}

type Service

type Service interface {
	AddRestaurant(Restaurant) (int64, error)
	AddVisit(Visit) (int64, error)
	AddUser(User) (int64, error)
}

Service provides adding operations.

func NewService

func NewService(r Repository, m Map) Service

NewService creates an adding service with the necessary dependencies

type User added in v1.0.0

type User struct {
	FirstName      string `json:"first_name" schema:"first,required"`
	LastName       string `json:"last_name" schema:"lastName,required"`
	Email          string `json:"email" schema:"email,required"`
	Password       string `json:"password" schema:"password,required"`
	RepeatPassword string `schema:"repeatPassword,required"`
	PasswordHash   string `schema:"-"`
}

type Visit

type Visit struct {
	RestaurantID  int64       `json:"restaurant_id"`
	VisitDateTime string      `json:"visit_datetime"`
	Note          string      `json:"note"`
	VisitUsers    []VisitUser `json:"visit_users"`
}

type VisitUser

type VisitUser struct {
	VisitID int64
	UserID  int64 `json:"user_id"`
	Rating  int64 `json:"rating"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL