MCPcopy Index your code
hub / github.com/TruthHun/BookStack / FindToPager

Method FindToPager

models/document_history.go:87–115  ·  view source on GitHub ↗

分页查询指定文档的历史.

(docId, pageIndex, pageSize int)

Source from the content-addressed store, hash-verified

85
86//分页查询指定文档的历史.
87func (m *DocumentHistory) FindToPager(docId, pageIndex, pageSize int) (docs []*DocumentHistorySimpleResult, totalCount int, err error) {
88
89 o := orm.NewOrm()
90
91 offset := (pageIndex - 1) * pageSize
92
93 totalCount = 0
94
95 sql := `SELECT history.*,m1.account,m1.nickname,m2.account as modify_name
96FROM md_document_history AS history
97LEFT JOIN md_members AS m1 ON history.member_id = m1.member_id
98LEFT JOIN md_members AS m2 ON history.modify_at = m2.member_id
99WHERE history.document_id = ? ORDER BY history.history_id DESC LIMIT ?,?;`
100
101 _, err = o.Raw(sql, docId, offset, pageSize).QueryRows(&docs)
102
103 if err != nil {
104 return
105 }
106 var count int64
107 count, err = o.QueryTable(m.TableNameWithPrefix()).Filter("document_id", docId).Count()
108
109 if err != nil {
110 return
111 }
112 totalCount = int(count)
113
114 return
115}
116
117//恢复指定历史的文档.
118func (history *DocumentHistory) Restore(historyId, docId, uid int) (err error) {

Callers

nothing calls this directly

Calls 2

TableNameWithPrefixMethod · 0.95
CountMethod · 0.45

Tested by

no test coverage detected