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

Method List

controllers/BookmarkController.go:45–78  ·  view source on GitHub ↗

获取书签列表

()

Source from the content-addressed store, hash-verified

43
44//获取书签列表
45func (this *BookmarkController) List() {
46 bookId, _ := this.GetInt(":book_id")
47 if bookId <= 0 {
48 this.JsonResult(1, "获取书签列表失败:参数错误")
49 }
50
51 bl, rows, err := new(models.Bookmark).List(this.Member.MemberId, bookId)
52 if err != nil {
53 beego.Error(err.Error())
54 this.JsonResult(1, "获取书签列表失败")
55 }
56
57 var (
58 book = new(models.Book)
59 lists []map[string]interface{}
60 )
61
62 orm.NewOrm().QueryTable(book).Filter("book_id", bookId).One(book, "identify")
63 for _, item := range bl {
64 var list = make(map[string]interface{})
65 list["url"] = beego.URLFor("DocumentController.Read", ":key", book.Identify, ":id", item.Identify)
66 list["title"] = item.Title
67 list["doc_id"] = item.DocId
68 list["del"] = beego.URLFor("BookmarkController.Bookmark", ":id", item.DocId)
69 list["time"] = time.Unix(int64(item.CreateAt), 0).Format("01-02 15:04")
70 lists = append(lists, list)
71 }
72
73 this.JsonResult(0, "获取书签列表成功", map[string]interface{}{
74 "count": rows,
75 "book_id": bookId,
76 "list": lists,
77 })
78}

Callers

nothing calls this directly

Calls 2

JsonResultMethod · 0.80
appendFunction · 0.50

Tested by

no test coverage detected