()
| 62 | } |
| 63 | |
| 64 | func (this *BookController) Index() { |
| 65 | this.Data["SettingBook"] = true |
| 66 | this.TplName = "book/index.html" |
| 67 | private, _ := this.GetInt("private", 1) //是否是私有文档 |
| 68 | wd := this.GetString("wd", "") |
| 69 | this.Data["Private"] = private |
| 70 | this.Data["Wd"] = wd |
| 71 | pageIndex, _ := this.GetInt("page", 1) |
| 72 | books, totalCount, _ := models.NewBook().FindToPager(pageIndex, conf.PageSize, this.Member.MemberId, wd, private) |
| 73 | ebookStats := make(map[int]map[string]models.Ebook) |
| 74 | modelEbook := models.NewEbook() |
| 75 | for _, book := range books { |
| 76 | ebookStats[book.BookId] = modelEbook.GetStats(book.BookId) |
| 77 | } |
| 78 | ebookJSON, _ := json.Marshal(ebookStats) |
| 79 | this.Data["EbookStats"] = template.JS(string(ebookJSON)) |
| 80 | if totalCount > 0 { |
| 81 | this.Data["PageHtml"] = utils.NewPaginations(conf.RollPage, totalCount, conf.PageSize, pageIndex, beego.URLFor("BookController.Index"), fmt.Sprintf("&private=%v&wd=%s", private, url.QueryEscape(wd))) |
| 82 | } else { |
| 83 | this.Data["PageHtml"] = "" |
| 84 | } |
| 85 | //处理封面图片 |
| 86 | for idx, book := range books { |
| 87 | book.Cover = utils.ShowImg(book.Cover, "cover") |
| 88 | books[idx] = book |
| 89 | } |
| 90 | b, err := json.Marshal(books) |
| 91 | if err != nil || len(books) <= 0 { |
| 92 | this.Data["Result"] = template.JS("[]") |
| 93 | } else { |
| 94 | this.Data["Result"] = template.JS(string(b)) |
| 95 | } |
| 96 | installedDependencies := utils.GetInstalledDependencies() |
| 97 | for _, item := range installedDependencies { |
| 98 | this.Data[item.Name+"_is_installed"] = item.IsInstalled |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | // 收藏书籍 |
| 103 | func (this *BookController) Star() { |
nothing calls this directly
no test coverage detected