users

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(entity *Entity) error

func ExistEmail

func ExistEmail(email string) bool

ExistEmail 检查邮箱是否已存在

func ExistUsername

func ExistUsername(username string) bool

ExistUsername 检查用户名是否已存在

func GetCount

func GetCount() int64

func GetMapByIds

func GetMapByIds(userIds []uint64) map[uint64]*Entity

func GetMaxId

func GetMaxId() uint64

func GetMonthCount added in v0.0.3

func GetMonthCount() int64

func IncrementPrestige

func IncrementPrestige(addNumber int64, userId uint64) int64

func Page

func Page(q PageQuery) struct {
	Page     int
	PageSize int
	Total    int64
	Data     []Entity
}

func Save

func Save(entity *Entity) error

Types

type Entity

type Entity struct {
	Id                  uint64     `gorm:"primaryKey;column:id;autoIncrement;not null;" json:"id"`                       //
	Username            string     `gorm:"column:username;index;type:varchar(255);not null;default:'';" json:"username"` //
	Nickname            string     `gorm:"column:nickname;type:varchar(255);not null;default:'';" json:"nickname"`       //
	Email               string     `gorm:"column:email;index;type:varchar(255);not null;default:'';" json:"email"`       //
	Password            string     `gorm:"column:password;type:varchar(255);not null;default:'';" json:"password"`       //
	MobileAreaCode      string     `gorm:"column:mobile_area_code;type:varchar(16);" json:"mobileAreaCode"`              //
	MobilePhoneNumber   string     `gorm:"column:mobile_phone_number;type:varchar(64);" json:"mobilePhoneNumber"`        //
	RoleId              uint64     `gorm:"column:role_id;type:bigint unsigned;not null;default:0;" json:"roleId"`        //
	Status              int8       `gorm:"column:status;type:tinyint;not null;default:0;" json:"status"`                 // 状态:0正常 1冻结
	Validate            int8       `gorm:"column:validate;type:tinyint;not null;default:0;" json:"validate"`             // 是否验证通过: 0未通过/未验证 1 验证通过
	ActivatedAt         time.Time  `gorm:"column:activated_at;type:datetime;" json:"activatedAt"`                        // 激活时间
	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
	Bio                 string     `gorm:"column:bio;type:varchar(500);" json:"bio"`                                     // 个人简介
	Signature           string     `gorm:"column:signature;type:varchar(255);" json:"signature"`                         // 署名
	Website             string     `gorm:"column:website;type:varchar(255);" json:"website"`                             // 个人网站
	WebsiteName         string     `gorm:"column:website_name;type:varchar(64);" json:"websiteName"`                     // 个人网站名
	ExternalInformation string     `gorm:"column:external_information;type:varchar(2048);" json:"externalInformation"`   // 外部信息
	CreatedAt           time.Time  `gorm:"column:created_at;index;autoCreateTime;<-:create;" json:"createdAt"`           //
	UpdatedAt           time.Time  `gorm:"column:updated_at;autoUpdateTime;" json:"updatedAt"`
	DeletedAt           *time.Time `gorm:"column:deleted_at;type:datetime;" json:"deletedAt"` //
}

func All

func All() (entities []*Entity)

func Get

func Get(id any) (entity Entity, err error)

func GetByEmail added in v0.0.3

func GetByEmail(email string) (entity Entity, err error)

GetByEmail 通过邮箱获取用户

func GetByIds

func GetByIds(userIds []uint64) (entities []*Entity)

func GetByUsername

func GetByUsername(username string) (entities *Entity)

func MakeUser

func MakeUser(name string, password string, email string) *Entity

func QueryById added in v0.0.3

func QueryById(startId uint64, limit int) (entities []*Entity)

func Verify

func Verify(usernameOrEmail string, password string) (*Entity, error)

func (*Entity) Activate

func (itself *Entity) Activate() error

func (*Entity) GetExternalInformation added in v0.0.3

func (itself *Entity) GetExternalInformation() ExternalInformation

func (*Entity) GetShowName added in v0.0.3

func (itself *Entity) GetShowName() string

func (*Entity) GetWebAvatarUrl

func (itself *Entity) GetWebAvatarUrl() string

func (*Entity) SetExternalInformation added in v0.0.3

func (itself *Entity) SetExternalInformation(info ExternalInformation)

func (*Entity) SetPassword

func (itself *Entity) SetPassword(password string) *Entity

func (*Entity) TableName

func (itself *Entity) 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"`
}

func (*ExternalInformation) Scan added in v0.0.3

func (itself *ExternalInformation) Scan(value any) error

func (*ExternalInformation) Value added in v0.0.3

func (itself *ExternalInformation) Value() (driver.Value, error)

type ExternalInformationItem added in v0.0.3

type ExternalInformationItem struct {
	Link string `json:"link"`
}

type PageQuery

type PageQuery struct {
	Page, PageSize int
	Username       string
	UserId         uint64
	Email          string
}

Jump to

Keyboard shortcuts

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