Browse Source

Merge branch 'cygx_8.7' into debug

# Conflicts:
#	models/activity.go
ziwen 2 years ago
parent
commit
3cd8b6350f
4 changed files with 61 additions and 5 deletions
  1. 17 0
      controllers/activity.go
  2. 2 1
      models/activity.go
  3. 13 4
      models/activity_voice.go
  4. 29 0
      models/article_collect.go

+ 17 - 0
controllers/activity.go

@@ -1057,6 +1057,23 @@ func (this *ActivityCoAntroller) Detail() {
 		//处理按钮是否展示问题
 		resp.Detail = services.ActivityButtonShow(activityInfo)
 	}
+
+	collectCount1, err := models.GetActivityVoiceCollectCount(uid, activityId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "判断是否已收藏失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(activityId)
+		return
+	}
+	collectCount2, err := models.GetActivityVideoCollectCountByActivityId(uid, activityId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "判断是否已收藏失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(activityId)
+		return
+	}
+	if collectCount1+collectCount2 > 0 {
+		resp.Detail.IsCollect = true
+	}
+
 	resp.HasPermission = hasPermission
 	br.Ret = 200
 	br.Success = true

+ 2 - 1
models/activity.go

@@ -194,6 +194,7 @@ type ActivityDetail struct {
 	SourceType              int                        `description:"活动来源。 1:活动 、2:专项产业调研"`
 	TripImgLink             string                     `description:"专项产业调研行程链接"`
 	ActivityTimeEnd         string                     `description:"专项产业调研活动预期结束时间"`
+	IsCollect               bool                       `description:"是否收藏"`
 }
 
 type CygxActivityResp struct {
@@ -688,7 +689,7 @@ type CygxActivityLabelList struct {
 	Resource          int    `description:"位置 ,1:活动 ,2:专项产业调研"`
 	TemporaryLabel    string `description:"临时标签"`
 	IsNew             bool   `description:"是否为新:活动存在关联的的产业所关联的报告均在3个月内/无报告则标记新"`
-	YidongActivityId   int   `description:"易董活动ID"`
+	YidongActivityId  int    `description:"易董活动ID"`
 	IsExternalLabel   bool   `description:"是否为外部资源"`
 }
 

+ 13 - 4
models/activity_voice.go

@@ -20,10 +20,11 @@ type CygxActivityVoice struct {
 
 // ActivityVoiceReq 音频数据
 type CygxActivityVoiceReq struct {
-	ActivityId  int    ` description:"活动ID"`
-	Url         string `description:"音频资源url地址"`
-	Name        string `description:"音频名称"`
-	PlaySeconds int    `description:"音频时长"`
+	ActivityId      int    ` description:"活动ID"`
+	ActivityVoiceId int    ` description:"音频ID"`
+	Url             string `description:"音频资源url地址"`
+	Name            string `description:"音频名称"`
+	PlaySeconds     int    `description:"音频时长"`
 }
 
 // GetCygxActivityVoiceReqList 获取活动ID的音频
@@ -36,6 +37,7 @@ func GetCygxActivityVoiceReqList(activityIds []int) (items []*CygxActivityVoiceR
 	//endTime := time.Now().AddDate(0, 0, -30).Format("2006-01-02 15:04:05")
 	sql := `SELECT
 			v.activity_id,
+			v.activity_voice_id,
 			v.voice_url AS url,
 			v.voice_name AS name,
 			v.voice_play_seconds AS play_seconds 
@@ -74,3 +76,10 @@ func GetActivityVoiceListAll(condition string, pars []interface{}, startSize, pa
 	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
 	return
 }
+
+// GetCygxActivityVoiceByActivityId 主键获取活动音频
+func GetCygxActivityVoiceByActivityId(activityId int) (item *CygxActivityVoice, err error) {
+	sql := `SELECT * FROM cygx_activity_voice WHERE activity_id = ? LIMIT 1`
+	err = orm.NewOrm().Raw(sql, activityId).QueryRow(&item)
+	return
+}

+ 29 - 0
models/article_collect.go

@@ -215,3 +215,32 @@ func GetActivityVideoCollectUsersCount(videoId int) (count int, err error) {
 	err = orm.NewOrm().Raw(sql, videoId).QueryRow(&count)
 	return
 }
+
+func GetActivityVoiceCollectCount(userId, activityId int) (count int, err error) {
+	sql := `SELECT
+	COUNT( 1 ) AS count 
+FROM
+	cygx_article_collect AS c
+	INNER JOIN cygx_activity_voice AS vc 
+WHERE
+	c.user_id =? 
+	AND vc.activity_id =? 
+	AND c.activity_voice_id = vc.activity_voice_id`
+	err = orm.NewOrm().Raw(sql, userId, activityId,).QueryRow(&count)
+
+	return
+}
+
+func GetActivityVideoCollectCountByActivityId(userId, activityId int) (count int, err error) {
+	sql := `SELECT
+	COUNT( 1 ) AS count 
+FROM
+	cygx_article_collect AS c
+	INNER JOIN cygx_activity_video AS vd 
+WHERE
+	c.user_id =? 
+	AND vd.activity_id =? 
+	AND c.activity_voice_id = vd.activity_voice_id`
+	err = orm.NewOrm().Raw(sql, userId, activityId,).QueryRow(&count)
+	return
+}