biz

package
v0.0.0-...-b12402e Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2022 License: MIT, MIT Imports: 8 Imported by: 0

README

Biz

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPasswordInvalid = errors.New("password invalid")
	ErrUsernameInvalid = errors.New("username invalid")
	ErrUserNotFound    = errors.New("user not found")
)
View Source
var (
	ErrLoginFailed = errors.New("login failed")
)

ProviderSet is biz providers.

Functions

This section is empty.

Types

type Address

type Address struct {
	Id       int64
	Name     string
	Mobile   string
	Address  string
	PostCode string
}

type AuthUseCase

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

func NewAuthUseCase

func NewAuthUseCase(conf *conf.Auth, userRepo UserRepo) *AuthUseCase

func (*AuthUseCase) Login

func (receiver *AuthUseCase) Login(ctx context.Context, req *v1.LoginReq) (*v1.LoginReply, error)

func (*AuthUseCase) Register

func (receiver *AuthUseCase) Register(ctx context.Context, req *v1.RegisterReq) (*v1.RegisterReply, error)

type Beer

type Beer struct {
	Id          int64
	Name        string
	Description string
	Count       int64
	Images      []Image
}

type Card

type Card struct {
	Id      int64
	CardNo  string
	CCV     string
	Expires string
}

type CatalogRepo

type CatalogRepo interface {
	GetBeer(ctx context.Context, id int64) (*Beer, error)
	ListBeer(ctx context.Context, pageNum, pageSize int64) ([]*Beer, error)
}

type CatalogUseCase

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

func NewCatalogUseCase

func NewCatalogUseCase(repo CatalogRepo, logger log.Logger) *CatalogUseCase

func (*CatalogUseCase) GetBeer

func (uc *CatalogUseCase) GetBeer(ctx context.Context, id int64) (*Beer, error)

func (*CatalogUseCase) ListBeer

func (uc *CatalogUseCase) ListBeer(ctx context.Context, pageNum, pageSize int64) ([]*Beer, error)

type Image

type Image struct {
	URL string
}

type User

type User struct {
	Id       int64
	Username string
	Password string
}

func NewUser

func NewUser(
	username string,
	password string,
) (User, error)

type UserRepo

type UserRepo interface {
	Find(ctx context.Context, id int64) (*User, error)
	FindByUsername(ctx context.Context, username string) (*User, error)
	Save(ctx context.Context, u *User) error

	VerifyPassword(ctx context.Context, u *User, password string) error

	CreateAddress(ctx context.Context, uid int64, a *Address) (*Address, error)
	GetAddress(ctx context.Context, id int64) (*Address, error)
	ListAddress(ctx context.Context, uid int64) ([]*Address, error)

	CreateCard(ctx context.Context, uid int64, c *Card) (*Card, error)
	GetCard(ctx context.Context, id int64) (*Card, error)
	ListCard(ctx context.Context, id int64) ([]*Card, error)
}

type UserUseCase

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

func NewUserUseCase

func NewUserUseCase(repo UserRepo, logger log.Logger, authUc *AuthUseCase) *UserUseCase

func (*UserUseCase) CreateAddress

func (uc *UserUseCase) CreateAddress(ctx context.Context, uid int64, a *Address) (*Address, error)

func (*UserUseCase) CreateCard

func (uc *UserUseCase) CreateCard(ctx context.Context, uid int64, c *Card) (*Card, error)

func (*UserUseCase) GetAddress

func (uc *UserUseCase) GetAddress(ctx context.Context, id int64) (*Address, error)

func (*UserUseCase) GetCard

func (uc *UserUseCase) GetCard(ctx context.Context, id int64) (*Card, error)

func (*UserUseCase) ListAddress

func (uc *UserUseCase) ListAddress(ctx context.Context, uid int64) ([]*Address, error)

func (*UserUseCase) ListCard

func (uc *UserUseCase) ListCard(ctx context.Context, uid int64) ([]*Card, error)

func (*UserUseCase) Logout

func (uc *UserUseCase) Logout(ctx context.Context, u *User) error

Jump to

Keyboard shortcuts

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