repository

package
v0.0.0-...-30a6304 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPostgresDB

func NewPostgresDB(cfg Config) (*sqlx.DB, error)

Types

type Admin

type Admin interface {
	GetByCredentials(name, password string) (*domain.Admin, error)
}

type AdminPg

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

func NewAdminPg

func NewAdminPg(db *sqlx.DB) *AdminPg

func (*AdminPg) GetByCredentials

func (r *AdminPg) GetByCredentials(name, password string) (*domain.Admin, error)

type Category

type Category interface {
	GetAll(restaurantId int) ([]*domain.Category, error)
	Create(category *domain.Category) (int, error)
	GetById(categoryId int) (*domain.Category, error)
	GetAllItems(categoryId int) ([]*domain.MenuItem, error)
	DeleteCategory(restaurantId int, categoryId int) error
	UpdateCategory(restaurantId int, categoryId int, input *domain.Category) error
}

type CategoryPg

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

func NewCategoryPg

func NewCategoryPg(db *sqlx.DB) *CategoryPg

func (*CategoryPg) Create

func (r *CategoryPg) Create(category *domain.Category) (int, error)

func (*CategoryPg) DeleteCategory

func (r *CategoryPg) DeleteCategory(restaurantId int, categoryId int) error

func (*CategoryPg) GetAll

func (r *CategoryPg) GetAll(restaurantId int) ([]*domain.Category, error)

func (*CategoryPg) GetAllItems

func (r *CategoryPg) GetAllItems(categoryId int) ([]*domain.MenuItem, error)

func (*CategoryPg) GetById

func (r *CategoryPg) GetById(categoryId int) (*domain.Category, error)

func (*CategoryPg) UpdateCategory

func (r *CategoryPg) UpdateCategory(restaurantId int, categoryId int, input *domain.Category) error

type Config

type Config struct {
	Host     string
	Port     string
	Username string
	Password string
	DBName   string
	SSLMode  string
}

type Courier

type Courier interface {
	Create(courier *domain.Courier) (int, error)
	GetByCredentials(phone, password string) (*domain.Courier, error)
	GetById(courierId int) (*domain.Courier, error)
	Update(courierId int, input *domain.Courier) error
}

type CourierPg

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

func NewCourierPg

func NewCourierPg(db *sqlx.DB) *CourierPg

func (*CourierPg) Create

func (r *CourierPg) Create(courier *domain.Courier) (int, error)

func (*CourierPg) GetByCredentials

func (r *CourierPg) GetByCredentials(phone, password string) (*domain.Courier, error)

func (*CourierPg) GetById

func (r *CourierPg) GetById(courierId int) (*domain.Courier, error)

func (*CourierPg) Update

func (r *CourierPg) Update(courierId int, input *domain.Courier) error
type MenuItem interface {
	GetById(menuItemId int) (*domain.MenuItem, error)
	UpdateMenuItem(restaurantId int, menuItemId int, categoryId int, input *domain.MenuItem) error
	Create(menuItem *domain.MenuItem, categoryId int) (int, error)
	UpdateImage(menuItemId int, image string) error
	DeleteItem(menuItemId int) error
}
type MenuItemPg struct {
	// contains filtered or unexported fields
}

func NewMenuItem

func NewMenuItem(db *sqlx.DB) *MenuItemPg
func (r *MenuItemPg) Create(menuItem *domain.MenuItem, categoryId int) (int, error)
func (r *MenuItemPg) DeleteItem(menuItemId int) error
func (r *MenuItemPg) GetById(menuItemId int) (*domain.MenuItem, error)
func (r *MenuItemPg) UpdateImage(menuItemId int, image string) error
func (r *MenuItemPg) UpdateMenuItem(restaurantId int, menuItemId int, categoryId int, input *domain.MenuItem) error

type Order

type Order interface {
	Create(order *domain.Order) (int, error)
	GetById(orderId int) (*domain.Order, error)
	Delete(orderId int) error
	Update(orderId int, input *domain.Order) error
	GetActiveRestaurantOrders(restaurantId int) ([]*domain.Order, error)
	CreateItem(orderItem *domain.OrderItem) (int, error)
	GetAllItems(orderId int) ([]*domain.OrderItem, error)
	GetItemById(orderItemId int) (*domain.OrderItem, error)
	UpdateItem(orderItemId, menuItemsCount int) error
	DeleteItem(orderItemId int, orderId int) error
	GetActiveCourierOrder(courierId int) (*domain.Order, error)
	GetNearestCourierId(userId int) (int, error)
}

