model

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package model provides ...

Index

Constants

View Source
const (
	LoginStatusSuccess = "success"
	LoginStatusFailure = "failure"
)
View Source
const (
	MenuPlatformAll     = "all"
	MenuPlatformWeb     = "web"
	MenuPlatformMobile  = "mobile"
	MenuPlatformDesktop = "desktop"
)

Variables

View Source
var (
	// Records is the table records must be pr-eexists before any database curd,
	// its register by register function.
	// The underlying type of map value must be model pointer to structure, eg: *model.User
	//
	// Records is the table records that should created automatically when app bootstraping.
	Records []*Record = make([]*Record, 0)

	// Tables is the database table that should created automatically when app bootstraping.
	Tables []types.Model

	TablesWithDB []struct {
		Table  types.Model
		DBName string
	}

	// Routes is a map slice that element is map[string][]Verb
	// The map key is the route path, eg: '/asset' or 'asset'
	//   or '/api/asset' (the prefiex /api will be remove automatically).
	// The map value is the Verb slice.
	// - VerbCreate is equivalent to http method "POST".
	// - VerbDelete is equivalent to http method "DELETE".
	// - VerbUpdate is equivalent to http method "PUT".
	// - VerbUpdatePartial is equivalent to http method "PATCH".
	// - VerbList is equivalent to http method "GET /xxx".
	// - VerbGET is equivalent to http method "GET /xxx/:id".
	// - VerbExport is equivalent to http method "GET" but specifially used to export resources.
	// - VerbImport is equivalent to http method "POST" but specifically used to import resources.
	Routes []route = make([]route, 0)
)
View Source
var (
	RootId      = "root"
	RootName    = "root"
	UnknownId   = "unknown"
	UnknownName = "未知"
	NoneId      = "none"
	NoneName    = "无"

	KeyName = "name"
	KeyId   = "id"
)
View Source
var ErrMobileLength = errors.New("mobile number length must be 11")
View Source
var MenuRoot = &Menu{ParentId: RootId, Base: Base{ID: RootId}}

Functions

func GetTableName added in v0.0.66

func GetTableName[M types.Model]() string

func Register

func Register[M types.Model](records ...M)

Register associates the model with database table and will created automatically. If records provided, they will be inserted when application bootstrapping.

Parameters:

  • records: Optional initial records to be seeded into the table. Can be single or multiple records.

Examples:

// Create table 'users' only
Register[*model.User]()

// Create table 'users' and insert one record
Register[*model.User](&model.User{ID: 1, Name: "admin"})

// Create table 'users' and insert a single user record
Register[*model.User](user)

// Create table 'users' and insert multiple records
Register[*model.User](users...)  // where users is []*model.User

NOTE:

  1. Always call this function in init().
  2. Ensure the model pacakge is imported in main.go. The init() function will only executed if the file is imported directly or indirectly by main.go.

func RegisterRoutes deprecated

func RegisterRoutes[M types.Model](path string, verbs ...consts.HTTPVerb)

RegisterRoutes register one route path with multiple api verbs. call this function multiple to register multiple route path. If route path is same, using latest register route path.

Deprecated: use router.Register() instead. This function is a no-op.

func RegisterTo

func RegisterTo[M types.Model](dbname string, records ...M)

RegisterTo works identically to Register(), but registers the model on the specified database instance. more details see: Register().

func SetID

func SetID(m types.Model, id ...string)

Types

type BIOS added in v0.0.65

type BIOS struct {
	Vendor  string `json:"vendor,omitempty"`
	Version string `json:"version,omitempty"`
	Date    string `json:"date,omitempty"`
}

type Base

