()
| 1647 | } |
| 1648 | |
| 1649 | func (this *DocumentController) Compare() { |
| 1650 | this.TplName = "document/compare.html" |
| 1651 | historyId, _ := strconv.Atoi(this.Ctx.Input.Param(":id")) |
| 1652 | identify := this.Ctx.Input.Param(":key") |
| 1653 | |
| 1654 | bookId := 0 |
| 1655 | //如果是超级管理员则忽略权限判断 |
| 1656 | if this.Member.IsAdministrator() { |
| 1657 | book, err := models.NewBook().FindByFieldFirst("identify", identify) |
| 1658 | if err != nil { |
| 1659 | beego.Error("DocumentController.Compare => ", err) |
| 1660 | this.Abort("404") |
| 1661 | return |
| 1662 | } |
| 1663 | bookId = book.BookId |
| 1664 | this.Data["Model"] = book |
| 1665 | } else { |
| 1666 | bookResult, err := models.NewBookResult().FindByIdentify(identify, this.Member.MemberId) |
| 1667 | |
| 1668 | if err != nil || bookResult.RoleId == conf.BookObserver { |
| 1669 | beego.Error("FindByIdentify => ", err) |
| 1670 | this.Abort("404") |
| 1671 | return |
| 1672 | } |
| 1673 | bookId = bookResult.BookId |
| 1674 | this.Data["Model"] = bookResult |
| 1675 | } |
| 1676 | |
| 1677 | if historyId <= 0 { |
| 1678 | this.JsonResult(60002, "参数错误") |
| 1679 | } |
| 1680 | |
| 1681 | history, err := models.NewDocumentHistory().Find(historyId) |
| 1682 | if err != nil { |
| 1683 | beego.Error("DocumentController.Compare => ", err) |
| 1684 | this.ShowErrorPage(60003, err.Error()) |
| 1685 | } |
| 1686 | doc, err := models.NewDocument().Find(history.DocumentId) |
| 1687 | |
| 1688 | if doc.BookId != bookId { |
| 1689 | this.ShowErrorPage(60002, "参数错误") |
| 1690 | } |
| 1691 | vc := models.NewVersionControl(doc.DocumentId, history.Version) |
| 1692 | this.Data["HistoryId"] = historyId |
| 1693 | this.Data["DocumentId"] = doc.DocumentId |
| 1694 | ModelStore := new(models.DocumentStore) |
| 1695 | this.Data["HistoryContent"] = vc.GetVersionContent(false) |
| 1696 | this.Data["Content"] = ModelStore.GetFiledById(doc.DocumentId, "markdown") |
| 1697 | } |
| 1698 | |
| 1699 | // 递归生成文档序列数组. |
| 1700 | func RecursiveFun(parentId int, prefix, dpath string, this *DocumentController, book *models.BookResult, docs []*models.Document, paths *list.List) { |
nothing calls this directly
no test coverage detected