type OrderPg

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

func NewOrderPg

func NewOrderPg(db *sqlx.DB) *OrderPg

func (*OrderPg) Create

func (r *OrderPg) Create(order *domain.Order) (int, error)

func (*OrderPg) CreateItem

func (r *OrderPg) CreateItem(orderItem *domain.OrderItem) (int, error)

func (*OrderPg) Delete

func (r *OrderPg) Delete(orderId int) error

func (*OrderPg) DeleteItem

func (r *OrderPg) DeleteItem(orderId int, orderItemId int) error

func (*OrderPg) GetActiveCourierOrder

func (r *OrderPg) GetActiveCourierOrder(courierId int) (*domain.Order, error)

func (*OrderPg) GetActiveRestaurantOrders

func (r *OrderPg) GetActiveRestaurantOrders(restaurantId int) ([]*domain.Order, error)

func (*OrderPg) GetAllItems

func (r *OrderPg) GetAllItems(orderId int) ([]*domain.OrderItem, error)

func (*OrderPg) GetById

func (r *OrderPg) GetById(orderId int) (*domain.Order, error)

func (*OrderPg) GetItemById

func (r *OrderPg) GetItemById(orderItemId int) (*domain.OrderItem, error)

func (*OrderPg) GetNearestCourierId

func (r *OrderPg) GetNearestCourierId(userId int) (int, error)

TODO: стоит вынести в репозиторий курьера

func (*OrderPg) Update

func (r *OrderPg) Update(orderId int, input *domain.Order) error

func (*OrderPg) UpdateItem

func (r *OrderPg) UpdateItem(orderItemId, menuItemsCount int) error

type Repository

type Repository struct {
	Admin
	User
	Courier
	Restaurant
	Category
	Order
	MenuItem
}

func NewRepository

func NewRepository(db *sqlx.DB) *Repository

type Restaurant

type Restaurant interface {
	GetByCredentials(phone, password string) (*domain.Restaurant, error)
	GetAll(userId int) ([]*domain.Restaurant, error)
	GetById(restaurantId int) (*domain.Restaurant, error)
	GetMenu(restaurantId int) ([]*domain.MenuItem, error)
	Create(restaurant *domain.Restaurant) (int, error)
	UpdateImage(restaurantId int, image string) error
	Update(restaurantId int, input *domain.Restaurant) error
}

type RestaurantPg

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

func NewRestaurantPg

func NewRestaurantPg(db *sqlx.DB) *RestaurantPg

func (*RestaurantPg) Create

func (r *RestaurantPg) Create(restaurant *domain.Restaurant) (int, error)

func (*RestaurantPg) GetAll

func (r *RestaurantPg) GetAll(userId int) ([]*domain.Restaurant, error)

func (*RestaurantPg) GetByCredentials

func (r *RestaurantPg) GetByCredentials(phone, password string) (*domain.Restaurant, error)

func (*RestaurantPg) GetById

func (r *RestaurantPg) GetById(restaurantId int) (*domain.Restaurant, error)

func (*RestaurantPg) GetMenu

func (r *RestaurantPg) GetMenu(restarauntId int) ([]*domain.MenuItem, error)

func (*RestaurantPg) Update

func (r *RestaurantPg) Update(restaurantId int, input *domain.Restaurant) error

func (*RestaurantPg) UpdateImage

func (r *RestaurantPg) UpdateImage(restaurantId int, image string) error

type User

type User interface {
	Create(user *domain.User) (int, error)
	GetByCredentials(phone, password string) (*domain.User, error)
	GetAllOrders(userId int, activeOrdersFlag bool) ([]*domain.Order, error)
	Update(userId int, input *domain.User) error
	GetById(userId int) (*domain.User, error)
}

type UserPg

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

func NewUserPg

func NewUserPg(db *sqlx.DB) *UserPg

func (*UserPg) Create

func (r *UserPg) Create(user *domain.User) (int, error)

func (*UserPg) GetAllOrders

func (r *UserPg) GetAllOrders(userId int, activeOrdersFlag bool) ([]*domain.Order, error)

func (*UserPg) GetByCredentials

func (r *UserPg) GetByCredentials(phone, password string) (*domain.User, error)

func (*UserPg) GetById

func (r *UserPg) GetById(userId int) (*domain.User, error)

func (*UserPg) Update

func (r *UserPg) Update(userId int, input *domain.User) error

Jump to

Keyboard shortcuts

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