data

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserStatusNormal int = iota
	UserStatusDeleted
)
View Source
const (
	UserCacheExpire = 60 * 60 * 24 // 1 day
)
View Source
const (
	UserMaxFriendCount = 2000 // UserMaxRelationCount is the max count of user relation.
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Friend

type Friend struct {
	ID int64 `gorm:"primary_key"`
	// UID is the user uid of the user.
	UID string `gorm:"column:uid"`
	// FriendUID is the user uid of the friend.
	FriendUID string `gorm:"column:friend_uid"`
	// Status is the status of the relation.
	Status friendpb.FriendStatus `gorm:"column:status"`
	// CreatedAt is the creation time of the relation.
	CreatedAt int64 `gorm:"column:created_at"`
	// UpdatedAt is the update time of the relation.
	UpdatedAt int64 `gorm:"column:updated_at"`
}

Friend is the model of user relation table based on gorm, which is used for user relation management. Friend data stored in mysql.

func (*Friend) IsBlocked

func (ur *Friend) IsBlocked() bool

func (*Friend) IsFriend

func (ur *Friend) IsFriend() bool

func (*Friend) IsStranger

func (ur *Friend) IsStranger() bool

func (*Friend) SetBlocked

func (ur *Friend) SetBlocked() bool

func (*Friend) SetFriend

func (ur *Friend) SetFriend() bool

func (*Friend) SetStatus

func (ur *Friend) SetStatus(status friendpb.FriendStatus) bool

func (*Friend) SetStranger

func (ur *Friend) SetStranger() bool

func (Friend) TableName

func (Friend) TableName() string

func (*Friend) ToProtoFriend

func (ur *Friend) ToProtoFriend() *friendpb.Friend

type FriendRequest

type FriendRequest struct {
	ID        int64                        `gorm:"primary_key"`
	UID       string                       `gorm:"column:uid"`
	FriendUID string                       `gorm:"column:friend_uid"`
	Status    friendpb.FriendRequestStatus `gorm:"column:status"`
	CreatedAt int64                        `gorm:"column:created_at"`
	UpdatedAt int64                        `gorm:"column:updated_at"`
}

FriendRequest is the model of fiend request table based on gorm, which is used for add friend request. FriendRequest data stored in mysql.

func (*FriendRequest) IsAccepted

func (fr *FriendRequest) IsAccepted() bool

func (*FriendRequest) IsRejected

func (fr *FriendRequest) IsRejected() bool

func (*FriendRequest) IsRequested

func (fr *FriendRequest) IsRequested() bool

func (*FriendRequest) SetAccepted

func (fr *FriendRequest) SetAccepted()

func (*FriendRequest) SetRejected

func (fr *FriendRequest) SetRejected()

func (*FriendRequest) SetRequested

func (fr *FriendRequest) SetRequested()

func (*FriendRequest) SetStatus

func (fr *FriendRequest) SetStatus(status friendpb.FriendRequestStatus)

func (FriendRequest) TableName

func (FriendRequest) TableName() string

func (*FriendRequest) ToProto

func (fr *FriendRequest) ToProto() *friendpb.FriendRequest

type User

type User struct {
	ID        int64   `gorm:"primary_key"`
	UID       string  `gorm:"type:varchar(64);unique_index;not null"`
	Name      string  `gorm:"type:varchar(32);not null"`
	Password  string  `gorm:"type:varchar(32);not null"`
	Email     *string `gorm:"type:varchar(32)"`
	Phone     *string `gorm:"type:varchar(32)"`
	Avatar    string  `gorm:"type:varchar(128);not null"`
	Status    int     `gorm:"type:tinyint(1);not null"`
	CreatedAt int64   `gorm:"type:bigint(20);not null;autoCreateTime"`
	UpdatedAt int64   `gorm:"type:bigint(20);not null;autoUpdateTime"`
}

User is the model of user table based on gorm, which contains user basic info. User data stored in mysql.

func (*User) IsDeleted

func (u *User) IsDeleted() bool

func (*User) SetEmail

func (u *User) SetEmail(email string)

func (*User) SetPhone

func (u *User) SetPhone(phone string)

func (User) TableName

func (User) TableName() string

func (*User) ToProtoUserInternal

func (u *User) ToProtoUserInternal() *userv1.UserInternal

Jump to

Keyboard shortcuts

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