forked from shen100/mili
/
vote.go
61 lines (55 loc) · 1.99 KB
/
vote.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
package model
import (
"time"
)
// Vote 投票
type Vote struct {
ID uint `gorm:"primary_key" json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt *time.Time `sql:"index" json:"deletedAt"`
EndAt time.Time `json:"endAt"`
Name string `json:"name"`
BrowseCount int `json:"browseCount"`
CommentCount int `json:"commentCount"`
CollectCount int `json:"collectCount"`
Status int `json:"status"`
Content string `json:"content"`
HTMLContent string `json:"htmlContent"`
ContentType int `json:"contentType"`
Comments []Comment `gorm:"ForeignKey:SourceID" json:"comments"`
UserID uint `json:"userID"`
User User `json:"user"`
LastUserID uint `json:"lastUserID"` //最后一个回复投票、参与投票的人
LastUser User `json:"lastUser"`
LastCommentAt *time.Time `json:"lastCommentAt"`
VoteItems []VoteItem `json:"voteItems"`
}
// VoteItem 投票项, 一个投票有多个投票项,用户选择投票项进行投票
type VoteItem struct {
ID uint `gorm:"primary_key" json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt *time.Time `sql:"index" json:"deletedAt"`
Name string `json:"name"`
Count uint `json:"count"`
VoteID uint `json:"voteID"`
}
// UserVote 用户对哪个投票项进行了投票
type UserVote struct {
ID uint `gorm:"primary_key" json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt *time.Time `sql:"index" json:"deletedAt"`
UserID uint `json:"userID"`
User User `json:"user"`
VoteID uint `json:"voteID"`
Vote Vote `json:"vote"`
VoteItemID uint `json:"voteItemID"`
}
const (
// VoteUnderway 进行中
VoteUnderway = 1
// VoteOver 已结束
VoteOver = 2
)