type Base struct {
	ID string `json:"id" gorm:"primaryKey" schema:"id" url:"-"`

	CreatedBy string     `json:"created_by,omitempty" gorm:"index" schema:"created_by" url:"-"`
	UpdatedBy string     `json:"updated_by,omitempty" gorm:"index" schema:"updated_by" url:"-"`
	CreatedAt *time.Time `json:"created_at,omitempty" gorm:"index" schema:"-" url:"-"`
	UpdatedAt *time.Time `json:"updated_at,omitempty" gorm:"index" schema:"-" url:"-"`
	Remark    *string    `json:"remark,omitempty" gorm:"size:10240" schema:"-" url:"-"` // 如果需要支持 PATCH 更新,则必须是指针类型
	Order     *uint      `json:"order,omitempty" schema:"-" url:"-"`

	// Query parameter
	Page       uint    `json:"-" gorm:"-" schema:"page" url:"page,omitempty"`                 // Query parameter, eg: "page=2"
	Size       uint    `json:"-" gorm:"-" schema:"size" url:"size,omitempty"`                 // Query parameter, eg: "size=10"
	Expand     *string `json:"-" gorm:"-" schema:"_expand" url:"_expand,omitempty"`           // Query parameter, eg: "_expand=children,parent".
	Depth      *uint   `json:"-" gorm:"-" schema:"_depth" url:"_depth,omitempty"`             // Query parameter, eg: "_depth=3".
	Fuzzy      *bool   `json:"-" gorm:"-" schema:"_fuzzy" url:"_fuzzy,omitempty"`             // Query parameter, eg: "_fuzzy=true"
	SortBy     string  `json:"-" gorm:"-" schema:"_sortby" url:"_sortby,omitempty"`           // Query parameter, eg: "_sortby=name"
	NoCache    bool    `json:"-" gorm:"-" schema:"_nocache" url:"_nocache,omitempty"`         // Query parameter: eg: "_nocache=false"
	ColumnName string  `json:"-" gorm:"-" schema:"_column_name" url:"_column_name,omitempty"` // Query parameter: eg: "_column_name=created_at"
	StartTime  string  `json:"-" gorm:"-" schema:"_start_time" url:"_start_time,omitempty"`   // Query parameter: eg: "_start_time=2024-04-29+23:59:59"
	EndTime    string  `json:"-" gorm:"-" schema:"_end_time" url:"_end_time,omitempty"`       // Query parameter: eg: "_end_time=2024-04-29+23:59:59"
	Or         *bool   `json:"-" gorm:"-" schema:"_or" url:"_or,omitempty"`                   // query parameter: eg: "_or=true"
	Index      string  `json:"-" gorm:"-" schema:"_index" url:"_index,omitempty"`             // Query parameter: eg: "_index=name"
	Select     string  `json:"-" gorm:"-" schema:"_select" url:"_select,omitempty"`           // Query parameter: eg: "_select=field1,field2"

	gorm.Model `json:"-" schema:"-" url:"-"`
}

Base implement types.Model interface. Each model must be expands the Base structure. You can implements your custom method to overwrite the defaults methods.

Usually, there are some gorm tags that may be of interest to you. gorm:"unique" gorm:"foreignKey:ParentID" gorm:"foreignKey:ParentID,references:ID"

func (*Base) CreateAfter

func (*Base) CreateAfter() error

func (*Base) CreateBefore

func (*Base) CreateBefore() error

These methods implement types.Hooker interface. model should create custom hook to overwrite default hooks.

func (*Base) DeleteAfter

func (*Base) DeleteAfter() error

func (*Base) DeleteBefore

func (*Base) DeleteBefore() error

func (*Base) Excludes

func (b *Base) Excludes() map[string][]any

func (*Base) Expands

func (b *Base) Expands() []string

func (*Base) GetAfter

func (*Base) GetAfter() error

func (*Base) GetBefore

func (*Base) GetBefore() error

func (*Base) GetCreatedAt

func (b *Base) GetCreatedAt() time.Time

func (*Base) GetCreatedBy

func (b *Base) GetCreatedBy() string

func (*Base) GetID

func (b *Base) GetID() string

func (*Base) GetTableName

func (b *Base) GetTableName() string

