article_backup.go
1.0 KB
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
package models
import (
"time"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gorm.io/gorm"
)
// 编辑文章后保存的历史记录
type ArticleBackup struct {
Id int64
UpdatedAt time.Time // 更新时间
DeletedAt gorm.DeletedAt //
CreatedAt time.Time //
Operator domain.UserSimple // 操作人
Title string // 标题
Section []domain.ArticleSection // 分段内容
Images []domain.Image // 图片
Action string // 操作
WhoRead []int64 // 谁可以看
WhoReview []int64 // 评论人
Tags []int // 标签
}
func (m *ArticleBackup) TableName() string {
return "article_backup"
}
func (m *ArticleBackup) BeforeCreate(tx *gorm.DB) (err error) {
m.CreatedAt = time.Now()
m.UpdatedAt = time.Now()
return
}
func (m *ArticleBackup) BeforeUpdate(tx *gorm.DB) (err error) {
m.UpdatedAt = time.Now()
return
}