biz

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: MIT Imports: 13 Imported by: 0

README

Biz

Documentation

Index

Constants

View Source
const (
	IdempotentMissingToken = "idempotent.token.missing"
	IdempotentTokenExpired = "idempotent.token.invalid"

	TooManyRequests = "too.many.requests"
	DataNotChange   = "data.not.change"
	DuplicateField  = "duplicate.field"
	RecordNotFound  = "record.not.found"
	NoPermission    = "no.permission"
)

Variables

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, bool)) (string, bool)
	// 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
}

type FindGame added in v1.0.2

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

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"`
	Age  int32  `json:"age"`
}

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)

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,omitempty"`
	Name *string `json:"name,omitempty"`
	Age  *int32  `json:"age,omitempty"`
}

Jump to

Keyboard shortcuts

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