func (*Base) GetUpdatedAt

func (b *Base) GetUpdatedAt() time.Time

func (*Base) GetUpdatedBy

func (b *Base) GetUpdatedBy() string

func (*Base) ListAfter

func (*Base) ListAfter() error

func (*Base) ListBefore

func (*Base) ListBefore() error

func (*Base) MarshalLogObject

func (b *Base) MarshalLogObject(enc zapcore.ObjectEncoder) error

func (*Base) SetCreatedAt

func (b *Base) SetCreatedAt(t time.Time)

func (*Base) SetCreatedBy

func (b *Base) SetCreatedBy(s string)

func (*Base) SetID

func (b *Base) SetID(id ...string)

func (*Base) SetUpdatedAt

func (b *Base) SetUpdatedAt(t time.Time)

func (*Base) SetUpdatedBy

func (b *Base) SetUpdatedBy(s string)

func (*Base) UpdateAfter

func (*Base) UpdateAfter() error

func (*Base) UpdateBefore

func (*Base) UpdateBefore() error

func (*Base) UpdatePartialAfter

func (*Base) UpdatePartialAfter() error

func (*Base) UpdatePartialBefore

func (*Base) UpdatePartialBefore() error

type Board added in v0.0.65

type Board struct {
	Name     string `json:"name,omitempty"`
	Vendor   string `json:"vendor,omitempty"`
	Version  string `json:"version,omitempty"`
	Serial   string `json:"serial,omitempty"`
	AssetTag string `json:"assettag,omitempty"`
}

type CPU added in v0.0.65

type CPU struct {
	Vendor  string `json:"vendor,omitempty"`
	Model   string `json:"model,omitempty"`
	Speed   uint   `json:"speed,omitempty"`   // CPU clock rate in MHz
	Cache   uint   `json:"cache,omitempty"`   // CPU cache size in KB
	Cpus    uint   `json:"cpus,omitempty"`    // number of physical CPUs
	Cores   uint   `json:"cores,omitempty"`   // number of physical CPU cores
	Threads uint   `json:"threads,omitempty"` // number of logical (HT) CPU cores
}

type CasbinRule added in v0.0.66

type CasbinRule struct {
	// ID    uint64 `json:"id" gorm:"primaryKey;autoIncrement"`
	ID    uint64 `json:"id" gorm:"primaryKey"`
	Ptype string `json:"ptype" gorm:"size:100" schema:"ptype"`
	V0    string `json:"v0,omitempty" gorm:"size:100" schema:"v0"`
	V1    string `json:"v1,omitempty" gorm:"size:100" schema:"v1"`
	V2    string `json:"v2,omitempty" gorm:"size:100" schema:"v2"`
	V3    string `json:"v3,omitempty" gorm:"size:100" schema:"v3"`
	V4    string `json:"v4,omitempty" gorm:"size:100" schema:"v4"`
	V5    string `json:"v5,omitempty" gorm:"size:100" schema:"v5"`

	// 当 Ptype 为 g 时, V0 就是用户名, V1 就是角色名
	// 当 Ptype 为 p 时, V0 就是角色名, V1 就是资源, V2 就是操作
	Username    string `json:"username" schema:"username"`
	RoleName    string `json:"role_name" schema:"role_name"`
	MenuName    string `json:"menu_name" schema:"menu_name"`
	IsMenu      bool   `json:"is_menu" schema:"is_menu"` // 这个 casbin_rule 是否是根据菜单创建出来的.
	Description string `json:"description"`

	Base
}

CasbinRule RBAC 包中会通过 gormadapter.NewAdapterByDBWithCustomTable(database.DB, &model.CasbinRule{}) 或 gormadapter.NewAdapterByDB(database.DB) 来创建; NOTE: ID 类型必须是整型

func (*CasbinRule) CreateBefore added in v0.0.66

func (cr *CasbinRule) CreateBefore() error

