internal

package
v0.0.0-...-56d6a6b Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGetVoucherQuotaLimit

func NewGetVoucherQuotaLimit(voucherRepo VoucherRepository) andromeda.GetQuota

func NewGetVoucherQuotaUsage

func NewGetVoucherQuotaUsage(voucherRepo VoucherRepository) andromeda.GetQuota

func NewGetVoucherQuotaUsageExpiration

func NewGetVoucherQuotaUsageExpiration() andromeda.GetQuotaExpiration

func NewGetVoucherQuotaUsageKey

func NewGetVoucherQuotaUsageKey(keyFormat string) andromeda.GetQuotaKey

func NewUpdateVoucherQuotaUsageListener

func NewUpdateVoucherQuotaUsageListener() andromeda.UpdateQuotaUsageListener

Types

type ClaimVoucher

type ClaimVoucher interface {
	Do(ctx context.Context, code, userID string) (*History, error)
}

func NewClaimVoucher

func NewClaimVoucher(
	voucherRepo VoucherRepository,
	historyRepo HistoryRepository,
	addVoucherUsage andromeda.UpdateQuotaUsage,
	reduceVoucherUsage andromeda.UpdateQuotaUsage,
) ClaimVoucher

func NewUnClaimVoucher

func NewUnClaimVoucher(
	voucherRepo VoucherRepository,
	historyRepo HistoryRepository,
	addVoucherUsage andromeda.UpdateQuotaUsage,
	reduceVoucherUsage andromeda.UpdateQuotaUsage,
) ClaimVoucher

type History

type History struct {
	ID        string    `json:"id" db:"id"`
	VoucherID string    `json:"voucherId" db:"voucher_id"`
	UserID    string    `json:"userId" db:"user_id"`
	CreatedAt time.Time `json:"createdAt" db:"created_at"`
}

type HistoryRepository

type HistoryRepository interface {
	Create(ctx context.Context, data *History) error
}

type Voucher

type Voucher struct {
	ID    string `db:"id"`
	Code  string `db:"code"`
	Limit int64  `db:"quota_limit"`
	Usage int64  `db:"quota_usage"`
}

type VoucherRepository

type VoucherRepository interface {
	FindAll(ctx context.Context) ([]*Voucher, error)
	FindByID(ctx context.Context, id string) (*Voucher, error)
	FindByCode(ctx context.Context, code string) (*Voucher, error)
	Update(ctx context.Context, data *Voucher) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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