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

Method History

controllers/DocumentController.go:1476–1540  ·  view source on GitHub ↗

文档历史列表.

()

Source from the content-addressed store, hash-verified

1474
1475// 文档历史列表.
1476func (this *DocumentController) History() {
1477
1478 this.TplName = "document/history.html"
1479
1480 identify := this.GetString("identify")
1481 docId, _ := this.GetInt("doc_id", 0)
1482 pageIndex, _ := this.GetInt("page", 1)
1483
1484 bookId := 0
1485 //如果是超级管理员则忽略权限判断
1486 if this.Member.IsAdministrator() {
1487 book, err := models.NewBook().FindByFieldFirst("identify", identify)
1488 if err != nil {
1489 beego.Error("FindByIdentify => ", err)
1490 this.Data["ErrorMessage"] = "书籍不存在或权限不足"
1491 return
1492 }
1493 bookId = book.BookId
1494 this.Data["Model"] = book
1495 } else {
1496 bookResult, err := models.NewBookResult().FindByIdentify(identify, this.Member.MemberId)
1497
1498 if err != nil || bookResult.RoleId == conf.BookObserver {
1499 beego.Error("FindByIdentify => ", err)
1500 this.Data["ErrorMessage"] = "书籍不存在或权限不足"
1501 return
1502 }
1503 bookId = bookResult.BookId
1504 this.Data["Model"] = bookResult
1505 }
1506
1507 if docId <= 0 {
1508 this.Data["ErrorMessage"] = "参数错误"
1509 return
1510 }
1511
1512 doc, err := models.NewDocument().Find(docId)
1513
1514 if err != nil {
1515 beego.Error("Delete => ", err)
1516 this.Data["ErrorMessage"] = "获取历史失败"
1517 return
1518 }
1519 //如果文档所属书籍错误
1520 if doc.BookId != bookId {
1521 this.Data["ErrorMessage"] = "参数错误"
1522 return
1523 }
1524
1525 histories, totalCount, err := models.NewDocumentHistory().FindToPager(docId, pageIndex, conf.PageSize)
1526 if err != nil {
1527 beego.Error("FindToPager => ", err)
1528 this.Data["ErrorMessage"] = "获取历史失败"
1529 return
1530 }
1531
1532 this.Data["List"] = histories
1533 this.Data["PageHtml"] = ""

Callers

nothing calls this directly

Calls 10

NewBookFunction · 0.92
NewBookResultFunction · 0.92
NewDocumentFunction · 0.92
NewDocumentHistoryFunction · 0.92
GetPagerHtmlFunction · 0.92
IsAdministratorMethod · 0.80
FindByFieldFirstMethod · 0.45
FindByIdentifyMethod · 0.45
FindMethod · 0.45
FindToPagerMethod · 0.45

Tested by

no test coverage detected