service

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

This section is empty.

Types

type Admin

type Admin interface {
	SignIn(name, password string) (*Tokens, error)
}

type AdminService

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

func NewAdminService

func NewAdminService(repo repository.Admin, tokenManager auth.TokenManager, accessTokenTTL time.Duration) *AdminService

func (*AdminService) SignIn

func (s *AdminService) SignIn(name, password string) (*Tokens, error)

type Category

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

type CategoryService

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

func NewCategoryService

func NewCategoryService(repo repository.Category) *CategoryService

func (*CategoryService) Create

func (s *CategoryService) Create(clientId int, clientType string, category *domain.Category) (int, error)

func (*CategoryService) DeleteCategory

func (s *CategoryService) DeleteCategory(clientId int, clientType string, restaurantId int, categoryId int) error

func (*CategoryService) GetAll

func (s *CategoryService) GetAll(clientId int, clientType string, restaurantId int) ([]*domain.Category, error)

func (*CategoryService) GetAllItems

func (s *CategoryService) GetAllItems(clientId int, clientType string, restaurantId int, categoryId int) ([]*domain.MenuItem, error)

func (*CategoryService) GetById

func (s *CategoryService) GetById(clientId int, clientType string, restaurantId int, categoryId int) (*domain.Category, error)

func (*CategoryService) UpdateCategory

func (s *CategoryService) UpdateCategory(clientId int, clientType string, restaurantId int, categoryId int, input *domain.Category) error

type Courier

type Courier interface {
	SignIn(phone, password string) (*Tokens, error)
	SignUp(courier *domain.Courier, clientType string) (int, error)
	GetById(clientId int, clientType string, courierId int) (*domain.Courier, error)
	Update(clientId int, clientType string, courierId int, input *domain.Courier) error
}

type CourierService

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

func NewCourierService

func NewCourierService(repo repository.Courier, orderRepo repository.Order, tokenManager auth.TokenManager, accessTokenTTL time.Duration) *CourierService

func (*CourierService) GetById

func (s *CourierService) GetById(clientId int, clientType string, courierId int) (*domain.Courier, error)

func (*CourierService) SignIn

func (s *CourierService) SignIn(phone, password string) (*Tokens, error)

func (*CourierService) SignUp

func (s *CourierService) SignUp(courier *domain.Courier, clientType string) (int, error)

func (*CourierService) Update

func (s *CourierService) Update(clientId int, clientType string, courierId int, input *domain.Courier) error

type Deps

type Deps struct {
	Repos          *repository.Repository
	TokenManager   auth.TokenManager
	AccessTokenTTL time.Duration
}
type MenuItem interface {
	GetById(clientId int, clientType string, menuItemId int, restaurantId int) (*domain.MenuItem, error)
	UpdateMenuItem(clientId int, clientType string, restaurantId int, menuItemId int, categoryId int, input *domain.MenuItem) error
	Create(clientId int, clientType string, menuItem *domain.MenuItem, categoryId int) (int, error)
	UpdateImage(clientId int, clientType string, restaurantId int, menuItemId int, image string) (*domain.MenuItem, error)
	Delete(clientId int, clientType string, restaurantId int, menuItemId int) error
}
type MenuItemService struct {
	// contains filtered or unexported fields
}

func NewMenuItemService

func NewMenuItemService(repo repository.MenuItem, categoryRepo repository.Category) *MenuItemService
func (s *MenuItemService) Create(clientId int, clientType string, menuItem *domain.MenuItem, categoryId int) (int, error)
func (s *MenuItemService) Delete(clientId int, clientType string, restaurantId int, menuItemId int) error
func (s *MenuItemService) GetById(clientId int, clientType string, menuItemId int, restaurantId int) (*domain.MenuItem, error)
func (s *MenuItemService) UpdateImage(clientId int, clientType string, restaurantId int, menuItemId int, image string) (*domain.MenuItem, error)
func (s *MenuItemService) UpdateMenuItem(clientId int, clientType string, restaurantId int, menuItemId int, categoryId int, input *domain.MenuItem) error

type Order

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

type OrderService

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

func NewOrderService

func NewOrderService(repo repository.Order) *OrderService

func (*OrderService) Create

func (s *OrderService) Create(clientId int, clientType string, order *domain.Order) (int, error)

func (*OrderService) CreateItem

func (s *OrderService) CreateItem(clientId int, clientType string, orderItem *domain.OrderItem) (int, error)

func (*OrderService) Delete

func (s *OrderService) Delete(clientId int, clientType string, orderId int) error

