Documentation
¶
Index ¶
- Constants
- func Create(entity *EntityComplete) error
- func ExistEmail(email string) bool
- func ExistUsername(username string) bool
- func GetMapByIds(userIds []uint64) map[uint64]*EntityComplete
- func GetMaxId() uint64
- func IncrementPrestige(addNumber int64, userId uint64) int64
- func Page(q PageQuery) struct{ ... }
- func RandAvatarUrl() string
- func Save(entity *EntityComplete) error
- func UpdateWornBadgeCode(userID uint64, badgeCode string) error
- type EntityComplete
- func All() (entities []*EntityComplete)
- func Get(id any) (entity EntityComplete, err error)
- func GetByEmail(email string) (entity EntityComplete, err error)
- func GetByIds(userIds []uint64) (entities []*EntityComplete)
- func GetByUsername(username string) (entity EntityComplete, err error)
- func MakeUser(name string, password string, email string) *EntityComplete
- func Verify(usernameOrEmail string, password string) (*EntityComplete, error)
- type ExternalInformation
- type ExternalInformationItem
- type PageQuery
- type PublicPageQuery
- type PublicPageResult
Constants ¶
View Source
const ( StatusNormal = 0 StatusFrozen = 1 )
View Source
const ( ActivationPending = 0 ActivationSuccess = 1 )
Variables ¶
This section is empty.
Functions ¶
func Create ¶
func Create(entity *EntityComplete) error
func GetMapByIds ¶
func GetMapByIds(userIds []uint64) map[uint64]*EntityComplete
func IncrementPrestige ¶
func Page ¶
func Page(q PageQuery) struct { Page int PageSize int Total int64 Data []EntityComplete }
func RandAvatarUrl ¶ added in v0.0.6
func RandAvatarUrl() string
func Save ¶
func Save(entity *EntityComplete) error
func UpdateWornBadgeCode ¶ added in v0.2.43
Types ¶
type EntityComplete ¶ added in v0.0.7
type EntityComplete struct {
// base
Id uint64 `gorm:"primaryKey;column:id;autoIncrement;not null;" json:"id"` //
Username string `gorm:"column:username;index;type:varchar(64);not null;default:'';" json:"username"` //
Email string `gorm:"column:email;index;type:varchar(128);not null;default:'';" json:"email"` //
Password string `gorm:"column:password;type:varchar(128);not null;default:'';" json:"-"` //
TokenVersion uint64 `gorm:"column:token_version;type:bigint unsigned;not null;default:0;" json:"-"` // 登录令牌版本,改密后自增
Locale string `gorm:"column:locale;type:varchar(16);not null;default:'';" json:"locale"` // 用户语言偏好
IsFrozen int8 `gorm:"column:is_frozen;type:tinyint;not null;default:0;" json:"isFrozen"` // 状态:0正常 1冻结
IsActivated int8 `gorm:"column:is_activated;type:tinyint;not null;default:0;" json:"isActivated"` // 是否验证通过: 0未激活 1 已激活
ActivatedAt *time.Time `gorm:"column:activated_at;type:datetime;" json:"activatedAt"` // 激活时间
// info
Nickname string `gorm:"column:nickname;type:varchar(64);not null;default:'';" json:"nickname"` //
RoleId uint64 `gorm:"column:role_id;type:bigint unsigned;not null;default:0;" json:"roleId"` //
Prestige int64 `gorm:"column:prestige;type:bigint;not null;default:0;" json:"prestige"` // 声望
AvatarUrl string `gorm:"column:avatar_url;type:varchar(255);" json:"avatarUrl"` // 头像URL
ProfileCoverUrl string `gorm:"column:profile_cover_url;type:varchar(512);not null;default:'';" json:"profileCoverUrl"` // 个人主页封面URL
Bio string `gorm:"column:bio;type:varchar(500);not null;default:'';" json:"bio"` // 个人简介
Signature string `gorm:"column:signature;type:varchar(255);not null;default:'';" json:"signature"` // 署名
WebsiteName string `gorm:"column:website_name;type:varchar(64);not null;default:'';" json:"websiteName"` // 个人网站名
Website string `gorm:"column:website;type:varchar(255);not null;default:'';" json:"website"` // 个人网站
ExternalInformation ExternalInformation `gorm:"column:external_information;type:varchar(2048);default:'{}';serializer:json" json:"externalInformation"` // 外部信息
WornBadgeCode string `gorm:"column:worn_badge_code;type:varchar(64);not null;default:'';" json:"wornBadgeCode"` // 当前佩戴的徽章
// status
CreatedAt time.Time `gorm:"column:created_at;index;autoCreateTime;<-:create;" json:"createdAt"` //
UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime;" json:"updatedAt"`
DeletedAt gorm.DeletedAt //
}
func All ¶
func All() (entities []*EntityComplete)
func Get ¶
func Get(id any) (entity EntityComplete, err error)
func GetByEmail ¶ added in v0.0.3
func GetByEmail(email string) (entity EntityComplete, err error)
GetByEmail 通过邮箱获取用户
func GetByIds ¶
func GetByIds(userIds []uint64) (entities []*EntityComplete)
func GetByUsername ¶
func GetByUsername(username string) (entity EntityComplete, err error)
func (*EntityComplete) Activate ¶ added in v0.0.7
func (itself *EntityComplete) Activate()
func (*EntityComplete) GetWebAvatarUrl ¶ added in v0.0.7
func (itself *EntityComplete) GetWebAvatarUrl() string
func (*EntityComplete) SetPassword ¶ added in v0.0.7
func (itself *EntityComplete) SetPassword(password string) *EntityComplete
func (*EntityComplete) TableName ¶ added in v0.0.7
func (itself *EntityComplete) TableName() string
type ExternalInformation ¶ added in v0.0.3
type ExternalInformation struct {
Github ExternalInformationItem `json:"github"`
Weibo ExternalInformationItem `json:"weibo"`
Bilibili ExternalInformationItem `json:"bilibili"`
Twitter ExternalInformationItem `json:"twitter"`
LinkedIn ExternalInformationItem `json:"linkedIn"`
Zhihu ExternalInformationItem `json:"zhihu"`
}
type ExternalInformationItem ¶ added in v0.0.3
type ExternalInformationItem struct {
Link string `json:"link"`
}
type PublicPageQuery ¶ added in v0.2.68
type PublicPageResult ¶ added in v0.2.68
type PublicPageResult struct {
HasPrevious bool
HasNext bool
Data []EntityComplete
}
func PublicPage ¶ added in v0.2.68
func PublicPage(q PublicPageQuery) PublicPageResult
PublicPage returns only the columns needed by the public member directory. Controllers still decide the final public payload shape.
Click to show internal directories.
Click to hide internal directories.