forked from mindoc-org/mindoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dashboard.go
38 lines (26 loc) · 1018 Bytes
/
Dashboard.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
package models
import "github.com/beego/beego/v2/client/orm"
type Dashboard struct {
BookNumber int64 `json:"book_number"`
DocumentNumber int64 `json:"document_number"`
MemberNumber int64 `json:"member_number"`
CommentNumber int64 `json:"comment_number"`
AttachmentNumber int64 `json:"attachment_number"`
}
func NewDashboard() *Dashboard {
return &Dashboard{}
}
func (m *Dashboard) Query() *Dashboard {
o := orm.NewOrm()
book_number, _ := o.QueryTable(NewBook().TableNameWithPrefix()).Count()
m.BookNumber = book_number
document_count, _ := o.QueryTable(NewDocument().TableNameWithPrefix()).Count()
m.DocumentNumber = document_count
member_number, _ := o.QueryTable(NewMember().TableNameWithPrefix()).Count()
m.MemberNumber = member_number
//comment_number,_ := o.QueryTable(NewComment().TableNameWithPrefix()).Count()
m.CommentNumber = 0
attachment_number, _ := o.QueryTable(NewAttachment().TableNameWithPrefix()).Count()
m.AttachmentNumber = attachment_number
return m
}