biz

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 13 Imported by: 0

README

Biz

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIdempotentMissingToken = func(ctx context.Context) error {
		return reason.ErrorIllegalParameter(i18n.FromContext(ctx).T(constant.IdempotentMissingToken))
	}

	ErrTooManyRequests = func(ctx context.Context) error {
		return reason.ErrorTooManyRequests(i18n.FromContext(ctx).T(constant.TooManyRequests))
	}
	ErrDataNotChange = func(ctx context.Context, args ...string) error {
		return i18n.NewError(ctx, constant.DataNotChange, reason.ErrorIllegalParameter, args...)
	}
	ErrDuplicateField = func(ctx context.Context, args ...string) error {
		return i18n.NewError(ctx, constant.DuplicateField, reason.ErrorIllegalParameter, args...)
	}
	ErrRecordNotFound = func(ctx context.Context, args ...string) error {
		return i18n.NewError(ctx, constant.RecordNotFound, reason.ErrorNotFound, args...)
	}
	ErrInternal = func(ctx context.Context, args ...string) error {
		return i18n.NewError(ctx, constant.InternalError, reason.ErrorInternal, args...)
	}
	ErrIllegalParameter = func(ctx context.Context, args ...string) error {
		return i18n.NewError(ctx, constant.IllegalParameter, reason.ErrorIllegalParameter, args...)
	}
)
View Source
var ProviderSet = wire.NewSet(
	NewGameUseCase,
)

ProviderSet is biz providers.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// Cache is get redis instance
	Cache() redis.UniversalClient
	// WithPrefix will add cache key prefix
	WithPrefix(prefix string) Cache
	// Get is get cache data by key from redis, do write handler if cache is empty
	Get(ctx context.Context, action string, write func(context.Context) (string, error)) (string, error)
	// Set is set data to redis
	Set(ctx context.Context, action, data string, short bool)
	// Del delete key
	Del(ctx context.Context, action string)
	// SetWithExpiration is set data to redis with custom expiration
	SetWithExpiration(ctx context.Context, action, data string, seconds int64)
	// Flush is clean association cache if handler err=nil
	Flush(ctx context.Context, handler func(context.Context) error) error
	// FlushByPrefix clean cache by prefix, without prefix equals flush all by default cache prefix
	FlushByPrefix(ctx context.Context, prefix ...string) (err error)
}

type FindGame added in v1.0.2

type FindGame struct {
	Page page.Page `json:"page"`
	Name *string   `json:"name"`
}

type FindGameCache added in v1.0.2

type FindGameCache struct {
	Page page.Page `json:"page"`
	List []Game    `json:"list"`
}

type Game added in v1.0.2

type Game struct {
	Id   uint64 `json:"id,string"`
	Name string `json:"name"`
}

type GameRepo added in v1.0.2

type GameRepo interface {
	Create(ctx context.Context, item *Game) error
	Get(ctx context.Context, id uint64) (*Game, error)
	Find(ctx context.Context, condition *FindGame) []Game
	Update(ctx context.Context, item *UpdateGame) error
	Delete(ctx context.Context, ids ...uint64) error
}

type GameUseCase added in v1.0.2

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

func NewGameUseCase added in v1.0.2

func NewGameUseCase(c *conf.Bootstrap, repo GameRepo, tx Transaction, cache Cache) *GameUseCase

func (*GameUseCase) Create added in v1.0.2

func (uc *GameUseCase) Create(ctx context.Context, item *Game) error

func (*GameUseCase) Delete added in v1.0.2

func (uc *GameUseCase) Delete(ctx context.Context, ids ...uint64) error

func (*GameUseCase) Find added in v1.0.2

func (uc *GameUseCase) Find(ctx context.Context, condition *FindGame) (rp []Game, err error)

func (*GameUseCase) Get added in v1.0.2

func (uc *GameUseCase) Get(ctx context.Context, id uint64) (rp *Game, err error)

func (*GameUseCase) Update added in v1.0.2

func (uc *GameUseCase) Update(ctx context.Context, item *UpdateGame) error

type Transaction

type Transaction interface {
	Tx(ctx context.Context, handler func(context.Context) error) error
}

type UpdateGame added in v1.0.2

type UpdateGame struct {
	Id   uint64  `json:"id,string"`
	Name *string `json:"name,omitempty"`
}

Jump to

Keyboard shortcuts

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