Documentation ¶
Index ¶
- Constants
- func NewUserService(params ...interface{}) (interface{}, error)
- type Service
- type User
- type UserProvider
- type UserService
- func (u *UserService) GetLoginUser(ctx context.Context) (*User, error)
- func (u *UserService) GetUser(ctx context.Context, userID uint) (*User, error)
- func (u *UserService) Login(ctx context.Context, user *User) (*User, error)
- func (u *UserService) Register(ctx context.Context, user *User) (*User, error)
- func (u *UserService) SendRegisterMail(ctx context.Context, user *User) error
- func (u *UserService) VerifyRegister(ctx context.Context, captcha string) error
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, captcha string) error // Login 登录相关,使用用户名密码登录,获取完成User信息 Login(ctx context.Context, user *User) (*User, error) // GetUser 获取用户信息 GetUser(ctx context.Context, userID uint) (*User, error) // GetLoginUser 获取登录的用户信息 GetLoginUser(ctx context.Context) (*User, error) }
type User ¶
type User struct { gorm.Model UserName string `gorm:"column:username"` Password string `gorm:"column:password"` Email string `gorm:"column:email"` CreatedAt time.Time `gorm:"column:created_at"` Captcha string `gorm:"-"` // 注册验证码 Token string `gorm:"-"` // 用户token }
User 代表一个用户,注意这里的用户信息字段在不同接口和参数可能为空
func (*User) MarshalBinary ¶
MarshalBinary 实现BinaryMarshaler 接口
func (*User) UnmarshalBinary ¶
UnmarshalBinary 实现 BinaryUnMarshaler 接口
type UserProvider ¶
type UserProvider struct {
framework.ServiceProvider
}
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 ¶
func (sp *UserProvider) Register(c framework.Container) framework.NewInstance
type UserService ¶
type UserService struct { Service // contains filtered or unexported fields }
func (*UserService) GetLoginUser ¶
func (u *UserService) GetLoginUser(ctx context.Context) (*User, error)
func (*UserService) SendRegisterMail ¶
func (u *UserService) SendRegisterMail(ctx context.Context, user *User) error
func (*UserService) VerifyRegister ¶
func (u *UserService) VerifyRegister(ctx context.Context, captcha string) error
Click to show internal directories.
Click to hide internal directories.