浏览代码

Merge branch 'cygx_8.7' into debug

ziwen 2 年之前
父节点
当前提交
c4e9b5b9c3
共有 6 个文件被更改,包括 122 次插入44 次删除
  1. 62 6
      controllers/micro_roadshow.go
  2. 20 18
      controllers/user.go
  3. 24 3
      models/article_collect.go
  4. 3 13
      models/article_comment.go
  5. 3 2
      models/micro_roadshow.go
  6. 10 2
      services/micro_roadshow.go

+ 62 - 6
controllers/micro_roadshow.go

@@ -22,7 +22,8 @@ type MicroRoadShowController struct {
 // @Param   KeyWord			query	string	false	"搜索关键词"
 // @Param   AudioId			query	int		false	"音频ID"
 // @Param   VideoId			query	int		false	"视频ID"
-// @Param   AudioIds			query	string		false	"音频IDs"
+// @Param   AudioIds			query	string		false	"活动音频IDs"
+// @Param   ActivityVideoIds	query	string		false	"活动视频IDs"
 // @Param   VideoIds			query	string		false	"视频IDs"
 // @Param   ActivityVideoId			query	int		false	"活动视频ID"
 // @Param   Filter			query	int		false	"筛选条件 0:全部 1:视频 2:音频"
@@ -48,6 +49,7 @@ func (this *MicroRoadShowController) List() {
 	videoId, _ := this.GetInt("VideoId")
 	audioIds := this.GetString("AudioIds")
 	videoIds := this.GetString("VideoIds")
+	activityVideoIds := this.GetString("ActivityVideoIds")
 	activityVideoId, _ := this.GetInt("ActivityVideoId")
 	filter, _ := this.GetInt("Filter", 0)
 
@@ -59,7 +61,7 @@ func (this *MicroRoadShowController) List() {
 	}
 
 	// 微路演列表
-	list, total, e := services.GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId, filter, keywords, audioIds, videoIds)
+	list, total, e := services.GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId, filter, keywords, audioIds, videoIds, activityVideoIds)
 	if e != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
