MCPcopy Index your code
hub / github.com/TruthHun/DocHub / Get

Method Get

controllers/HomeControllers/CollectController.go:16–45  ·  view source on GitHub ↗

收藏文档

()

Source from the content-addressed store, hash-verified

14
15//收藏文档
16func (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//收藏夹列表
48func (this *CollectController) FolderList() {

Callers

nothing calls this directly

Calls 2

InsertMethod · 0.80
ResponseJsonMethod · 0.45

Tested by

no test coverage detected