func (CasbinRule) GetTableName added in v0.0.66

func (cr CasbinRule) GetTableName() string

func (*CasbinRule) UpdateBefore added in v0.0.66

func (cr *CasbinRule) UpdateBefore() error

type Chassis added in v0.0.65

type Chassis struct {
	Type     uint   `json:"type,omitempty"`
	Vendor   string `json:"vendor,omitempty"`
	Version  string `json:"version,omitempty"`
	Serial   string `json:"serial,omitempty"`
	AssetTag string `json:"assettag,omitempty"`
}

type Fixed added in v0.0.66

type Fixed string
const (
	FIXED_RIGHT Fixed = "right"
	FIXED_LEFT  Fixed = "left"
)

type GormScanner

type GormScanner struct {
	Object any
}

func GormScannerWrapper

func GormScannerWrapper(object any) *GormScanner

GormScannerWrapper converts object to GormScanner that can be used in GORM. WARN: you must pass pointer to object.

func (*GormScanner) Scan

func (g *GormScanner) Scan(value any) (err error)

func (*GormScanner) Value

func (g *GormScanner) Value() (driver.Value, error)

type GormStrings

type GormStrings []string

func (*GormStrings) Scan

func (gs *GormStrings) Scan(value any) error

func (GormStrings) Value

func (gs GormStrings) Value() (driver.Value, error)

type GormTime

type GormTime time.Time

func (GormTime) MarshalJSON

func (ct GormTime) MarshalJSON() ([]byte, error)

func (*GormTime) Scan

func (t *GormTime) Scan(value any) error

func (*GormTime) UnmarshalJSON

func (t *GormTime) UnmarshalJSON(b []byte) error

func (GormTime) Value

func (t GormTime) Value() (driver.Value, error)

type Kernel added in v0.0.65

type Kernel struct {
	Release      string `json:"release,omitempty"`
	Version      string `json:"version,omitempty"`
	Architecture string `json:"architecture,omitempty"`
}

type LoginLog added in v0.0.42

type LoginLog struct {
	UserID   string      `json:"user_id" schema:"user_id"`
	Username string      `json:"username" schema:"username"`
	ClientIP string      `json:"client_ip" schema:"client_ip"`
	Token    string      `json:"token" schema:"token"`
	Status   LoginStatus `json:"status" schema:"status"`

	UserAgent
	Base
}

type LoginStatus added in v0.0.42

type LoginStatus string

type Memory added in v0.0.65

type Memory struct {
	Type  string `json:"type,omitempty"`
	Speed uint   `json:"speed,omitempty"` // RAM data rate in MT/s
	Size  uint   `json:"size,omitempty"`  // RAM size in MB
}
type Menu struct {
	Api     string `json:"api,omitempty" schema:"api"` // 后端路由, 如果为空则使用 "/api" + Path
	Path    string `json:"path" schema:"path"`         // path should not add `omitempty` tag, empty value means default router in react route6.x.
	Element string `json:"element,omitempty" schema:"element"`
	Label   string `json:"label,omitempty" schema:"label"`
	Icon    string `json:"icon,omitempty" schema:"icon"`

	Visiable *bool  `json:"visiable" schema:"visiable"`                                                                    // 默认路由
	Default  string `json:"default,omitempty" schema:"default"`                                                            // 自路由中的默认路由, 如果有 Children, Default 才可能存在
	Status   *uint  `json:"status" gorm:"type:smallint;default:1;comment:status(0: disabled, 1: enabled)" schema:"status"` // 该路由是否启用

	ParentId string  `json:"parent_id,omitempty" gorm:"size:191" schema:"parent_id"`
	Children []*Menu `json:"children,omitempty" gorm:"foreignKey:ParentId"`             // 子路由
	Parent   *Menu   `json:"parent,omitempty" gorm:"foreignKey:ParentId;references:ID"` // 父路由

	// the empty value of `Platform` means all.
	Platform MenuPlatform `json:"platform" schema:"platform"`

	DomainPattern string `json:"domain_pattern" schema:"domain_pattern"`

	Base
}