func (*OrderService) DeleteItem

func (s *OrderService) DeleteItem(clientId int, clientType string, orderId int, orderItemId int) error

func (*OrderService) GetActiveCourierOrder

func (s *OrderService) GetActiveCourierOrder(clientId int, clientType string, courierId int) (*domain.Order, error)

func (*OrderService) GetActiveRestaurantOrders

func (s *OrderService) GetActiveRestaurantOrders(clientId int, clientType string, restaurantId int) ([]*domain.Order, error)

func (*OrderService) GetAllItems

func (s *OrderService) GetAllItems(clientId int, clientType string, orderId int) ([]*domain.OrderItem, error)

func (*OrderService) GetById

func (s *OrderService) GetById(clientId int, clientType string, orderId int) (*domain.Order, error)

func (*OrderService) GetItemById

func (s *OrderService) GetItemById(clientId int, clientType string, orderId, orderItemId int) (*domain.OrderItem, error)

func (*OrderService) Update

func (s *OrderService) Update(clientId int, clientType string, orderId int, input *domain.Order) error

TODO: обновление общей стоимости заказа лучше сделать в методах добавления, обновления, удаления позиции заказа

func (*OrderService) UpdateItem

func (s *OrderService) UpdateItem(clientId int, clientType string, orderId, orderItemId, menuItemsCount int) error

type Restaurant

type Restaurant interface {
	GetAll(clientId int, clientType string) ([]*domain.Restaurant, error)
	GetById(clientId int, clientType string, restaurantId int) (*domain.Restaurant, error)
	SignIn(phone, password string) (*Tokens, error)
	GetMenu(clientId int, clientType string, restaurantId int) ([]*domain.MenuItem, error)
	SignUp(restaurant *domain.Restaurant, clientType string) (int, error)
	UpdateImage(clientId int, clientType string, restaurantId int, image string) (*domain.Restaurant, error)
	Update(clientId int, clientType string, restaurantId int, input *domain.Restaurant) error
}

type RestaurantService

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

func NewRestaurantService

func NewRestaurantService(repo repository.Restaurant, tokenManager auth.TokenManager, accessTokenTTL time.Duration) *RestaurantService

func (*RestaurantService) GetAll

func (s *RestaurantService) GetAll(clientId int, clientType string) ([]*domain.Restaurant, error)

func (*RestaurantService) GetById

func (s *RestaurantService) GetById(clientId int, clientType string, restaurantId int) (*domain.Restaurant, error)

func (*RestaurantService) GetMenu

func (s *RestaurantService) GetMenu(clientId int, clientType string, restaurantId int) ([]*domain.MenuItem, error)

func (*RestaurantService) SignIn

func (s *RestaurantService) SignIn(phone, password string) (*Tokens, error)

func (*RestaurantService) SignUp

func (s *RestaurantService) SignUp(restaurant *domain.Restaurant, clientType string) (int, error)

func (*RestaurantService) Update

func (s *RestaurantService) Update(clientId int, clientType string, restaurantId int, input *domain.Restaurant) error

func (*RestaurantService) UpdateImage

func (s *RestaurantService) UpdateImage(clientId int, clientType string, restaurantId int, image string) (*domain.Restaurant, error)

type Service

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

func NewService

func NewService(deps Deps) *Service

type Tokens

type Tokens struct {
	AccessToken string `json:"token"`
}

type User

type User interface {
	SignIn(phone, password string) (*Tokens, error)
	SignUp(user *domain.User) (int, error)
	GetAllOrders(clientId int, clientType string, userId int, activeOrdersFlag bool) ([]*domain.Order, error)
	Update(clientId int, clientType string, userId int, input *domain.User) error
	GetById(clientId int, clientType string, userId int) (*domain.User, error)
}

type UserService

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

func NewUserService

func NewUserService(repo repository.User, tokenManager auth.TokenManager, accessTokenTTL time.Duration) *UserService

func (UserService) GetAllOrders

func (s UserService) GetAllOrders(clientId int, clientType string, userId int, activeOrdersFlag bool) ([]*domain.Order, error)

func (*UserService) GetById

func (s *UserService) GetById(clientId int, clientType string, userId int) (*domain.User, error)

func (*UserService) SignIn

func (s *UserService) SignIn(phone, password string) (*Tokens, error)

func (*UserService) SignUp

func (s *UserService) SignUp(user *domain.User) (int, error)

func (*UserService) Update

func (s *UserService) Update(clientId int, clientType string, userId int, input *domain.User) error

Jump to

Keyboard shortcuts

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