service

package
v0.0.0-...-266b4ff Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthService

type AuthService interface {
	Hash(s string) (string, error)
	VerifyPassword(userPassword string, providedPassword string) bool
}

AuthService is an interface for the authentication service

func NewAuthService

func NewAuthService() AuthService

NewAuthService creates a new instance of the AuthService

type CartService

type CartService interface {
	AddItem(userID, itemID string, quantity int64) error
	GetItemsList(userID string) ([]entity.Cart, error)
	RemoveItem(userID, itemID string) error
	RemoveItems(cartItems []entity.Cart) error
	UpdateUserItem(userID, itemID string, quantity int64) error
}

CartService is interface for cart service having methods for adding item and verification of user/item

func NewCartService

func NewCartService(cartRepository repository.CartRepository, userService UserService, menuService MenuService) CartService

NewCartService constructor for cartservice with injected fields as repo, user service and menu service

type MenuService interface {
	GetRestaurantMenu(id int, limit, offset int) (*utils.Pagination, error)
	GetItem(itemID string) (*entity.Menu, error)
}

MenuService interface layer for menu service

func NewMenuService

func NewMenuService(r repository.MenuRepository) MenuService

NewMenuService is a constructor for service layer of menu

type OrderService

type OrderService interface {
	CreateOrder(userID string) error
	CalculateTotalOrderPrice(carts []entity.Cart) float64
	GetOrderHistory(userID string) ([]entity.Order, error)
	UpdateOrderStatusShipped(userID, orderID string) error
	UpdateOrderStatusDelivered(userID, orderID string) error
}

func NewOrderService

func NewOrderService(orderRepository repository.OrderRepository, cartService CartService, userService UserService) OrderService

NewOrderService is a struct for order service

type RestaurantService

type RestaurantService interface {
	FilterRestaurants(category, zip, priceRange string) ([]entity.Restaurant, error)
	CreateRestaurant(restaurant entity.Restaurant) error
	UpdateRestaurant(restaurant entity.Restaurant) error
	DeleteRestaurant(id int64) error
}

RestaurantService defines an API for restaurant service to be used by presentation layer

func NewRestaurantService

func NewRestaurantService(r repository.RestaurantRepository) RestaurantService

NewRestaurantService is a constructor with pointer to service struct which returned as instance of the interface

type TokenService

type TokenService interface {
	GenerateToken(userID string) (string, error)
	ExtractIDFromToken(r *http.Request) (string, error)
}

TokenService is an interface for the token service

func NewTokenService

func NewTokenService(secret string) TokenService

NewTokenService creates a new instance of the TokenService

type UserService

type UserService interface {
	CreateUser(user entity.User) (*entity.User, error)
	VerifyUser(user entity.User) (bool, error)
	GenerateTokenResponse(email, password string) (string, error)
	GetUserByID(id string) (*entity.User, error)
	GetUserByEmail(email string) (*entity.User, error)
}

UserService defines an API for user service to be used by presentation layer

func NewUserService

func NewUserService(repository repository.UserRepository, auth AuthService, token TokenService) UserService

NewUserService a constructor for user service

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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