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

Method UserReleaseBook

controllers/api/CommonController.go:363–399  ·  view source on GitHub ↗

如果不传用户id,则表示查询当前登录的用户发布的书籍

()

Source from the content-addressed store, hash-verified

361
362// 如果不传用户id,则表示查询当前登录的用户发布的书籍
363func (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
401func (this *CommonController) TODO() {
402 this.Response(http.StatusOK, "TODO")

Callers

nothing calls this directly

Calls 9

RangeNumberFunction · 0.92
NewBookFunction · 0.92
CopyObjectFunction · 0.92
ShowImgFunction · 0.92
isLoginMethod · 0.80
ResponseMethod · 0.80
completeLinkMethod · 0.80
appendFunction · 0.50
FindToPagerMethod · 0.45

Tested by

no test coverage detected