【OK】
()
| 678 | |
| 679 | // 【OK】 |
| 680 | func (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 | |
| 715 | func (this *CommonController) BookListsByCids() { |
| 716 | sort := this.GetString("sort", "new") // new、recommend、hot、pin |
nothing calls this directly
no test coverage detected