Menu: 菜单 TODO: 加一个 api 用来指定后端路由,如果为空则使用 Path.

func (m *Menu) CreateBefore() (err error)
func (m *Menu) Excludes() map[string][]any
func (m *Menu) Expands() []string
func (m *Menu) GetAfter() (err error)
func (m *Menu) ListAfter() (err error)

ListAfter 可能是只查询最顶层的 Menu,并不能拿到最顶层的 Menu

func (m *Menu) MarshalLogObject(enc zapcore.ObjectEncoder) error
func (m *Menu) UpdateBefore() error
type MenuPlatform string

type NetworkDevice added in v0.0.65

type NetworkDevice struct {
	Name       string `json:"name,omitempty"`
	Driver     string `json:"driver,omitempty"`
	MACAddress string `json:"macaddress,omitempty"`
	Port       string `json:"port,omitempty"`
	Speed      uint   `json:"speed,omitempty"` // device max supported speed in Mbps
}

type NetworkDevices added in v0.0.65

type NetworkDevices []NetworkDevice

func (*NetworkDevices) Scan added in v0.0.65

func (nd *NetworkDevices) Scan(value any) error

func (NetworkDevices) Value added in v0.0.65

func (nd NetworkDevices) Value() (driver.Value, error)

type Node added in v0.0.65

type Node struct {
	Hostname   string `json:"hostname,omitempty"`
	MachineID  string `json:"machineid,omitempty"`
	Hypervisor string `json:"hypervisor,omitempty"`
	Timezone   string `json:"timezone,omitempty"`
}

type OS added in v0.0.65

type OS struct {
	Name         string `json:"name,omitempty"`
	Vendor       string `json:"vendor,omitempty"`
	Version      string `json:"version,omitempty"`
	Release      string `json:"release,omitempty"`
	Architecture string `json:"architecture,omitempty"`
}

type OperationLog

type OperationLog struct {
	User       string        `json:"user,omitempty" schema:"user"`   // 操作者, 本地账号该字段为空,例如 root
	IP         string        `json:"ip,omitempty" schema:"ip"`       // 操作者的 ip
	Op         OperationType `json:"op,omitempty" schema:"op"`       // 动作: 增删改查
	Table      string        `json:"table,omitempty" schema:"table"` // 操作了哪张表
	Model      string        `json:"model,omitempty" schema:"model"`
	RecordId   string        `json:"record_id,omitempty" schema:"record_id"`     // 表记录的 id
	RecordName string        `json:"record_name,omitempty" schema:"record_name"` // 表记录的 name
	Record     string        `json:"record,omitempty" schema:"record"`           // 记录全部内容
	OldRecord  string        `json:"old_record,omitempty"`                       // 更新前的内容
	NewRecord  string        `json:"new_record,omitempty"`                       // 更新后的内容
	Method     string        `json:"method,omitempty" schema:"method"`
	URI        string        `json:"uri,omitempty" schema:"uri"` // request uri
	UserAgent  string        `json:"user_agent,omitempty" schema:"user_agent"`
	RequestId  string        `json:"request_id,omitempty" schema:"request_id"`

	Base
}

type OperationType

type OperationType string
const (
	OperationTypeCreate        OperationType = "create"
	OperationTypeDelete        OperationType = "delete"
	OperationTypeUpdate        OperationType = "update"
	OperationTypeUpdatePartial OperationType = "update_partial"
	OperationTypeList          OperationType = "list"
	OperationTypeGet           OperationType = "get"
	OperationTypeExport        OperationType = "export"
	OperationTypeImport        OperationType = "import"
)

type Product added in v0.0.65

type Product struct {
	Name    string `json:"name,omitempty"`
	Vendor  string `json:"vendor,omitempty"`
	Version string `json:"version,omitempty"`
	Serial  string `json:"serial,omitempty"`
	UUID    string `json:"uuid,omitempty"`
	SKU     string `json:"sku,omitempty"`
}

