收藏文档
()
| 14 | |
| 15 | //收藏文档 |
| 16 | func (this *CollectController) Get() { |
| 17 | if this.IsLogin == 0 { |
| 18 | this.ResponseJson(false, "您当前未登录,请先登录") |
| 19 | } |
| 20 | |
| 21 | cid, _ := this.GetInt("Cid") |
| 22 | did, _ := this.GetInt("Did") |
| 23 | |
| 24 | if cid == 0 || did == 0 { |
| 25 | this.ResponseJson(false, "收藏失败:参数不正确") |
| 26 | } |
| 27 | |
| 28 | collect := models.Collect{Did: did, Cid: cid} |
| 29 | rows, err := orm.NewOrm().Insert(&collect) |
| 30 | if err != nil { |
| 31 | helper.Logger.Error("SQL执行失败:%v", err.Error()) |
| 32 | } |
| 33 | |
| 34 | if err != nil || rows == 0 { |
| 35 | this.ResponseJson(false, "收藏失败:您已收藏过该文档") |
| 36 | } |
| 37 | |
| 38 | //文档被收藏的数量+1 |
| 39 | models.Regulate(models.GetTableDocumentInfo(), "Ccnt", 1, fmt.Sprintf("`Id`=%v", did)) |
| 40 | |
| 41 | //收藏夹的文档+1 |
| 42 | models.Regulate(models.GetTableCollectFolder(), "Cnt", 1, fmt.Sprintf("`Id`=%v", cid)) |
| 43 | |
| 44 | this.ResponseJson(true, "恭喜您,文档收藏成功。") |
| 45 | } |
| 46 | |
| 47 | //收藏夹列表 |
| 48 | func (this *CollectController) FolderList() { |
nothing calls this directly
no test coverage detected