补充用户接口定义
This commit is contained in:
parent
12c6375b1b
commit
76fd1c6f3e
@ -1,8 +1,49 @@
|
|||||||
package user
|
package user
|
||||||
|
|
||||||
|
import "context"
|
||||||
|
|
||||||
type Service interface {
|
type Service interface {
|
||||||
// 注册
|
// 注册
|
||||||
Registry()
|
Registry(context.Context, *RegistryRequest) (*User, error)
|
||||||
|
|
||||||
|
// 用户更新
|
||||||
|
// 用户秘密更新, 安全等级弱, 用于已经提供了原来的密码
|
||||||
|
UpdatePassword(context.Context, *UpdatePasswordRequest) error
|
||||||
|
// 忘了密码,需要重置, 安全等级高,有很多限制条件
|
||||||
|
ResetPassword(context.Context, *ResetPasswordRequest) error
|
||||||
|
// 更新Profile信息, 邮箱之类的
|
||||||
|
UpdateProfile(context.Context, *UpdateProfileRequest) (*User, error)
|
||||||
|
|
||||||
// 注销
|
// 注销
|
||||||
UnRegistry()
|
UnRegistry(context.Context, *UnRegistryRequest)
|
||||||
|
}
|
||||||
|
|
||||||
|
type UpdateProfileRequest struct {
|
||||||
|
// 用户Id
|
||||||
|
UserId string `json:"user_id"`
|
||||||
|
// 需要更新的Profile
|
||||||
|
Profile
|
||||||
|
}
|
||||||
|
|
||||||
|
type UpdatePasswordRequest struct {
|
||||||
|
// 用户名
|
||||||
|
Username string `json:"username"`
|
||||||
|
// 原来的密码
|
||||||
|
OldPassword string `json:"old_password"`
|
||||||
|
// 新的密码
|
||||||
|
NewPassword string `json:"new_password"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ResetPasswordRequest struct {
|
||||||
|
// 用户名
|
||||||
|
Username string `json:"username"`
|
||||||
|
// 新的密码
|
||||||
|
NewPassword string `json:"new_password"`
|
||||||
|
// 验证码
|
||||||
|
VerifyCode string `json:"verify_code"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UnRegistryRequest struct {
|
||||||
|
// 用户名
|
||||||
|
Username string `json:"username"`
|
||||||
}
|
}
|
||||||
|
32
vblog/apps/user/model.go
Normal file
32
vblog/apps/user/model.go
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package user
|
||||||
|
|
||||||
|
import "gitlab.com/go-course-project/go17/vblog/utils"
|
||||||
|
|
||||||
|
type User struct {
|
||||||
|
// 存放到数据里的对象的远数据信息
|
||||||
|
utils.ResourceMeta
|
||||||
|
// 具体参数
|
||||||
|
RegistryRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
type RegistryRequest struct {
|
||||||
|
// 用户名
|
||||||
|
Username string `json:"username" gorm:"column:username;unique;index"`
|
||||||
|
// 密码
|
||||||
|
Password string `json:"password" gorm:"column:username;type:varchar(255)"`
|
||||||
|
// Profile 信息
|
||||||
|
Profile
|
||||||
|
}
|
||||||
|
|
||||||
|
type Profile struct {
|
||||||
|
// 头像
|
||||||
|
Avatar string `json:"avatar" gorm:"column:avatar;type:varchar(255)"`
|
||||||
|
// 用户昵称
|
||||||
|
NickName string `json:"nic_name" gorm:"column:nic_name;type:varchar(100)"`
|
||||||
|
// 用户邮箱, 验证用户有效性
|
||||||
|
Email string `json:"email" gorm:"column:email;type:varchar(100)"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *User) TableName() string {
|
||||||
|
return "users"
|
||||||
|
}
|
12
vblog/utils/resource.go
Normal file
12
vblog/utils/resource.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
type ResourceMeta struct {
|
||||||
|
// 资源Id
|
||||||
|
Id uint `json:"id" gorm:"primaryKey;column:id"`
|
||||||
|
// 创建时间
|
||||||
|
CreatedAt time.Time `json:"created_at" gorm:"column:created_at;not null"`
|
||||||
|
// 更新时间
|
||||||
|
UpdatedAt *time.Time `json:"updated_at" gorm:"column:updated_at"`
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user