type Record

type Record struct {
	Table   types.Model
	Rows    any
	Expands []string
	DBName  string
}

Record is table record

type StorageDevice added in v0.0.65

type StorageDevice struct {
	Name   string `json:"name,omitempty"`
	Driver string `json:"driver,omitempty"`
	Vendor string `json:"vendor,omitempty"`
	Model  string `json:"model,omitempty"`
	Serial string `json:"serial,omitempty"`
	Size   uint   `json:"size,omitempty"` // device size in GB
}

type StorageDevices added in v0.0.65

type StorageDevices []StorageDevice

func (*StorageDevices) Scan added in v0.0.65

func (sd *StorageDevices) Scan(value any) error

func (StorageDevices) Value added in v0.0.65

func (sd StorageDevices) Value() (driver.Value, error)

type SysInfo added in v0.0.65

type SysInfo struct {
	Node    Node    `json:"node" gorm:"embedded;embeddedPrefix:node_"`
	OS      OS      `json:"os" gorm:"embedded;embeddedPrefix:os_"`
	Kernel  Kernel  `json:"kernel" gorm:"embedded;embeddedPrefix:kernel_"`
	Product Product `json:"product" gorm:"embedded;embeddedPrefix:product_"`
	Board   Board   `json:"board" gorm:"embedded;embeddedPrefix:board_"`
	Chassis Chassis `json:"chassis" gorm:"embedded;embeddedPrefix:chassis_"`
	BIOS    BIOS    `json:"bios" gorm:"embedded;embeddedPrefix:bios_"`
	CPU     CPU     `json:"cpu" gorm:"embedded;embeddedPrefix:cpu_"`
	Memory  Memory  `json:"memory" gorm:"embedded;embeddedPrefix:memory_"`

	Storages StorageDevices `json:"storages,omitempty"`
	Networks NetworkDevices `json:"networks,omitempty"`

	Base
}

func (*SysInfo) CreateBefore added in v0.0.65

func (si *SysInfo) CreateBefore() error

func (*SysInfo) UpdateBefore added in v0.0.65

func (si *SysInfo) UpdateBefore() error

type TableColumn added in v0.0.66

type TableColumn struct {
	UserId    string `json:"user_id,omitempty" schema:"user_id"`       // 属于哪一个用户的
	TableName string `json:"table_name,omitempty" schema:"table_name"` // 属于哪一张表的
	Name      string `json:"name,omitempty" schema:"name"`             // 列名
	Key       string `json:"key,omitempty" schema:"key"`               // 列名对应的id

	Width    *uint  `json:"width,omitempty"`    // 列宽度
	Sequence *uint  `json:"sequence,omitempty"` // 列顺序
	Visiable *bool  `json:"visiable,omitempty"` // 是否显示
	Fixed    *Fixed `json:"fixed,omitempty"`    // 固定在哪里 left,right, 必须加上 omitempty

	Base
}

TableColumn 表格的列

type User

