mindoc/models/Dashboard.go

39 lines
1018 B
Go
Raw Permalink Normal View History

2017-04-25 20:05:59 +08:00
package models
import "github.com/beego/beego/v2/client/orm"
2017-04-25 20:05:59 +08:00
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"`
2017-04-25 20:05:59 +08:00
}
func NewDashboard() *Dashboard {
return &Dashboard{}
}
func (m *Dashboard) Query() *Dashboard {
2017-04-25 20:05:59 +08:00
o := orm.NewOrm()
book_number, _ := o.QueryTable(NewBook().TableNameWithPrefix()).Count()
2017-04-25 20:05:59 +08:00
m.BookNumber = book_number
document_count, _ := o.QueryTable(NewDocument().TableNameWithPrefix()).Count()
2017-04-25 20:05:59 +08:00
m.DocumentNumber = document_count
member_number, _ := o.QueryTable(NewMember().TableNameWithPrefix()).Count()
2017-04-25 20:05:59 +08:00
m.MemberNumber = member_number
2017-05-04 14:31:08 +08:00
//comment_number,_ := o.QueryTable(NewComment().TableNameWithPrefix()).Count()
m.CommentNumber = 0
2017-04-25 20:05:59 +08:00
attachment_number, _ := o.QueryTable(NewAttachment().TableNameWithPrefix()).Count()
2017-04-25 20:05:59 +08:00
m.AttachmentNumber = attachment_number
return m
}