88 lines
1.9 KiB
Go
88 lines
1.9 KiB
Go
package user
|
||
|
||
import (
|
||
"context"
|
||
|
||
"github.com/infraboard/mcube/v2/ioc"
|
||
)
|
||
|
||
// 获取实现,从ioc
|
||
func GetService() Service {
|
||
return ioc.Controller().Get(AppName).(Service)
|
||
}
|
||
|
||
const (
|
||
AppName = "user"
|
||
)
|
||
|
||
type Service interface {
|
||
AdminService
|
||
UserService
|
||
}
|
||
|
||
type AdminService interface {
|
||
// 更新用户状态
|
||
UpdateUserStatus(context.Context, *UpdateUserStatusRequest) (*User, error)
|
||
// 查询某个具体的用户详情
|
||
DescribeUser(context.Context, *DescribeUserRequest) (*User, error)
|
||
}
|
||
|
||
// UserId Or Username
|
||
type DescribeUserRequest struct {
|
||
DescribeBy DESCRIBE_BY `json:"describe_by"`
|
||
Value string `json:"value"`
|
||
}
|
||
|
||
type UserService interface {
|
||
// 注册
|
||
Registry(context.Context, *RegistryRequest) (*User, error)
|
||
|
||
// 用户更新
|
||
// 用户秘密更新, 安全等级弱, 用于已经提供了原来的密码
|
||
UpdatePassword(context.Context, *UpdatePasswordRequest) error
|
||
// 忘了密码,需要重置, 安全等级高,有很多限制条件
|
||
ResetPassword(context.Context, *ResetPasswordRequest) error
|
||
// 更新Profile信息, 邮箱之类的
|
||
UpdateProfile(context.Context, *UpdateProfileRequest) (*User, error)
|
||
|
||
// 注销
|
||
UnRegistry(context.Context, *UnRegistryRequest)
|
||
}
|
||
|
||
type UpdateUserStatusRequest struct {
|
||
// 用户Id
|
||
UserId string `json:"user_id"`
|
||
//
|
||
Status
|
||
}
|
||
|
||
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"`
|
||
}
|