type User struct {
	Username     string `json:"username,omitempty" gorm:"unique" binding:"required"`
	Name         string `json:"name,omitempty"` // 等同于 username
	EnName       string `json:"en_name,omitempty"`
	Password     string `json:"password,omitempty"`
	RePassword   string `json:"re_password,omitempty" gorm:"-"`
	NewPassword  string `json:"new_password,omitempty" gorm:"-"`
	Email        string `json:"email,omitempty" gorm:"unique"`
	Avatar       string `json:"avatar,omitempty"`
	AvatarUrl    string `json:"avatar_url,omitempty"`    // 用户头像
	AvatarThumb  string `json:"avatar_thumb,omitempty"`  // 用户头像 72x72
	AvatarMiddle string `json:"avatar_middle,omitempty"` // 用户头像 240x240
	AvatarBig    string `json:"avatar_big,omitempty"`    // 用户头像 640x640
	Mobile       string `json:"mobile,omitempty"`
	Nickname     string `json:"nickname,omitempty"`
	Introduction string `json:"introduction,omitempty"`
	Status       uint   `json:"status,omitempty" gorm:"type:smallint;default:1;comment:status(0: disabled, 1: enabled)"`
	// State 员工状态
	// 1 在职
	// 2 离职
	// 3 试用期
	// 4 实习生
	RoleId       string `json:"role_id,omitempty"`
	DepartmentId string `json:"department_id,omitempty"`

	LastLogin  GormTime `json:"last_login,omitempty"`
	LockExpire int64    `json:"lock_expire,omitempty"`
	NumWrong   int      `json:"num_wrong,omitempty" gorm:"comment:the number of input password wrong"`

	Token           string   `json:"token,omitempty" gorm:"-"`
	AccessToken     string   `json:"access_token,omitempty" gorm:"-"`
	RefreshToken    string   `json:"refresh_token,omitempty" gorm:"-"`
	SessionId       string   `json:"session_id,omitempty" gorm:"-"`
	TokenExpiration GormTime `json:"token_expiration,omitempty"`

	Base
}

func (*User) CreateBefore

func (u *User) CreateBefore() error

CreateBefore check whether user mobile is valid.

func (*User) GetAfter

func (u *User) GetAfter() error

GetAfter clean the fields value of Password, RePassword, NewPassword .

func (*User) ListAfter

func (u *User) ListAfter() error

ListAfter clean the fields value of Password, RePassword, NewPassword .

type UserAgent added in v0.0.42

type UserAgent struct {
	Source   string `json:"source" schema:"source"`
	Platform string `json:"platform" schema:"platform"`
	Engine   string `json:"engine" schema:"engine"`
	Browser  string `json:"browser" schema:"browser"`
}

type UserInfo

type UserInfo struct {
	AccessToken      string `json:"access_token,omitempty"`       // user_access_token,用于获取用户资源
	TokenType        string `json:"token_type,omitempty"`         // token 类型
	ExpiresIn        int    `json:"expires_in,omitempty"`         // `access_token`的有效期,单位: 秒
	Name             string `json:"name,omitempty"`               // 用户姓名
	EnName           string `json:"en_name,omitempty"`            // 用户英文名称
	AvatarUrl        string `json:"avatar_url,omitempty"`         // 用户头像
	AvatarThumb      string `json:"avatar_thumb,omitempty"`       // 用户头像 72x72
	AvatarMiddle     string `json:"avatar_middle,omitempty"`      // 用户头像 240x240
	AvatarBig        string `json:"avatar_big,omitempty"`         // 用户头像 640x640
	OpenId           string `json:"open_id,omitempty"`            // 用户在应用内的唯一标识
	UnionId          string `json:"union_id,omitempty"`           // 用户统一ID
	Email            string `json:"email,omitempty"`              // 用户邮箱
	EnterpriseEmail  string `json:"enterprise_email,omitempty"`   // 企业邮箱,请先确保已在管理后台启用飞书邮箱服务
	UserId           string `json:"user_id,omitempty"`            // 用户 user_id
	Mobile           string `json:"mobile,omitempty"`             // 用户手机号
	TenantKey        string `json:"tenant_key,omitempty"`         // 当前企业标识
	RefreshExpiresIn int    `json:"refresh_expires_in,omitempty"` // `refresh_token` 的有效期,单位: 秒
	RefreshToken     string `json:"refresh_token,omitempty"`      // 刷新用户 `access_token` 时使用的 token
	Sid              string `json:"sid,omitempty"`                // 用户当前登录态session的唯一标识,为空则不返回

	Base
}

func (*UserInfo) MarshalLogObject

func (u *UserInfo) MarshalLogObject(enc zapcore.ObjectEncoder) error

Jump to

Keyboard shortcuts

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