biz

package
v0.0.0-...-75939a1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

ProviderSet is service providers.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Id            uint32
	Account       string
	Password      string
	Salt          string
	Role          string
	LastIp        string
	LastLoginTime *time.Time
}

认证信息实体

func (*Auth) CheckAuth

func (a *Auth) CheckAuth(passwd string) error

检查认证

func (*Auth) CreateCheck

func (u *Auth) CreateCheck() error

认证信息参数检查

func (*Auth) SetPassword

func (a *Auth) SetPassword(password string)

设置密码

type AuthRepo

type AuthRepo interface {
	// 获取密码错误统计
	CountPasswdError(ctx context.Context, account string) int
	// 添加密码错误统计
	AddPasswdError(ctx context.Context, account string)
	// 清除统计
	DelPasswdError(ctx context.Context, account string)
}

type AuthUseCase

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

认证用例

func NewAuthUseCase

func NewAuthUseCase(cfg *conf.Data, user UserRepo, auth AuthRepo) (*AuthUseCase, error)

wire 创建认证用例接口

func (*AuthUseCase) Captcha

func (uc *AuthUseCase) Captcha(_ context.Context, uuid string) (string, error)

获取图形验证码

func (*AuthUseCase) CheckRisk

func (uc *AuthUseCase) CheckRisk(ctx context.Context, account string) bool

风险检查

func (*AuthUseCase) CreateUserToken

func (uc *AuthUseCase) CreateUserToken(up myctx.JwtProfile, ut string) (string, error)

创建token

func (*AuthUseCase) GetUser

func (uc *AuthUseCase) GetUser(ctx context.Context, uid uint32) (*User, error)

查询用户

func (*AuthUseCase) LoginForPassword

func (uc *AuthUseCase) LoginForPassword(ctx context.Context, account, passwd string) (*User, error)

密码登录

func (*AuthUseCase) ParseUserToken

func (uc *AuthUseCase) ParseUserToken(ctx context.Context, tokenString string) (*myctx.JwtCustomClaims, error)

解析token

func (*AuthUseCase) RefreshUserToken

func (uc *AuthUseCase) RefreshUserToken(ctx context.Context, tokenString string) (string, error)

刷新token

func (*AuthUseCase) UpdatePassword

func (uc *AuthUseCase) UpdatePassword(ctx context.Context, account, passwd, oldPasswd string) error

修改密码

func (*AuthUseCase) ValidateCaptcha

func (uc *AuthUseCase) ValidateCaptcha(_ context.Context, uuid, code string) bool

图形验证码验证

type ListOption

type ListOption struct {
	// 排序字段
	OrderField string
	// 是否倒序 true desc false asc
	OrderDesc bool
	// 更多排序
	OrderMore []OrderBy
	// 页码
	Page uint32
	// 分页大小
	PageSize uint32
	// 不分页
	NoPage bool
}

基础列表查询选项

func NewListOption

func NewListOption(option *v1.ListOption) ListOption

func (*ListOption) GetPageSize

func (op *ListOption) GetPageSize() uint32

获取分页大小

type ListUserOption

type ListUserOption struct {
	Id      uint32
	Keyword string
	Role    string
	Account string
	ListOption
}

用户查询选项

type OrderBy

type OrderBy struct {
	// 排序字段
	OrderField string
	// 是否倒序 true desc false asc
	OrderDesc bool
}

type User

type User struct {
	Id    uint32
	Name  string
	Phone string
	Email string
	// 认证相关信息
	AuthId    uint32
	Auth      *Auth
	CreatedAt time.Time
	UpdatedAt time.Time
}

用户结构

func (*User) CreateCheck

func (u *User) CreateCheck() error

检查用户信息

type UserRepo

type UserRepo interface {
	// 获取用户
	GetUser(ctx context.Context, op ListUserOption) (*User, error)
	// 用户列表
	ListUser(ctx context.Context, op ListUserOption) ([]*User, int64, error)
	// 存储新用户 创建新的认证信息
	CreateUser(ctx context.Context, user *User) (*User, error)
	// 更新认证信息
	UpdateAuth(ctx context.Context, id uint32, auth *Auth) (*Auth, error)
	// 更新用户
	UpdateUser(ctx context.Context, id uint32, user *User) (*User, error)
	// 删除用户 同时删除认证信息
	DeleteUser(ctx context.Context, uid uint32) error
}

type UserUseCase

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

func NewUserUseCase

func NewUserUseCase(userRepo UserRepo) *UserUseCase

func (*UserUseCase) CreateUser

func (uc *UserUseCase) CreateUser(ctx context.Context, user *User) (*User, error)

创建用户

func (*UserUseCase) DelUser

func (uc *UserUseCase) DelUser(ctx context.Context, uid uint32) error

删除用户

func (*UserUseCase) GetUser

func (uc *UserUseCase) GetUser(ctx context.Context, uid uint32) (*User, error)

获取用户信息

func (*UserUseCase) ListUser

func (uc *UserUseCase) ListUser(ctx context.Context, op ListUserOption) ([]*User, int64, error)

用户列表

func (*UserUseCase) UpdateUser

func (uc *UserUseCase) UpdateUser(ctx context.Context, uid uint32, user *User) (*User, error)

修改用户信息

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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