Documentation
¶
Index ¶
Constants ¶
View Source
const ( SOURCE_UNKNOWN = iota SOURCE_WEB SOURCE_IOS SOURCE_ANDROID SOURCE_PC )
View Source
const ( //系统初始化 CREATE_TYPE_INIT = iota //管理员创建 CREATE_TYPE_ADMIN //用户注册 CREATE_TYPE_REGISTRY )
View Source
const ( SEX_UNKNOWN = iota SEX_MALE SEX_FEMALE )
View Source
const (
APP_NAME = "user"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CREATE_TYPE ¶
type CREATE_TYPE int
type CreateUserRequest ¶
type CreateUserRequest struct {
//账号提供方
Provider PROVIDER `json:"provider" gorm:"column:provider;type:tinyint(1);not null;index" description:"账号提供方"`
//创建方式
CreateType CREATE_TYPE `json:"create_type" gorm:"column:create_type;type:tinyint(1);not null;index" optional:"true"`
//用户名
UserName string `json:"user_name" gorm:"column:user_name;type:varchar(255);not null;uniqueIndex" description:"用户名"`
//密码(Hash过后的)
PassWord string `json:"password,omitempty" gorm:"column:password;type:varchar(255);not null" description:"用户密码" mask:",1,1"`
//用户描述
Description string `json:"description" gorm:"column:description;type:varchar(255);not null" description:"用户描述"`
//用户类型
Type TYPE `json:"type" gorm:"column:type:varchar(255);not null" description:"用户类型"`
//用户所属域
Domain string `json:"domain" gorm:"column:domain;type:varchar(255);" description:"用户所属域"`
//支持接口调用
EnabledApi bool `json:"enabled_api" gorm:"column:enabled_api;type:tinyint(1)" optional:"true" description:"是否支持接口调用"`
// 是否为管理员
IsAdmin bool `json:"is_admin" gorm:"column:is_admin;type:tinyint(1)" optional:"true" description:"是否为管理员"`
//用户状态 01:正常,02:冻结
Locked bool `json:"stat" gorm:"column:stat;type:tinyint(1)" optional:"true" description:"用户状态 01:正常,02:冻结"`
//激活状态 1:已激活,0:未激活
Activate bool `json:"activate" gorm:"column:activate;type:tinyint(1)" optional:"true" description:"激活状态 1:已激活,0:未激活"`
//生日
BirthDay *time.Time `json:"birthday" gorm:"column:birthday;type:varchar(255)" optional:"true" description:"生日"`
//昵称
NickName string `json:"nick_name" gorm:"column:nick_name;type:varchar(255)" optional:"true" description:"昵称"`
//头像图片
UserIcon string `json:"user_icon" gorm:"column:user_icon;type:varchar(500)" optional:"true" description:"头像图片"`
//性别 1:男,2:女,3:保密
Sex SEX `json:"sex" gorm:"column:sex;type:tinyint(1)" optional:"true" description:"性别 1:男,2:女,3:保密"`
//邮箱
Email string `json:"email" gorm:"column:email;type:varchar(255);index" description:"邮箱" unique:"true"`
//邮箱验证是否正确
IsEmailConfirmed bool `` /* 126-byte string literal not displayed */
//手机号码
Mobile string `json:"mobile" gorm:"column:moble;type:varchar(255);index" optional:"true" description:"手机号码"`
//手机号码验证是否正确
IsMobileConfirmed bool `` /* 134-byte string literal not displayed */
//手机登录标识
MobileTGC string `json:"mobile_tgc" gorm:"column:moble_tgc;type:varchar(255)" optional:"true" description:"手机登录标识"`
//标签
Label string `json:"label" gorm:"column:label;type:varchar(255);index" optional:"true" description:"标签"`
//其他扩展信息
Extras map[string]string `json:"extras" gorm:"column:extras;serializer:json;type:json" optional:"true" description:"其他扩展信息"`
// contains filtered or unexported fields
}
func NewCreateUserRequest ¶
func NewCreateUserRequest() *CreateUserRequest
func (*CreateUserRequest) PasswordHash ¶
func (req *CreateUserRequest) PasswordHash()
func (*CreateUserRequest) SetIsHashed ¶
func (req *CreateUserRequest) SetIsHashed()
func (*CreateUserRequest) Validate ¶
func (req *CreateUserRequest) Validate() error
type DESCRIBE_BY ¶
type DESCRIBE_BY int
const ( DESCRIBE_BY_ID DESCRIBE_BY = iota DESCRIBE_BY_USERNAME )
type DeleteUserRequest ¶
type DeleteUserRequest struct {
Id string `json:"id"`
}
func NewDeleteUserRequest ¶
func NewDeleteUserRequest(id string) *DeleteUserRequest
type DescribeUserRequest ¶
type DescribeUserRequest struct {
DescribeBy DESCRIBE_BY `json:"describe_by"`
DescribeValue string `json:"describe_value"`
}
同事支持通过Id查询,也支持通过username来查询
func NewDescribeUserRequestById ¶
func NewDescribeUserRequestById(id string) *DescribeUserRequest
func NewDescribeUserRequestByUserName ¶
func NewDescribeUserRequestByUserName(username string) *DescribeUserRequest
type QueryUsersRequest ¶
type QueryUsersRequest struct {
request.PageRequest
UserIds []uint64 `form:"user" json:"user"`
}
func NewQueryUsersRequest ¶
func NewQueryUsersRequest() *QueryUsersRequest
func (*QueryUsersRequest) AddUsers ¶
func (r *QueryUsersRequest) AddUsers(userIds ...uint64) *QueryUsersRequest
添加用户ID到查询条件中
type Service ¶
type Service interface {
//创建用户
CreateUser(context.Context, *CreateUserRequest) (*User, error)
//删除用户
DeleteUser(context.Context, *DeleteUserRequest) (*User, error)
//查询用户详情
DescribeUser(context.Context, *DescribeUserRequest) (*User, error)
//查询用户列表
QueryUsers(context.Context, *QueryUsersRequest) (*types.Set[*User], error)
}
func GetService ¶
func GetService() Service
type User ¶
type User struct {
//基础数据
apps.ResourceMeta
//用户传递过来的请求
CreateUserRequest
//密码强度
PwdIntensity int8 `json:"pwd_intensity" gorm:"column:pwd_intensity;type:tinyint(1);not null" optional:"true"`
}
用于存放存入数据库的对象
func NewUser ¶
func NewUser(req *CreateUserRequest) *User
Click to show internal directories.
Click to hide internal directories.