-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
62 lines (52 loc) · 1.6 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package config
import (
"time"
)
// UserForm 用户表单信息
type UserForm struct {
UserId int64 `json:"user_id" gorm:"primaryKey"`
Username string `json:"username"`
Password string `json:"password"`
}
// TableName 自定义表名
func (UserForm) TableName() string {
return "t_users"
}
type Relation struct {
UserId int64 `json:"user_id" gorm:"primary_key"`
ToUserId int64 `json:"to_user_id" gorm:"primary_key"`
User UserForm `gorm:"foreignkey:UserId;foreignkey:ToUserId"` //用户所属用户表外键
}
func (Relation) TableName() string {
return "t_relation"
}
type Video struct {
Id int64 `json:"id" gorm:"primary_key"`
UserId int64 `json:"user_id"`
VideoUrl string `json:"video_url"`
Title string `json:"title"`
VideoCover string `json:"video_cover"`
CreatedAt time.Time `json:"created_at"`
User UserForm `gorm:"foreignkey:UserId"`
}
func (Video) TableName() string {
return "t_video"
}
type Favorite struct {
UserId int64 `json:"user_id" gorm:"primary_key"`
VideoId int64 `json:"video_id" gorm:"primary_key"`
User UserForm `gorm:"foreignkey:UserId""`
Video Video `gorm:"foreignkey:VideoId"`
}
func (Favorite) TableName() string {
return "t_favorite"
}
type Comment struct {
Id int64 `json:"id" gorm:"primary_key"`
UserId int64 `json:"user_id" gorm:"primary_key"`
VideoId int64 `json:"video_id" gorm:"primary_key"`
Content string `json:"content"`
User UserForm `gorm:"foreignkey:UserId""`
Video Video `gorm:"foreignkey:VideoId"`
CreatedAt time.Time `json:"created_at"`
}