Browse Source

我的收藏添加微路演

xingzai 2 years ago
parent
commit
2e93747762
2 changed files with 19 additions and 1 deletions
  1. 8 0
      controllers/user.go
  2. 11 1
      models/user.go

+ 8 - 0
controllers/user.go

@@ -328,6 +328,14 @@ func (this *UserController) Detail() {
 				}
 				detail.ScheduleNum += tatolSpecil
 
+				microRoadshowCollectcount, err := models.GetUserMicroRoadshowCollectcount(user.UserId)
+				if err != nil {
+					br.Msg = "获取信息失败"
+					br.ErrMsg = "获取微路演收藏信息失败,GetUserMicroRoadshowCollectcount Err:" + err.Error()
+					return
+				}
+				detail.ConNum += microRoadshowCollectcount
+
 			} else {
 				hasPermission = 1
 			}

+ 11 - 1
models/user.go

@@ -480,4 +480,14 @@ func GetUserMicroRoadshowCollectList(userId int) (items []*CygxArticleCollect, e
            ORDER BY a.create_time DESC `
 	_, err = orm.NewOrm().Raw(sql, userId).QueryRows(&items)
 	return
-}
+}
+
+func GetUserMicroRoadshowCollectcount(userId int) (count int, err error) {
+	sqlCount := `SELECT SELECT COUNT(1) AS count FROM cygx_article_collect AS a 
+			WHERE a.user_id=?  
+			AND a.article_id =0 
+           ORDER BY a.create_time DESC `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, userId).QueryRow(&count)
+	return
+}