生成电子书
()
| 833 | |
| 834 | // 生成电子书 |
| 835 | func (this *BookController) Generate() { |
| 836 | identify := this.GetString(":key") |
| 837 | |
| 838 | if !models.NewBook().HasProjectAccess(identify, this.Member.MemberId, conf.BookAdmin) { |
| 839 | this.JsonResult(1, "您没有操作权限,只有书籍创始人和书籍管理员才有权限") |
| 840 | } |
| 841 | |
| 842 | book, err := models.NewBook().FindByIdentify(identify) |
| 843 | if err != nil { |
| 844 | beego.Error(err) |
| 845 | this.JsonResult(1, "书籍不存在") |
| 846 | } |
| 847 | |
| 848 | ebookModel := models.NewEbook() |
| 849 | |
| 850 | // 电子书不是处于完成状态,不允许再添加到电子书生成队列中 |
| 851 | if ok := ebookModel.IsFinish(book.BookId); !ok { |
| 852 | this.JsonResult(1, "电子书生成任务已在处理中,如需再次生成,请您稍后再试。") |
| 853 | } |
| 854 | |
| 855 | // 添加到电子书生成队列 |
| 856 | if err = ebookModel.AddToGenerate(book.BookId); err != nil { |
| 857 | this.JsonResult(1, err.Error()) |
| 858 | } |
| 859 | |
| 860 | this.JsonResult(0, "电子书生成任务已交由后台执行,请您耐心等待。") |
| 861 | } |
| 862 | |
| 863 | // 文档排序. |
| 864 | func (this *BookController) SaveSort() { |
nothing calls this directly
no test coverage detected