2017-04-25 20:05:59 +08:00
|
|
|
package models
|
|
|
|
|
2021-03-26 11:34:02 +08:00
|
|
|
import "github.com/beego/beego/v2/client/orm"
|
2017-04-25 20:05:59 +08:00
|
|
|
|
|
|
|
type Dashboard struct {
|
2018-01-26 17:17:38 +08:00
|
|
|
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{}
|
|
|
|
}
|
|
|
|
|
2018-01-26 17:17:38 +08:00
|
|
|
func (m *Dashboard) Query() *Dashboard {
|
2017-04-25 20:05:59 +08:00
|
|
|
o := orm.NewOrm()
|
|
|
|
|
2018-01-26 17:17:38 +08:00
|
|
|
book_number, _ := o.QueryTable(NewBook().TableNameWithPrefix()).Count()
|
2017-04-25 20:05:59 +08:00
|
|
|
|
|
|
|
m.BookNumber = book_number
|
|
|
|
|
2018-01-26 17:17:38 +08:00
|
|
|
document_count, _ := o.QueryTable(NewDocument().TableNameWithPrefix()).Count()
|
2017-04-25 20:05:59 +08:00
|
|
|
m.DocumentNumber = document_count
|
|
|
|
|
2018-01-26 17:17:38 +08:00
|
|
|
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
|
|
|
|
2018-01-26 17:17:38 +08:00
|
|
|
attachment_number, _ := o.QueryTable(NewAttachment().TableNameWithPrefix()).Count()
|
2017-04-25 20:05:59 +08:00
|
|
|
|
|
|
|
m.AttachmentNumber = attachment_number
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|