models

package
v0.0.0-...-bd2a5d7 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	CustomBaseModel
	VideoID int64  `gorm:"not null"`
	Video   Video  `gorm:"foreignKey:VideoID"`
	UserID  int64  `gorm:"not null"`
	User    User   `gorm:"foreignKey:UserID"`
	Content string `gorm:"type:varchar(255);not null" json:"content"`
}

type CustomBaseModel

type CustomBaseModel struct {
	ID        int64 `gorm:"primaryKey"`
	CreatedAt int64
	UpdatedAt int64
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

type OtherInfo

type OtherInfo struct {
	ID             int64 `gorm:"primaryKey" json:"id"`
	FollowCount    int64 `gorm:"type:bigint;default:0" json:"follow_count"`
	FollowerCount  int64 `gorm:"type:bigint;default:0" json:"follower_count"`
	FavoriteCount  int64 `gorm:"type:bigint;default:0" json:"favorite_count"`
	TotalFavorited int64 `gorm:"type:bigint;default:0" json:"total_favorited"`
	WorkCount      int64 `gorm:"type:bigint;default:0" json:"work_count"`
}

type User

type User struct {
	CustomBaseModel
	Username        string    `gorm:"type:varchar(255);not null;unique" json:"username" binding:"required"`
	Password        string    `gorm:"type:varchar(255);not null" json:"password" binding:"required"`
	Avatar          string    `gorm:"type:varchar(255)" json:"avatar"`
	BackgroundImage string    `gorm:"type:varchar(255)" json:"background_image"`
	Signature       string    `gorm:"type:varchar(255)" json:"signature"`
	OtherInfoID     int64     // 其他信息的id,为外键
	OtherInfo       OtherInfo // belongs to 关系

	Follower []User `gorm:"many2many:user_follower;"` // 自引用的many to many关系,表示user的跟随着

	FavoriteVideo []Video `gorm:"many2many:user_favorite"`
}

type Video

type Video struct {
	CustomBaseModel
	PlayURL       string `gorm:"type:varchar(255)" json:"play_url"`
	CoverURL      string `gorm:"type:varchar(255)" json:"cover_url"`
	FavoriteCount int64  `gorm:"type:bigint" json:"favorite_count"`
	CommentCount  int64  `gorm:"type:bigint" json:"comment_count"`
	Title         string `gorm:"type:varchar(255)" json:"title"`
	AuthorID      int64  `json:"author_id"`
	User          User   `gorm:"foreignKey:AuthorID"`
}

Video 视频的model,与数据库保持一致

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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