发布书籍.
()
| 799 | |
| 800 | // 发布书籍. |
| 801 | func (this *BookController) Release() { |
| 802 | identify := this.GetString("identify") |
| 803 | force, _ := this.GetBool("force") |
| 804 | bookId := 0 |
| 805 | if this.Member.IsAdministrator() { |
| 806 | book, err := models.NewBook().FindByFieldFirst("identify", identify) |
| 807 | if err != nil { |
| 808 | beego.Error(err) |
| 809 | } |
| 810 | bookId = book.BookId |
| 811 | } else { |
| 812 | book, err := models.NewBookResult().FindByIdentify(identify, this.Member.MemberId) |
| 813 | if err != nil { |
| 814 | if err == models.ErrPermissionDenied { |
| 815 | this.JsonResult(6001, "权限不足") |
| 816 | } |
| 817 | if err == orm.ErrNoRows { |
| 818 | this.JsonResult(6002, "书籍不存在") |
| 819 | } |
| 820 | beego.Error(err) |
| 821 | this.JsonResult(6003, "未知错误") |
| 822 | } |
| 823 | if book.RoleId != conf.BookAdmin && book.RoleId != conf.BookFounder && book.RoleId != conf.BookEditor { |
| 824 | this.JsonResult(6003, "权限不足") |
| 825 | } |
| 826 | bookId = book.BookId |
| 827 | } |
| 828 | |
| 829 | go models.NewDocument().ReleaseContent(bookId, this.BaseUrl(), force) |
| 830 | |
| 831 | this.JsonResult(0, "发布任务已推送到任务队列,稍后将在后台执行。") |
| 832 | } |
| 833 | |
| 834 | // 生成电子书 |
| 835 | func (this *BookController) Generate() { |
nothing calls this directly
no test coverage detected