MCPcopy Create free account
hub / github.com/TruthHun/BookStack / Star

Method Star

controllers/BookController.go:103–128  ·  view source on GitHub ↗

收藏书籍

()

Source from the content-addressed store, hash-verified

101
102// 收藏书籍
103func (this *BookController) Star() {
104 uid := this.BaseController.Member.MemberId
105 if uid <= 0 {
106 this.JsonResult(1, "收藏失败,请先登录")
107 }
108
109 id, _ := this.GetInt(":id")
110 if id <= 0 {
111 this.JsonResult(1, "收藏失败,书籍不存在")
112 }
113
114 cancel, err := new(models.Star).Star(uid, id)
115 data := map[string]bool{"IsCancel": cancel}
116 if err != nil {
117 beego.Error(err.Error())
118 if cancel {
119 this.JsonResult(1, "取消收藏失败", data)
120 }
121 this.JsonResult(1, "添加收藏失败", data)
122 }
123
124 if cancel {
125 this.JsonResult(0, "取消收藏成功", data)
126 }
127 this.JsonResult(0, "添加收藏成功", data)
128}
129
130// Dashboard 书籍概要 .
131func (this *BookController) Dashboard() {

Callers

nothing calls this directly

Calls 1

JsonResultMethod · 0.80

Tested by

no test coverage detected