收藏书籍
()
| 101 | |
| 102 | // 收藏书籍 |
| 103 | func (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 书籍概要 . |
| 131 | func (this *BookController) Dashboard() { |
nothing calls this directly
no test coverage detected