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

Method BookInfo

controllers/api/CommonController.go:594–627  ·  view source on GitHub ↗

【OK】

()

Source from the content-addressed store, hash-verified

592
593// 【OK】
594func (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// 返回用户对该章节是否已读
630func (this *CommonController) BookMenu() {

Callers

nothing calls this directly

Calls 12

FindMethod · 0.95
FindByIdentifyMethod · 0.95
NewBookFunction · 0.92
CopyObjectFunction · 0.92
ShowImgFunction · 0.92
NewMemberFunction · 0.92
isLoginMethod · 0.80
ResponseMethod · 0.80
completeLinkMethod · 0.80
GetNicknameByUidMethod · 0.80
BooksProgressMethod · 0.80
DoesStarMethod · 0.80

Tested by

no test coverage detected