()
| 1057 | } |
| 1058 | |
| 1059 | func (this *CommonController) Bookshelf() { |
| 1060 | uid, _ := this.GetInt("uid") |
| 1061 | if uid <= 0 { |
| 1062 | uid = this.isLogin() |
| 1063 | } |
| 1064 | |
| 1065 | if uid <= 0 { |
| 1066 | if this.Token != "" { |
| 1067 | this.Response(http.StatusUnauthorized, messageRequiredLogin) |
| 1068 | } |
| 1069 | this.Response(http.StatusBadRequest, messageBadRequest) |
| 1070 | } |
| 1071 | |
| 1072 | cid, _ := this.GetInt("cid") |
| 1073 | withCate, _ := this.GetInt("with-cate", 0) |
| 1074 | size, _ := this.GetInt("size", 10) |
| 1075 | size = utils.RangeNumber(size, 10, maxPageSize) |
| 1076 | page, _ := this.GetInt("page", 1) |
| 1077 | if page <= 0 { |
| 1078 | page = 1 |
| 1079 | } |
| 1080 | total, res, err := new(models.Star).List(uid, page, size, cid) |
| 1081 | if err != nil { |
| 1082 | beego.Error(err.Error()) |
| 1083 | this.Response(http.StatusInternalServerError, messageInternalServerError) |
| 1084 | } |
| 1085 | |
| 1086 | var ( |
| 1087 | books []APIBook |
| 1088 | booksId []int |
| 1089 | ) |
| 1090 | for _, item := range res { |
| 1091 | book := &APIBook{} |
| 1092 | utils.CopyObject(&item, book) |
| 1093 | booksId = append(booksId, book.BookId) |
| 1094 | book.Cover = this.completeLink(utils.ShowImg(book.Cover, "cover")) |
| 1095 | books = append(books, *book) |
| 1096 | } |
| 1097 | |
| 1098 | data := map[string]interface{}{"total": total} |
| 1099 | |
| 1100 | if len(booksId) > 0 { |
| 1101 | //data["readed"] = new(models.ReadRecord).BooksProgress(uid, booksId...) |
| 1102 | data["books"] = books |
| 1103 | } |
| 1104 | |
| 1105 | if withCate > 0 { |
| 1106 | data["categories"] = models.NewCategory().CategoryOfUserCollection(uid, true) |
| 1107 | } |
| 1108 | |
| 1109 | this.Response(http.StatusOK, messageSuccess, data) |
| 1110 | } |
| 1111 | |
| 1112 | // 查询书籍评论 |
| 1113 | func (this *CommonController) GetComments() { |
nothing calls this directly
no test coverage detected