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

Method RestoreHistory

controllers/DocumentController.go:1596–1647  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1594}
1595
1596func (this *DocumentController) RestoreHistory() {
1597
1598 this.TplName = "document/history.html"
1599
1600 identify := this.GetString("identify")
1601 docId, _ := this.GetInt("doc_id", 0)
1602
1603 historyId, _ := this.GetInt("history_id", 0)
1604 if historyId <= 0 {
1605 this.JsonResult(6001, "参数错误")
1606 }
1607
1608 bookId := 0
1609 //如果是超级管理员则忽略权限判断
1610 if this.Member.IsAdministrator() {
1611 book, err := models.NewBook().FindByFieldFirst("identify", identify)
1612 if err != nil {
1613 beego.Error("FindByIdentify => ", err)
1614 this.JsonResult(6002, "书籍不存在或权限不足")
1615 }
1616 bookId = book.BookId
1617 } else {
1618 bookResult, err := models.NewBookResult().FindByIdentify(identify, this.Member.MemberId)
1619 if err != nil || bookResult.RoleId == conf.BookObserver {
1620 beego.Error("FindByIdentify => ", err)
1621 this.JsonResult(6002, "书籍不存在或权限不足")
1622 }
1623 bookId = bookResult.BookId
1624 }
1625
1626 if docId <= 0 {
1627 this.JsonResult(6001, "参数错误")
1628 }
1629
1630 doc, err := models.NewDocument().Find(docId)
1631
1632 if err != nil {
1633 beego.Error("Delete => ", err)
1634 this.JsonResult(6001, "获取历史失败")
1635 }
1636 //如果文档所属书籍错误
1637 if doc.BookId != bookId {
1638 this.JsonResult(6001, "参数错误")
1639 }
1640
1641 err = models.NewDocumentHistory().Restore(historyId, docId, this.Member.MemberId)
1642 if err != nil {
1643 beego.Error(err)
1644 this.JsonResult(6002, "删除失败")
1645 }
1646 this.JsonResult(0, "ok", doc)
1647}
1648
1649func (this *DocumentController) Compare() {
1650 this.TplName = "document/compare.html"

Callers

nothing calls this directly

Calls 10

NewBookFunction · 0.92
NewBookResultFunction · 0.92
NewDocumentFunction · 0.92
NewDocumentHistoryFunction · 0.92
JsonResultMethod · 0.80
IsAdministratorMethod · 0.80
RestoreMethod · 0.80
FindByFieldFirstMethod · 0.45
FindByIdentifyMethod · 0.45
FindMethod · 0.45

Tested by

no test coverage detected