如果不传用户id,则表示查询当前登录的用户发布的书籍
()
| 361 | |
| 362 | // 如果不传用户id,则表示查询当前登录的用户发布的书籍 |
| 363 | func (this *CommonController) UserReleaseBook() { |
| 364 | uid, _ := this.GetInt("uid") |
| 365 | if uid <= 0 { |
| 366 | if login := this.isLogin(); login > 0 { |
| 367 | uid = login |
| 368 | } else { |
| 369 | this.Response(http.StatusBadRequest, messageBadRequest) |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | page, _ := this.GetInt("page") |
| 374 | if page <= 0 { |
| 375 | page = 1 |
| 376 | } |
| 377 | size, _ := this.GetInt("size", 10) |
| 378 | size = utils.RangeNumber(size, 10, maxPageSize) |
| 379 | |
| 380 | res, totalCount, err := models.NewBook().FindToPager(page, size, uid, "", 0) |
| 381 | if err != nil { |
| 382 | this.Response(http.StatusInternalServerError, messageInternalServerError) |
| 383 | } |
| 384 | |
| 385 | var books []APIBook |
| 386 | for _, item := range res { |
| 387 | book := &APIBook{} |
| 388 | utils.CopyObject(item, book) |
| 389 | book.Cover = this.completeLink(utils.ShowImg(book.Cover, "cover")) |
| 390 | books = append(books, *book) |
| 391 | } |
| 392 | data := map[string]interface{}{"total": totalCount} |
| 393 | |
| 394 | if len(books) > 0 { |
| 395 | data["books"] = books |
| 396 | } |
| 397 | |
| 398 | this.Response(http.StatusOK, messageSuccess, data) |
| 399 | } |
| 400 | |
| 401 | func (this *CommonController) TODO() { |
| 402 | this.Response(http.StatusOK, "TODO") |
nothing calls this directly
no test coverage detected