Documentation
      ¶
    
    
  
    
  
    Index ¶
Constants ¶
      View Source
      
  
    const ( SEX_UNKNOWN = iota SEX_MALE SEX_FEMALE )
      View Source
      
  
    const ( // 系统初始化 CREATE_TYPE_INIT = iota // 管理员创建 CREATE_TYPE_ADMIN // 用户自己注册 CREATE_TYPE_REGISTRY )
      View Source
      
  
    const ( // 未知 SOURCE_UNKNOWN = iota // Web SOURCE_WEB // IOS SOURCE_IOS // ANDROID SOURCE_ANDROID // PC SOURCE_PC )
      View Source
      
  
const (
	AppName = "user"
)
    Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CEATE_TYPE ¶
type CEATE_TYPE int
type CreateUserRequest ¶
type CreateUserRequest struct {
	// 账号提供方
	Provider PROVIDER `json:"provider" gorm:"column:provider;type:tinyint(1);not null;index" description:"账号提供方"`
	// 创建方式
	CreateType CEATE_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(100);not null;uniqueIndex" description:"用户名"`
	// 密码(Hash过后的)
	Password string `json:"password" gorm:"column:password;type:varchar(200);not null" description:"用户密码"`
	// 用户描述
	Description string `json:"description" gorm:"column:description;type:varchar(200);not null" 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(200)" optional:"true" description:"生日"`
	// 昵称
	NickName string `json:"nick_name" gorm:"column:nick_name;type:varchar(200)" optional:"true" description:"昵称"`
	// 头像图片
	UserIcon string `json:"user_icon" gorm:"column:user_icon;type:varchar(500)" optional:"true" description:"头像图片"`
	// 性别, 1:男,2:女,0:保密
	Sex SEX `json:"sex" gorm:"column:sex;type:tinyint(1)" optional:"true" description:"性别, 1:男, 2:女, 0: 保密"`
	// 邮箱
	Email string `json:"email" gorm:"column:email;type:varchar(200);uniqueIndex" optional:"true" description:"邮箱" unique:"true"`
	// 邮箱是否验证ok
	IsEmailConfirmed bool `json:"is_email_confirmed" gorm:"column:is_email_confirmed;type:tinyint(1)" optional:"true" description:"邮箱是否验证ok"`
	// 手机
	Mobile string `json:"mobile" gorm:"column:mobile;type:varchar(200);uniqueIndex" optional:"true" description:"手机" unique:"true"`
	// 手机释放验证ok
	IsMobileConfirmed bool `` /* 127-byte string literal not displayed */
	// 手机登录标识
	MobileTGC string `json:"mobile_tgc" gorm:"column:mobile_tgc;type:char(64)" optional:"true" description:"手机登录标识"`
	// 标签
	Label string `json:"label" gorm:"column:label;type:varchar(200);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 NewLDAPCreateUserRequest ¶
func NewLDAPCreateUserRequest(username, password, descriptoin string) *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 QueryUserRequest ¶
type QueryUserRequest struct {
	*request.PageRequest
}
    func NewQueryUserRequest ¶
func NewQueryUserRequest() *QueryUserRequest
type Service ¶
type Service interface {
	// 创建用户
	CreateUser(context.Context, *CreateUserRequest) (*User, error)
	// 删除用户
	DeleteUser(context.Context, *DeleteUserRequest) (*User, error)
	// 查询用户详情
	DescribeUser(context.Context, *DescribeUserRequest) (*User, error)
	// 查询用户列表
	QueryUser(context.Context, *QueryUserRequest) (*types.Set[*User], error)
}
    定义User包的能力 就是接口定义 站在使用放的角度来定义的 userSvc.Create(ctx, req), userSvc.DeleteUser(id) 接口定义好了,不要试图 随意修改接口, 要保证接口的兼容性
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"`
}
    用于存放 存入数据库的对象(PO)
func NewUser ¶
func NewUser(req *CreateUserRequest) *User
 Click to show internal directories. 
   Click to hide internal directories.