8 Star 4 Fork 0

陈可桐 / 字节跳动青训营-仿造简易抖音

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
models.go 1.00 KB
一键复制 编辑 原始数据 按行查看 历史
陈可桐 提交于 2022-06-09 10:56 . 修改数据库模型
package models
import "gorm.io/gorm"
type User struct {
gorm.Model
Name string `gorm:"uniqueIndex;size:10"`
Password string `gorm:"size:60"`
Content string `gorm:"size:50"`
Videos []Video `gorm:"ForeignKey:AuthorID"`
Comments []Comment `gorm:"many2many:comments;joinForeignKey:UserID"`
FavoriteVideos []Video `gorm:"many2many:user_favorite_videos"`
Subscribers []User `gorm:"joinForeignKey:UserID;many2many:subscribes"`
Followers []User `gorm:"joinForeignKey:SubscriberID;many2many:subscribes"`
}
type Subscribe struct {
UserID uint
SubscriberID uint
}
type Video struct {
gorm.Model
AuthorID uint
Title string `gorm:"size:30"`
Author User `gorm:"reference:ID"`
UserFavorites []User `gorm:"many2many:user_favorite_videos"`
Comments []Comment `gorm:"many2many:comments;joinForeignKey:VideoID"`
}
type Comment struct {
gorm.Model
UserID uint
VideoID uint
Content string `gorm:"index;size:100"`
}
Go
1
https://gitee.com/Whitroom/imitate-tiktok.git
git@gitee.com:Whitroom/imitate-tiktok.git
Whitroom
imitate-tiktok
字节跳动青训营-仿造简易抖音
3ac9adb29a57

搜索帮助

53164aa7 5694891 3bd8fe86 5694891