article.go
1005 字节
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
package models
import (
"time"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gorm.io/gorm"
)
type Article struct {
Id int64
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt
AuthorId int64 // 发布人
Author domain.UserSimple // 发布人
Title string // 文章标题
Images []domain.Image // 图片
WhoRead []int64 // 谁可以看
WhoReview []int64 // 评论人
Location domain.Location // 坐标
CountLove int // 点赞数量
CountComment int // 评论数量
Tags []int // 标签
// ...more
}
func (m *Article) TableName() string {
return "article"
}
func (m *Article) BeforeCreate(tx *gorm.DB) (err error) {
m.CreatedAt = time.Now()
m.UpdatedAt = time.Now()
return
}
func (m *Article) BeforeUpdate(tx *gorm.DB) (err error) {
m.UpdatedAt = time.Now()
return
}