user

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type AllUserRequest

type AllUserRequest struct {
	Name        string `json:"name" url:"name" validate:"omitempty,gte=2,lte=50"`
	DisplayName string `json:"display_name" url:"display_name" validate:"omitempty,lte=191"`
	model.PageParam
}

type CreateDivisionRequest

type CreateDivisionRequest struct {
	Name     string `json:"name" validate:"required,lte=191"`
	ParentID uint   `json:"parent_id"`
}

type CreateUserRequest

type CreateUserRequest struct {
	RegisterUserRequest
	RoleName   string `json:"role_name" validate:"omitempty,lte=50"`
	DivisionID uint   `json:"division_id"`
	OpenID     string `json:"-"`
}

type Division

type Division struct {
	gorm.Model
	Name     string      `gorm:"not null; size:191; unique; comment:分组名称"`
	ParentID *uint       `gorm:"comment:父分组ID"`
	Children []*Division `gorm:"foreignkey:ParentID"`
}

type DivisionJson

type DivisionJson struct {
	ID       uint            `json:"id"`
	Name     string          `json:"name"`
	ParentID uint            `json:"parent_id"` // 父分组ID
	Children []*DivisionJson `json:"children"`
}

type LoginRequest

type LoginRequest struct {
	Account  string `json:"account" validate:"required,lte=191"`
	Password string `json:"password" validate:"required,gte=8,lte=32"`
}

type RegisterUserRequest

type RegisterUserRequest struct {
	Name        string `json:"name" validate:"required,gte=2,lte=50"`
	Password    string `json:"password" validate:"required,gte=8,lte=32"`
	DisplayName string `json:"display_name" validate:"required,lte=191"`
	Phone       string `json:"phone" validate:"omitempty,alphanum,lte=191"`
	Email       string `json:"email" validate:"omitempty,email,lte=191"`
	RealName    string `json:"real_name" validate:"omitempty,lte=191"`
}

type UpdateDivisionRequest

type UpdateDivisionRequest struct {
	Name     string `json:"name" validate:"omitempty,lte=191"`
	ParentID int64  `json:"parent_id" validate:"omitempty,gte=-1"` // -1: 修改为null 0: 不修改 n: 修改为指定的分组
}

type UpdateUserRequest

type UpdateUserRequest struct {
	Name        string `json:"name" validate:"omitempty,gte=2,lte=50"`
	Password    string `json:"password" validate:"omitempty,gte=8,lte=32"`
	DisplayName string `json:"display_name" validate:"omitempty,lte=191"`
	Phone       string `json:"phone" validate:"omitempty,alphanum,lte=191"`
	Email       string `json:"email" validate:"omitempty,email,lte=191"`
	RealName    string `json:"real_name" validate:"omitempty,lte=191"`
	RoleName    string `json:"role_name" validate:"omitempty,lte=50"`
	DivisionID  int64  `json:"division_id" validate:"omitempty,gte=-1"` // -1: 修改为null 0: 不修改 n: 修改为指定的分组
}

type User

type User struct {
	model.BaseModel
	Name        string    `gorm:"not null; size:50; unique; comment:用户名"`
	Password    string    `gorm:"not null; size:191; comment:密码"`
	DisplayName string    `gorm:"not null; size:191; comment:昵称"`
	RoleName    string    `gorm:"not null; size:50; index; comment:所属角色"`
	DivisionID  *uint     `gorm:"comment:所属分组id"`
	Division    *Division `gorm:"foreignkey:DivisionID"`
	Phone       string    `gorm:"not null; size:191; index; comment:手机号"`
	Email       string    `gorm:"not null; size:191; index; comment:邮箱"`
	LoginIP     string    `gorm:"not null; size:40; default:0.0.0.0; comment:最后登录IP"`
	LoginTime   time.Time `gorm:"not null; comment:最后登录时间"`
	RealName    string    `gorm:"not null; size:191; comment:真实姓名"`
	OpenID      string    `gorm:"not null; size:191; index; comment:微信openid"`
}

func GetUserByID

func GetUserByID(id uint) (*User, error)

GetUserByID returns the user with the given ID.

type UserJson

type UserJson struct {
	ID          uint           `json:"id"`
	Name        string         `json:"name"`
	DisplayName string         `json:"display_name"` // 昵称
	RoleName    string         `json:"user_role"`
	Role        *rbac.RoleJson `json:"role,omitempty"`
	Phone       string         `json:"phone"`
	Email       string         `json:"email"`
	RealName    string         `json:"real_name"`
	LoginTime   int64          `json:"login_time"` // unix timestamp in seconds (UTC)
}

func UserToJson

func UserToJson(user *User) *UserJson

UserToJson converts a user to a json string.

type WxLoginRequest

type WxLoginRequest struct {
	Code string `json:"code"`
}

type WxLoginResponse

type WxLoginResponse struct {
	OpenID     string `json:"openid"`
	SessionKey string `json:"session_key"`
	UnionID    string `json:"unionid"`
	ErrCode    int    `json:"errcode"`
	ErrMsg     string `json:"errmsg"`
}

type WxRegisterRequest

type WxRegisterRequest struct {
	Code string `json:"code"`
	RegisterUserRequest
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL