user

package
v0.0.0-...-ed6a5cb Latest Latest
Warning

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

Go to latest
Published: May 30, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const UserKey = "user"

Variables

This section is empty.

Functions

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)

	// SendRegisterMail 发送注册的邮件
	// 参数:user必填: username, password, email, token
	SendRegisterMail(ctx context.Context, user *User) error

	// VerifyRegister 注册用户,验证注册信息, 返回验证是否成功
	VerifyRegister(ctx context.Context, token string) (bool, error)

	// Login 登录相关,使用用户名密码登录,获取完成User信息
	Login(ctx context.Context, user *User) (*User, error)

	// Logout 登出
	Logout(ctx context.Context, user *User) error

	// VerifyLogin 登录验证
	VerifyLogin(ctx context.Context, token string) (*User, error)

	// GetUser 获取用户信息
	GetUser(ctx context.Context, userID int64) (*User, error)
}

type User

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

	Token    string `gorm:"-"` // token 可以用作注册token或者登录token
	Metadata string `gorm:"-"` // 资源的功能属性
}

User 一个管理员用户

func (*User) MarshalBinary

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

MarshalBinary 实现BinaryMarshaler 接口

func (*User) UnmarshalBinary

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

UnmarshalBinary 实现 BinaryUnMarshaler 接口

type UserProvider

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

func (*UserProvider) Boot

func (sp *UserProvider) Boot(c core.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 core.Container) []interface{}

func (*UserProvider) Register

func (sp *UserProvider) Register(c core.Container) core.NewInstance

type UserService

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

func (*UserService) Foo

func (s *UserService) Foo() string

func (*UserService) GetUser

func (u *UserService) GetUser(ctx context.Context, userID int64) (*User, error)

func (*UserService) Login

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

func (*UserService) Logout

func (u *UserService) Logout(ctx context.Context, 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

func (*UserService) VerifyLogin

func (u *UserService) VerifyLogin(ctx context.Context, token string) (*User, error)

func (*UserService) VerifyRegister

func (u *UserService) VerifyRegister(ctx context.Context, token string) (bool, error)

Jump to

Keyboard shortcuts

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