Documentation ¶
Overview ¶
Copyright 2019-2020 Axetroy. All rights reserved. Apache License 2.0.
Copyright 2019-2020 Axetroy. All rights reserved. Apache License 2.0.
Copyright 2019-2020 Axetroy. All rights reserved. Apache License 2.0.
Copyright 2019-2020 Axetroy. All rights reserved. Apache License 2.0.
Copyright 2019-2020 Axetroy. All rights reserved. Apache License 2.0.
Copyright 2019-2020 Axetroy. All rights reserved. Apache License 2.0.
Copyright 2019-2020 Axetroy. All rights reserved. Apache License 2.0.
Copyright 2019-2020 Axetroy. All rights reserved. Apache License 2.0.
Copyright 2019-2020 Axetroy. All rights reserved. Apache License 2.0.
Index ¶
- Constants
- Variables
- func DeleteRowByTable(tableName string, field string, value interface{}) (err error)
- type Gender
- type Host
- type HostConnectType
- type HostConnectionRecord
- type HostOwnerType
- type HostRecord
- type HostRecordType
- type InviteState
- type OAuth
- type OAuthProvider
- type Team
- type TeamMember
- type TeamMemberInvite
- type TeamRole
- type User
- type UserStatus
Constants ¶
View Source
const ( HostOwnerTypeUser HostOwnerType = "user" HostOwnerTypeTeam HostOwnerType = "team" HostConnectTypePassword HostConnectType = "password" HostConnectTypePrivateKey HostConnectType = "private_key" )
View Source
const ( // 用户状态 UserStatusBanned UserStatus = -100 // 账号被禁用 UserStatusInactivated UserStatus = -1 // 账号未激活 UserStatusInit UserStatus = 1 // 初始化状态 // 用户性别 GenderUnknown Gender = 0 // 未知性别 GenderMale // 1 男 GenderFemale // 2 女 )
Variables ¶
View Source
var ( Db *gorm.DB Config = config.Database )
Functions ¶
func DeleteRowByTable ¶
Types ¶
type Host ¶
type Host struct { Id string `gorm:"primary_key;not null;unique;index;type:varchar(32);" json:"id"` // 用户ID OwnerID string `gorm:"not null;index;type:varchar(32);" json:"owner_id"` // 拥有者ID,可以是userID,也可以是 teamID User User `gorm:"foreignkey:OwnerID" json:"user"` // **关联外键** Team Team `gorm:"foreignkey:OwnerID" json:"team"` // **关联外键** OwnerType HostOwnerType `gorm:"not null;index;type:varchar(16);" json:"owner_type"` // 拥有者的类型,是个人用户拥有还是组织拥有? Name string `gorm:"not null;type:varchar(32);" json:"name"` // 服务器名 Host string `gorm:"not null;type:varchar(36);index;" json:"host"` // 服务器地址 Port uint `gorm:"not null;index;" json:"port"` // 端口 Username string `gorm:"not null;type:varchar(36);index;" json:"username"` // 用户名 ConnectType HostConnectType `gorm:"not null;type:varchar(36);index;" json:"connect_type"` // 服务器的连接方式 Passport string `gorm:"not null;type:varchar(4096);" json:"passport"` // 密码/密钥 Remark *string `gorm:"null;type:varchar(36);" json:"remark"` // 备注 CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` }
type HostConnectType ¶
type HostConnectType string
type HostConnectionRecord ¶
type HostConnectionRecord struct { Id string `gorm:"primary_key;not null;unique;index;type:varchar(32);" json:"id"` // 随机生成的主键 HostID string `gorm:"not null;index;type:varchar(32);" json:"host_id"` // 服务器 ID Host Host `gorm:"foreignkey:HostID" json:"host"` // **关联外键** UserID string `gorm:"not null;index;type:varchar(32);" json:"user_id"` // 操作者的 ID User User `gorm:"foreignkey:UserID" json:"user"` // **关联外键** Records pq.StringArray `gorm:"not null;type:text[]" json:"records"` // 操作记录 Ip string `gorm:"not null;type:varchar(32);" json:"ip"` // 连接的服务器 CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` }
func (*HostConnectionRecord) BeforeCreate ¶
func (u *HostConnectionRecord) BeforeCreate(scope *gorm.Scope) error
func (*HostConnectionRecord) TableName ¶
func (u *HostConnectionRecord) TableName() string
type HostOwnerType ¶
type HostOwnerType string
type HostRecord ¶
type HostRecord struct { Id string `gorm:"primary_key;not null;unique;index;type:varchar(32);" json:"id"` // 记录 ID UserID string `gorm:"not null;index;type:varchar(32);" json:"user_id"` // 对应的用户 ID HostID string `gorm:"not null;index;type:varchar(32);" json:"host_id"` // 对应的服务器 ID Host Host `gorm:"foreignkey:HostID" json:"host"` // **关联外键** Type HostRecordType `gorm:"not null;index;type:varchar(32);" json:"type"` // 类型 CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` }
func (*HostRecord) BeforeCreate ¶
func (u *HostRecord) BeforeCreate(scope *gorm.Scope) error
func (*HostRecord) TableName ¶
func (u *HostRecord) TableName() string
type HostRecordType ¶
type HostRecordType string
const ( HostRecordTypeOwner HostRecordType = "owner" // 拥有者 HostRecordTypeCollaborator HostRecordType = "collaborator" // 协作者,可查看/连接服务器 HostRecordTypeVisitor HostRecordType = "visitor" // 访客,仅能查看服务器 )
type InviteState ¶
type InviteState string
const ( InviteStateInit InviteState = "init" // 初始的邀请状态,既未接受,也未拒绝 InviteStateAccept InviteState = "accept" // 接受邀请的状态 InviteStateRefuse InviteState = "refuse" // 拒绝邀请的状态 InviteStateCancel InviteState = "cancel" // 由团队管理者取消邀请 InviteStateDeprecated InviteState = "deprecated" // 被系统弃用 )
type OAuth ¶
type OAuth struct { Id string `gorm:"primary_key;unique;not null;index;type:varchar(32)" json:"id"` // ID Provider OAuthProvider `gorm:"not null;index;unique(user_id);type:varchar(32)" json:"provider"` // 绑定的服务提供商 Uid string `gorm:"not null;index;unique(provider);type:varchar(32)" json:"uid"` // 对应的平台 UID // 以下是 oAuth 返回的字段 UserID string `gorm:"not null;type:varchar(255);index" json:"user_id"` // 用户 ID Name string `gorm:"not null;type:varchar(32)" json:"name"` // 用户名 FirstName string `gorm:"not null;type:varchar(32)" json:"first_name"` // 姓 LastName string `gorm:"not null;type:varchar(32)" json:"last_name"` // 名 Nickname string `gorm:"not null;type:varchar(32)" json:"nickname"` // 昵称 Description string `gorm:"not null;type:varchar(255)" json:"description"` // 描述 Email string `gorm:"not null;type:varchar(255)" json:"email"` // 邮箱 AvatarURL string `gorm:"not null;type:varchar(255)" json:"avatar_url"` // 头像 URL Location string `gorm:"not null;type:varchar(255)" json:"location"` // 地址 AccessToken string `gorm:"not null;" json:"access_token"` // Access Token AccessTokenSecret string `gorm:"not null;" json:"access_token_secret"` // Access Token Secret RefreshToken string `gorm:"not null;" json:"refresh_token"` // Refresh Token ExpiresAt time.Time `gorm:"not null;" json:"expires_at"` // 过期时间 CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` }
func (*OAuth) IsValidProvider ¶
type OAuthProvider ¶
type OAuthProvider string
var ( ProviderGithub OAuthProvider = "github" ProviderGitlab OAuthProvider = "gitlab" ProviderTwitter OAuthProvider = "twitter" ProviderFacebook OAuthProvider = "facebook" ProviderGoogle OAuthProvider = "google" )
type Team ¶
type Team struct { Id string `gorm:"primary_key;not null;unique;index;type:varchar(32);" json:"id"` // 团队ID OwnerID string `gorm:"not null;index;type:varchar(32);" json:"owner_id"` // 拥有者 Owner User `gorm:"foreignkey:OwnerID" json:"owner"` // ** 关联外键 ** Name string `gorm:"not null;type:varchar(32);" json:"name"` // 团队名 Remark *string `gorm:"null;type:varchar(36);" json:"remark"` // 备注 CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` }
type TeamMember ¶
type TeamMember struct { Id string `gorm:"primary_key;not null;unique;index;type:varchar(32);" json:"id"` // ID TeamID string `gorm:"not null;index;type:varchar(32);" json:"team_id"` // 团队 ID Team Team `gorm:"foreignkey:TeamID" json:"team"` // ** 关联外键 ** UserID string `gorm:"not null;index;type:varchar(32);" json:"user_id"` // 成员 ID User User `gorm:"foreignkey:UserID" json:"user"` // ** 关联外键 ** Role TeamRole `gorm:"not null;type:varchar(32);" json:"role"` // 在团队中的角色 Remark *string `gorm:"null;type:varchar(36);" json:"remark"` // 备注 CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` }
func (*TeamMember) BeforeCreate ¶
func (t *TeamMember) BeforeCreate(scope *gorm.Scope) error
func (*TeamMember) IsAdmin ¶
func (t *TeamMember) IsAdmin() bool
func (*TeamMember) TableName ¶
func (t *TeamMember) TableName() string
type TeamMemberInvite ¶
type TeamMemberInvite struct { Id string `gorm:"primary_key;not null;unique;index;type:varchar(32);" json:"id"` // ID InvitorID string `gorm:"not null;index;type:varchar(32);" json:"invitor_id"` // 邀请人(发起者) Invitor User `gorm:"foreignkey:InvitorID" json:"invitor"` // 外建关联 TeamID string `gorm:"not null;index;type:varchar(32);" json:"team_id"` // 团队 ID Team Team `gorm:"foreignkey:TeamID" json:"team"` // 外建关联 UserID string `gorm:"not null;index;type:varchar(32);" json:"user_id"` // 成员 ID User User `gorm:"foreignkey:UserID" json:"user"` // 外建关联 Role TeamRole `gorm:"not null;index;type:varchar(32);" json:"role"` // 在团队中的角色 State InviteState `gorm:"not null;index;type:varchar(32);" json:"state"` // 这条邀请记录的状态 Remark *string `gorm:"null;type:varchar(36);" json:"remark"` // 备注 CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` }
func (*TeamMemberInvite) BeforeCreate ¶
func (t *TeamMemberInvite) BeforeCreate(scope *gorm.Scope) error
func (*TeamMemberInvite) TableName ¶
func (t *TeamMemberInvite) TableName() string
type User ¶
type User struct { Id string `gorm:"primary_key;not null;unique;index;type:varchar(32)" json:"id"` // 用户ID Username string `gorm:"not null;type:varchar(36)unique;index" json:"username"` // 用户名 Password string `gorm:"not null;type:varchar(64);index" json:"password"` // 登陆密码 Nickname *string `gorm:"null;type:varchar(36)" json:"nickname"` // 昵称 Phone *string `gorm:"null;unique;type:varchar(16);index" json:"phone"` // 手机号 Email *string `gorm:"null;unique;type:varchar(36);index" json:"email"` // 邮箱 Status UserStatus `gorm:"not null" json:"status"` // 状态 Role pq.StringArray `gorm:"not null;type:varchar(36)[]" json:"role"` // 角色, 用户可以拥有多个角色 Avatar string `gorm:"not null;type:varchar(128)" json:"avatar"` // 头像 Gender Gender `gorm:"not null;default(0)" json:"gender"` // 性别 // 外键关联 OAuth []OAuth `gorm:"foreignkey:Uid" json:"oauth"` // **外键** CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` }
type UserStatus ¶
type UserStatus int32
Click to show internal directories.
Click to hide internal directories.