user

package
v0.0.0-...-743d0d0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const UserKey = "user"

Variables

This section is empty.

Functions

func GenNumberValidateCode

func GenNumberValidateCode(width int) string

func NewUserService

func NewUserService(params ...interface{}) (interface{}, error)

Types

type Service

type Service interface {
	// Register 注册用户,注意这里只是将用户注册, 并没有激活, 需要调用
	// 参数:user必填,username,password, email
	// 返回值: user 带上token
	Register(ctx context.Context, user *User) (*User, error)
	// IsEmailRegister 用户邮箱是否注册
	// 参数:user必填: email
	IsEmailRegister(ctx context.Context, email string) (bool, error)
	// SendRegisterMail 发送注册的邮件
	// 参数:user必填: username, password, email, token
	SendRegisterMail(ctx context.Context, user *User) error
	// Login 登录相关,使用用户名密码登录,获取完成User信息
	Login(ctx context.Context, user *User) (*User, error)
}

Service 用户相关的服务

type User

type User struct {
	ID        int64     `gorm:"column:id;primaryKey"` // 代表用户id, 只有注册成功之后才有这个id,唯一表示一个用户
	UserName  string    `gorm:"column:username"`
	Password  string    `gorm:"column:password"`
	Email     string    `gorm:"column:email"`
	CreatedAt time.Time `gorm:"column:created_at"`
}

User 代表一个用户,注意这里的用户信息字段在不同接口和参数可能为空

func (*User) MarshalBinary

func (b *User) MarshalBinary() ([]byte, error)

MarshalBinary 实现BinaryMarshaler 接口

func (*User) UnmarshalBinary

func (b *User) UnmarshalBinary(bt []byte) error

UnmarshalBinary 实现 BinaryUnMarshaler 接口

type UserProvider

type UserProvider struct {
	framework.ServiceProvider
	// contains filtered or unexported fields
}

func (*UserProvider) Boot

func (sp *UserProvider) Boot(c framework.Container) error

func (*UserProvider) IsDefer

func (sp *UserProvider) IsDefer() bool

func (*UserProvider) Name

func (sp *UserProvider) Name() string

func (*UserProvider) Params

func (sp *UserProvider) Params(c framework.Container) []interface{}

func (*UserProvider) Register

type UserService

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

func (*UserService) IsEmailRegister

func (u *UserService) IsEmailRegister(ctx context.Context, email string) (bool, error)

func (*UserService) Login

func (u *UserService) Login(ctx context.Context, user *User) (*User, error)

func (*UserService) Register

func (u *UserService) Register(ctx context.Context, user *User) (*User, error)

func (*UserService) SendRegisterMail

func (u *UserService) SendRegisterMail(ctx context.Context, user *User) error

Jump to

Keyboard shortcuts

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