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

Method BookLists

controllers/api/CommonController.go:680–713  ·  view source on GitHub ↗

【OK】

()

Source from the content-addressed store, hash-verified

678
679// 【OK】
680func (this *CommonController) BookLists() {
681 sort := this.GetString("sort", "new") // new、recommend、hot、pin
682 page, _ := this.GetInt("page", 1)
683 cid, _ := this.GetInt("cid")
684 lang := this.GetString("lang")
685 size, _ := this.GetInt("size", 10)
686
687 if page <= 0 {
688 page = 1
689 }
690
691 size = utils.RangeNumber(size, 10, maxPageSize)
692
693 model := models.NewBook()
694
695 fields := []string{"book_id", "book_name", "identify", "order_index", "description", "label", "doc_count",
696 "vcnt", "star", "lang", "cover", "score", "cnt_score", "cnt_comment", "modify_time", "create_time", "release_time",
697 }
698
699 books, total, _ := model.HomeData(page, size, models.BookOrder(sort), lang, cid, fields...)
700 data := map[string]interface{}{"total": total}
701 if len(books) > 0 {
702 var lists []APIBook
703 var list APIBook
704
705 for _, book := range books {
706 book.Cover = this.completeLink(utils.ShowImg(book.Cover, "cover"))
707 utils.CopyObject(&book, &list)
708 lists = append(lists, list)
709 }
710 data["books"] = lists
711 }
712 this.Response(http.StatusOK, messageSuccess, data)
713}
714
715func (this *CommonController) BookListsByCids() {
716 sort := this.GetString("sort", "new") // new、recommend、hot、pin

Callers

nothing calls this directly

Calls 9

HomeDataMethod · 0.95
RangeNumberFunction · 0.92
NewBookFunction · 0.92
BookOrderTypeAlias · 0.92
ShowImgFunction · 0.92
CopyObjectFunction · 0.92
completeLinkMethod · 0.80
ResponseMethod · 0.80
appendFunction · 0.50

Tested by

no test coverage detected