【OK】
()
| 592 | |
| 593 | // 【OK】 |
| 594 | func (this *CommonController) BookInfo() { |
| 595 | var ( |
| 596 | book *models.Book |
| 597 | err error |
| 598 | apiBook APIBook |
| 599 | ) |
| 600 | |
| 601 | identify := this.GetString("identify") |
| 602 | model := models.NewBook() |
| 603 | id, _ := strconv.Atoi(identify) |
| 604 | |
| 605 | if id > 0 { |
| 606 | book, err = model.Find(id) |
| 607 | } else { |
| 608 | book, err = model.FindByIdentify(identify) |
| 609 | } |
| 610 | if err != nil { |
| 611 | beego.Error(err.Error()) |
| 612 | } |
| 613 | |
| 614 | if book.BookId == 0 || (book.PrivatelyOwned == 1 && this.isLogin() != book.MemberId) { |
| 615 | this.Response(http.StatusNotFound, messageNotFound) |
| 616 | } |
| 617 | |
| 618 | utils.CopyObject(book, &apiBook) |
| 619 | |
| 620 | apiBook.Cover = this.completeLink(utils.ShowImg(apiBook.Cover, "cover")) |
| 621 | apiBook.User = models.NewMember().GetNicknameByUid(book.MemberId) |
| 622 | apiBook.DocReaded = new(models.ReadRecord).BooksProgress(this.isLogin(), apiBook.BookId)[apiBook.BookId] // 这里的map是一定会有值,所以这样取值 |
| 623 | if this.isLogin() > 0 { |
| 624 | apiBook.IsStar = new(models.Star).DoesStar(this.isLogin(), apiBook.BookId) |
| 625 | } |
| 626 | this.Response(http.StatusOK, messageSuccess, map[string]interface{}{"book": apiBook}) |
| 627 | } |
| 628 | |
| 629 | // 返回用户对该章节是否已读 |
| 630 | func (this *CommonController) BookMenu() { |
nothing calls this directly
no test coverage detected