Documentation ¶
Index ¶
Constants ¶
View Source
const ( MaxCashAmount = 999999999.9 MinCashAmount = 0.1 )
Variables ¶
This section is empty.
Functions ¶
func RegisterHandlers ¶
func RegisterHandlers(r *routing.RouteGroup, service Service, logger log.Logger)
RegisterHandlers sets up the routing of the HTTP handlers.
Types ¶
type BeerBox ¶
type BeerBox struct {
PriceTotal float32 `json:"price_total"`
}
BeerBox represents the data about a price of beer box.
type CreateBeerRequest ¶
type CreateBeerRequest struct { Name string `json:"name"` Brewery string `json:"brewery"` Country string `json:"country"` Price float32 `json:"price"` Currency string `json:"currency"` }
CreateBeerRequest represents a beer creation request.
func (CreateBeerRequest) Validate ¶
func (m CreateBeerRequest) Validate() error
Validate validates the CreateBeerRequest fields.
type Repository ¶
type Repository interface { // Get returns the beer with the specified user ID. Get(ctx context.Context, id int) (entity.Beer, error) // Count returns the number of beers. Count(ctx context.Context) (int, error) // Query returns the list of beers with the given offset and limit. Query(ctx context.Context, offset, limit int, filters map[string]interface{}) ([]entity.Beer, error) // Create saves a new beer in the storage. Create(ctx context.Context, beer entity.Beer) (int, error) // GetPrice returns the price of beer box relative to currency GetPrice(ctx context.Context, id int, srcCurrency, dstCurrency string) (float32, error) // Update updates the beer with given ID in the storage. Update(ctx context.Context, beer entity.Beer) error // Delete removes the beer with given ID from the storage. Delete(ctx context.Context, id int) error }
Repository encapsulates the logic to access users from the data source.
func NewRepository ¶
func NewRepository(db *dbcontext.DB, logger log.Logger) Repository
NewRepository creates a new beer repository
type Service ¶
type Service interface { Get(ctx context.Context, id int) (BeerItem, error) GetPrice(ctx context.Context, id int, currency string, quantity uint32) (BeerBox, error) Create(ctx context.Context, input CreateBeerRequest) (BeerItem, error) Query(ctx context.Context, offset, limit int, filters map[string]interface{}) ([]BeerItem, error) Count(ctx context.Context) (int, error) }
Service encapsulates use case logic for beers.
func NewService ¶
func NewService(repo Repository, logger log.Logger) Service
NewService creates a new user service.
Click to show internal directories.
Click to hide internal directories.