db

package
v0.0.0-...-d63e0d4 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

Functions

func Create

func Create(ctx context.Context, currentId int64, toUserId int64) error

增加当前用户的关注总数,增加其他用户的粉丝总数,创建关注记录

func Delete

func Delete(ctx context.Context, currentId int64, toUserId int64) error

减少当前用户的关注总数,减少其他用户的粉丝总数,删除关注记录

func Init

func Init()

func QueryRelationByIds

func QueryRelationByIds(ctx context.Context, currentId int64, userIds []int64) (map[int64]*RelationRaw, error)

Types

type RelationRaw

type RelationRaw struct {
	gorm.Model
	UserId   int64 `gorm:"column:user_id;not null;index:idx_userid"`
	ToUserId int64 `gorm:"column:to_user_id;not null;index:idx_touserid"`
}

func QueryFollowById

func QueryFollowById(ctx context.Context, userId int64) ([]*RelationRaw, error)

通过用户id,查询该用户关注的用户,返回两者之间的关注记录

func QueryFollowerById

func QueryFollowerById(ctx context.Context, userId int64) ([]*RelationRaw, error)

通过用户id,查询该用户的粉丝, 返回两者之间的关注记录

func (RelationRaw) TableName

func (RelationRaw) TableName() string

type UserRaw

type UserRaw struct {
	gorm.Model
	Name            string `gorm:"column:name;index:idx_username,unique;type:varchar(32);not null"`
	Password        string `gorm:"column:password;type:varchar(32);not null"`
	FollowCount     int64  `gorm:"column:follow_count;default:0"`
	FollowerCount   int64  `gorm:"column:follower_count;default:0"`
	Avatar          string `gorm:"column:avatar,type:varchar(100);not null"`           // 用户头像
	BackgroundImage string `gorm:"column:background_image,type:varchar(100);not null"` // 用户个人页顶部大图
	Signature       string `gorm:"column:signature,type:varchar(1000);not null"`       // 个人简介
	TotalFavorited  string `gorm:"column:total_favorited;type:varchar(1000);not null"` // 获赞数量
	WorkCount       int64  `gorm:"column:work_count;default:0"`                        // 作品数量
	FavoriteCount   int64  `gorm:"column:favorite_count;default:0"`                    // 点赞数量
}

func QueryUserByIds

func QueryUserByIds(ctx context.Context, userIds []int64) ([]*UserRaw, error)

func (UserRaw) TableName

func (UserRaw) TableName() string

Jump to

Keyboard shortcuts

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