@@ -295,7 +297,7 @@ func (this *MicroRoadShowController) CommentAdd() {
 	if sourceType == 1 {
 		item.IndustryId = req.Id
 	} else if sourceType == 2 {
-		 item.ActivityId = req.Id
+		item.ActivityId = req.Id
 	}
 	_, err = models.AddArticleComment(&item)
 	if err != nil {
@@ -309,8 +311,8 @@ func (this *MicroRoadShowController) CommentAdd() {
 	return
 }
 
-// @Title 收藏
-// @Description 收藏
+// @Title 微路演收藏
+// @Description 微路演收藏
 // @Param	request	body models.MicroRoadshowCollectReq true "type json string"
 // @Success 200 {object} models.FontsCollectResp
 // @router /collect [post]
@@ -351,7 +353,7 @@ func (this *MicroRoadShowController) Collect() {
 		resp := new(models.ArticleCollectResp)
 		if count <= 0 {
 			item := new(models.CygxArticleCollect)
-			item.ArticleId = req.Id
+			item.ActivityVoiceId = req.Id
 			item.UserId = uid
 			item.CreateTime = time.Now()
 			item.Mobile = user.Mobile
@@ -390,6 +392,60 @@ func (this *MicroRoadShowController) Collect() {
 		br.Success = true
 		br.Data = resp
 	} else if req.SourceType == 2 {
+		_, err := models.GetCygxActivityVideoById(req.Id)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			return
+		}
+		count, err := models.GetActivityVideoCollectCount(uid, req.Id)
+		if err != nil {
+			br.Msg = "获取数据失败!"
+			br.ErrMsg = "获取数据失败,Err:" + err.Error()
+			return
+		}
+		resp := new(models.ArticleCollectResp)
+		if count <= 0 {
+			item := new(models.CygxArticleCollect)
+			item.ActivityVideoId = req.Id
+			item.UserId = uid
+			item.CreateTime = time.Now()
+			item.Mobile = user.Mobile
+			item.Email = user.Email
+			item.CompanyId = user.CompanyId
+			item.CompanyName = user.CompanyName
+			item.RealName = user.RealName
+			_, err = models.AddCygxArticleCollect(item)
+			if err != nil {
+				br.Msg = "收藏失败"
+				br.ErrMsg = "收藏失败,Err:" + err.Error()
+				return
+			}
+			br.Msg = "收藏成功"
+			resp.Status = 1
+			// 文章收藏消息发送
+			//go services.ArticleUserRemind(user, detail, 2)
+		} else {
+			err = models.RemoveActivityVideoCollect(uid, req.Id)
+			if err != nil {
+				br.Msg = "取消收藏失败"
+				br.ErrMsg = "取消收藏失败,Err:" + err.Error()
+				return
+			}
+			br.Msg = "已取消收藏"
+			resp.Status = 2
+		}
+		collectTotal, err := models.GetActivityVideoCollectUsersCount(req.Id)
+		if err != nil {
+			br.Msg = "获取数据失败"
+			br.ErrMsg = "获取数据失败,Err:" + err.Error()
+			return
+		}
+		resp.CollectCount = collectTotal
+		br.Ret = 200
+		br.Success = true
+		br.Data = resp
+	} else if req.SourceType == 3 {
 		_, err := models.GetMicroRoadshowVideoById(req.Id)
 		if err != nil {
 			br.Msg = "获取信息失败"

+ 20 - 18
controllers/user.go

@@ -1546,7 +1546,6 @@ func (this *UserCommonController) LoginPublic() {
 
 // @Title 获取我的留言
 // @Description 获取我的留言列表
-// @Param   CommentType		query	int		true	"留言种类,1报告 2微路演"
 // @Success 200 {object} models.CygxCommentListResp
 // @router /comment/list [get]
 func (this *UserController) CommnetList() {
@@ -1562,10 +1561,9 @@ func (this *UserController) CommnetList() {
 		br.Ret = 408
 		return
 	}
-	commentType, _ := this.GetInt("CommentType", 1)
 
 	userId := this.User.UserId
-	commentlist, err := models.GetCommentList(userId, commentType)
+	commentlist, err := models.GetCommentList(userId)
 	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取我的留言列表失败,Err:" + err.Error()
@@ -1576,24 +1574,24 @@ func (this *UserController) CommnetList() {
 
 	for _, comment := range commentlist {
 		item := models.CygxArticleCommentResp{
-			Id:           comment.Id,
-			UserId:       comment.UserId,
-			ArticleId:    comment.ArticleId,
-			IndustryId:   comment.IndustryId,
-			ActivityId:      comment.ActivityId,
-			CreateTime:   comment.CreateTime,
-			Mobile:       comment.Mobile,
-			Email:        comment.Email,
-			CompanyId:    comment.CompanyId,
-			CompanyName:  comment.CompanyName,
-			Content:      comment.Content,
-			Title:        comment.Title,
+			Id:          comment.Id,
+			UserId:      comment.UserId,
+			ArticleId:   comment.ArticleId,
+			IndustryId:  comment.IndustryId,
+			ActivityId:  comment.ActivityId,
+			CreateTime:  comment.CreateTime,
+			Mobile:      comment.Mobile,
+			Email:       comment.Email,
+			CompanyId:   comment.CompanyId,
+			CompanyName: comment.CompanyName,
+			Content:     comment.Content,
+			Title:       comment.Title,
 		}
 		if comment.ArticleId > 0 {
 			item.RedirectType = 1
-		} else if comment.IndustryId > 0{
+		} else if comment.IndustryId > 0 {
 			item.RedirectType = 2
-		}else if comment.ActivityId > 0 {
+		} else if comment.ActivityId > 0 {
 			item.RedirectType = 3
 		}
 		resp.List = append(resp.List, &item)
@@ -1627,18 +1625,22 @@ func (this *UserController) MicroRoadshowCollectList() {
 	resp := new(models.MicroRoadshowCollectList)
 	var audioIds []string
 	var videoIds []string
+	var activityVideoIds []string
 	for _, item := range list {
 		if item.ActivityVoiceId > 0 {
 			audioIds = append(audioIds, strconv.Itoa(item.ActivityVoiceId))
 		} else if item.VideoId > 0 {
 			videoIds = append(videoIds, strconv.Itoa(item.VideoId))
+		} else if item.ActivityVideoId > 0 {
+			activityVideoIds = append(activityVideoIds, strconv.Itoa(item.ActivityVideoId))
 		}
 	}
 	resp.AudioIds = strings.Join(audioIds, ",")
 	resp.VideoIds = strings.Join(videoIds, ",")
+	resp.ActivityVideoIds = strings.Join(activityVideoIds, ",")
 
 	br.Msg = "获取成功!"
 	br.Ret = 200
 	br.Success = true
 	br.Data = resp
-}
+}

+ 24 - 3
models/article_collect.go

@@ -10,6 +10,7 @@ type CygxArticleCollect struct {
 	Id              int `orm:"column(id);pk"`
 	ArticleId       int
 	ActivityVoiceId int
+	ActivityVideoId int
 	VideoId         int
 	UserId          int
 	CreateTime      time.Time
@@ -153,8 +154,9 @@ func GetArticleCollectNum(articleId []string, uid int) (items []*CygxArticleNum,
 }
 
 type MicroRoadshowCollectList struct {
-	AudioIds string
-	VideoIds string
+	AudioIds         string
+	VideoIds         string
+	ActivityVideoIds string
 }
 
 func GetVideoCollectCount(userId, videoId int) (count int, err error) {
@@ -193,4 +195,23 @@ func GetVoiceCollectUsersCount(voiceId int) (count int, err error) {
 	sql := `SELECT COUNT(user_id) AS count FROM cygx_article_collect WHERE activity_voice_id=? `
 	err = orm.NewOrm().Raw(sql, voiceId).QueryRow(&count)
 	return
-}
+}
+
+func GetActivityVideoCollectCount(userId, activityVideoId int) (count int, err error) {
+	sql := `SELECT COUNT(1) AS count FROM cygx_article_collect WHERE user_id=? AND activity_video_id=? `
+	err = orm.NewOrm().Raw(sql, userId, activityVideoId).QueryRow(&count)
+	return
+}
+
+func RemoveActivityVideoCollect(userId, activityVideoId int) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE FROM cygx_article_collect WHERE user_id=? AND activity_video_id=? `
+	_, err = o.Raw(sql, userId, activityVideoId).Exec()
+	return
+}
+
+func GetActivityVideoCollectUsersCount(videoId int) (count int, err error) {
+	sql := `SELECT COUNT(user_id) AS count FROM cygx_article_collect WHERE activity_video_id=? `
+	err = orm.NewOrm().Raw(sql, videoId).QueryRow(&count)
+	return
+}

+ 3 - 13
models/article_comment.go

@@ -33,24 +33,14 @@ type AddCygxArticleCommentReq struct {
 }
 
 //我的留言列表
-func GetCommentList(userId, commentType int) (items []*CygxArticleComment, err error) {
+func GetCommentList(userId int) (items []*CygxArticleComment, err error) {
 	o := orm.NewOrm()
-	sql := ""
-	if commentType == 1{
-		sql = `SELECT
+	sql := `SELECT
 			* 
 		FROM
 			cygx_article_comment AS c
 		WHERE
-			user_id = ? AND article_id <> 0 ORDER BY c.create_time DESC`
-	} else if commentType == 2{
-		sql = `SELECT
-			* 
-		FROM
-			cygx_article_comment AS c
-		WHERE
-			user_id = ? AND article_id = 0 ORDER BY c.create_time DESC`
-	}
+			user_id = ? ORDER BY c.create_time DESC`
 
 	_, err = o.Raw(sql, userId).QueryRows(&items)
 	return

+ 3 - 2
models/micro_roadshow.go

@@ -166,6 +166,7 @@ type MicroAudioUnionList struct {
 	AudioChartPermissionName string `description:"行业名称"`
 	AudioPlaySeconds         string `description:"音视频时长"`
 	AudioActivityId          int    `description:"活动ID"`
+	IsCollect                bool   `description:"是否收藏"`
 	AuthInfo                 *UserPermissionAuthInfo
 }
 
@@ -313,6 +314,6 @@ type AddVideoCommnetReq struct {
 }
 
 type MicroRoadshowCollectReq struct {
-	Id         int    `description:"音频或视频ID"`
-	SourceType int    `description:"视频来源: 1-音频; 2-视频 (不传默认为1)"`
+	Id         int `description:"音频或视频ID"`
+	SourceType int `description:"视频来源: 1-音频; 2-活动视频; 3-微路演视频 (不传默认为1)"`
 }

+ 10 - 2
services/micro_roadshow.go

@@ -164,7 +164,7 @@ func GetHomeNewestList(userId, companyId, startSize, pageSize int, condition str
 }
 
 // GetMicroRoadShowPageList 获取微路演列表添加活动视频 更新与8.1版本
-func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId, filter int, keywords, audioIds, videoIds string) (respList []*models.MicroRoadShowPageList, total int, err error) {
+func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId, filter int, keywords, audioIds, videoIds, activityVideoIds string) (respList []*models.MicroRoadShowPageList, total int, err error) {
 	var e error
 	// 根据每页数据量获取音视频配比
 	startSize := utils.StartIndex(currentIndex, pageSize)
@@ -228,6 +228,14 @@ func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activi
 			videoCondAct += ` AND video_id = ?`
 			videoParsAct = append(videoParsAct, activityVideoId)
 		}
+		if activityVideoIds != "" {
+			sliceId := strings.Split(activityVideoIds, ",")
+			var idSqlStr string
+			for _, v := range sliceId {
+				idSqlStr += "'" + v + "',"
+			}
+			videoCondAct += ` AND v.video_id IN (` + idSqlStr + `)`
+		}
 
 		//如果传了路演的或者活动的视频ID只查询一个
 		if videoId > 0 {
@@ -247,7 +255,7 @@ func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activi
 			for _, v := range sliceId {
 				idSqlStr += "'" + v + "',"
 			}
-			audioCond += ` AND video_id IN (` + idSqlStr + `)`
+			videoCond += ` AND video_id IN (` + idSqlStr + `)`
 		}
 		videoCond += ` AND publish_status = 1`
 	}