分页查询指定文档的历史.
(docId, pageIndex, pageSize int)
| 85 | |
| 86 | //分页查询指定文档的历史. |
| 87 | func (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 |
| 96 | FROM md_document_history AS history |
| 97 | LEFT JOIN md_members AS m1 ON history.member_id = m1.member_id |
| 98 | LEFT JOIN md_members AS m2 ON history.modify_at = m2.member_id |
| 99 | WHERE 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 | //恢复指定历史的文档. |
| 118 | func (history *DocumentHistory) Restore(historyId, docId, uid int) (err error) { |
nothing calls this directly
no test coverage detected