user

package
v0.0.0-...-e2d16e5 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2024 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CollectionName = "user"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type IMongoMapper

type IMongoMapper interface {
	Insert(ctx context.Context, data *User) error
	FindOne(ctx context.Context, id string) (*User, error)
	Update(ctx context.Context, data *User) error
	Delete(ctx context.Context, id string) error
	UpsertUser(ctx context.Context, data *User) error
	FindOneNoCache(ctx context.Context, id string) (*User, error)
}

IMongoMapper is an interface to be customized, add more methods here, and implement the added methods in MongoMapper.

func NewMongoMapper

func NewMongoMapper(config *config.Config) IMongoMapper

type Membership

type Membership struct {
	MemberId    string `bson:"memberId,omitempty" json:"memberId,omitempty"`
	MemberLevel int32  `bson:"memberLevel,omitempty" json:"memberLevel,omitempty"` // 0: 普通用户, 1: 普通会员, 2: 高级会员
}

type MongoMapper

type MongoMapper struct {
	// contains filtered or unexported fields
}

func (*MongoMapper) Delete

func (m *MongoMapper) Delete(ctx context.Context, id string) error

func (*MongoMapper) FindOne

func (m *MongoMapper) FindOne(ctx context.Context, id string) (*User, error)

func (*MongoMapper) FindOneNoCache

func (m *MongoMapper) FindOneNoCache(ctx context.Context, id string) (*User, error)

func (*MongoMapper) Insert

func (m *MongoMapper) Insert(ctx context.Context, data *User) error

func (*MongoMapper) Update

func (m *MongoMapper) Update(ctx context.Context, data *User) error

func (*MongoMapper) UpsertUser

func (m *MongoMapper) UpsertUser(ctx context.Context, data *User) error

type StorageInfo

type StorageInfo struct {
	AvailablePhotos int32 `bson:"availablePhotos,omitempty" json:"availablePhotos,omitempty"`
	UsedPhotos      int32 `bson:"usedPhotos,omitempty" json:"usedPhotos,omitempty"`
	AvailableMemory int64 `bson:"availableMemory,omitempty" json:"availableMemory,omitempty"`
	UsedMemory      int64 `bson:"usedMemory,omitempty" json:"usedMemory,omitempty"`
	AvailableAlbums int32 `bson:"availableAlbums,omitempty" json:"availableAlbums,omitempty"`
	UsedAlbums      int32 `bson:"usedAlbums,omitempty" json:"usedAlbums,omitempty"`
}

type User

type User struct {
	ID                 primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
	Nickname           string             `bson:"username,omitempty" json:"username,omitempty"`
	Bio                string             `bson:"bio,omitempty" json:"bio,omitempty"`
	Avatar             string             `bson:"avatar,omitempty" json:"avatar,omitempty"`
	UpdatedAt          time.Time          `bson:"updatedAt,omitempty" json:"updatedAt,omitempty"`
	CreatedAt          time.Time          `bson:"createdAt,omitempty" json:"createdAt,omitempty"`
	DeletedAt          time.Time          `bson:"deletedAt,omitempty" json:"deletedAt,omitempty"`
	Membership         *Membership        `bson:"membership,omitempty" json:"membership,omitempty"`
	TeamCount          int32              `bson:"teamCount,omitempty" json:"teamCount,omitempty"`
	TeamIds            []string           `bson:"teamIds,omitempty" json:"teamIds,omitempty"`
	MyAlbumCount       int32              `bson:"myAlbumCount,omitempty" json:"myAlbumCount,omitempty"`
	MyAlbumIds         []int32            `bson:"myAlbumIds,omitempty" json:"myAlbumIds,omitempty"`
	FollowedAlbumCount int32              `bson:"followedAlbumCount,omitempty" json:"followedAlbumCount,omitempty"`
	FollowedAlbumIds   []int32            `bson:"followedAlbumIds,omitempty" json:"followedAlbumIds,omitempty"`
	StorageInfo        *StorageInfo       `bson:"storageInfo,omitempty" json:"storageInfo,omitempty"`
	Points             int32              `bson:"points,omitempty" json:"points,omitempty"`
	Achievements       []string           `bson:"achievements,omitempty" json:"achievements,omitempty"`
}

type UserPreview

type UserPreview struct {
	ID       primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
	Nickname string             `bson:"nickname,omitempty" json:"nickname,omitempty"`
	Avatar   string             `bson:"avatar,omitempty" json:"avatar,omitempty"`
}

Jump to

Keyboard shortcuts

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