ziwen há 2 anos atrás
pai
commit
6443660225

+ 7 - 1
controllers/micro_roadshow.go

@@ -23,6 +23,9 @@ type MicroRoadShowController struct {
 // @Param   AudioId			query	int		false	"音频ID"
 // @Param   VideoId			query	int		false	"视频ID"
 // @Param   ActivityVideoId			query	int		false	"活动视频ID"
+// @Param   AudioIds			query	string		false	"活动音频IDs"
+// @Param   ActivityVideoIds	query	string		false	"活动视频IDs"
+// @Param   VideoIds			query	string		false	"视频IDs"
 // @Param   Filter			query	string		false	"筛选条件 为空:全部 1:视频 2:音频 3:逻辑解析 4:路演回放 多个用 , 隔开"
 // @Success 200 {object} models.HomeListResp
 // @router /list [get]
@@ -46,6 +49,9 @@ func (this *MicroRoadShowController) List() {
 	videoId, _ := this.GetInt("VideoId")
 	activityVideoId, _ := this.GetInt("ActivityVideoId")
 	filter := this.GetString("Filter")
+	audioIds := this.GetString("AudioIds")
+	videoIds := this.GetString("VideoIds")
+	activityVideoIds := this.GetString("ActivityVideoIds")
 
 	if pageSize <= 0 {
 		pageSize = utils.PageSize20
@@ -55,7 +61,7 @@ func (this *MicroRoadShowController) List() {
 	}
 
 	// 微路演列表
-	list, total, e := services.GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId, filter, keywords)
+	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()

+ 182 - 0
controllers/user.go

@@ -1078,4 +1078,186 @@ func (this *UserController) AskList() {
 	br.Ret = 200
 	br.Success = true
 	br.Data = resp
+}
+
+// @Title 我的收藏微路演列表
+// @Description 我的收藏微路演列表接口
+// @Param   PageSize		query	int		true	"每页数据条数"
+// @Param   CurrentIndex	query	int		true	"当前页页码,从1开始"
+// @Success 200 {object} models.HomeListResp
+// @router /collect/microRoadShow [get]
+func (this *UserController) Mycollect() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	userId := user.UserId
+	listMycollect, err := models.GetUserMicroRoadshowCollectList(userId)
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+
+	var audioIds []string
+	var videoIds []string
+	var activityVideoIds []string
+	for _, item := range listMycollect {
+		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))
+		}
+	}
+	if len(audioIds) == 0 && len(videoIds) == 0 && len(activityVideoIds) == 0 {
+		resp := new(models.MicroRoadShowListResp)
+		page := paging.GetPaging(currentIndex, pageSize, 0)
+		resp.List = make([]*models.MicroRoadShowPageList, 0)
+		resp.Paging = page
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
+		return
+	}
+
+	audioIdstr := strings.Join(audioIds, ",")
+	ideoIdsStr := strings.Join(videoIds, ",")
+	activityVideoIdsStr := strings.Join(activityVideoIds, ",")
+	// 微路演列表
+	list, total, e := services.GetMicroRoadShowMycollect(pageSize, currentIndex, audioIdstr, ideoIdsStr, activityVideoIdsStr)
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
+		return
+	}
+	for _, item := range list {
+		if item.Type == 1 {
+			//音频
+			count, err := models.GetVoiceCollectCount(user.UserId, item.Id)
+			if err != nil {
+				br.Msg = "获取数据失败!"
+				br.ErrMsg = "获取数据失败,Err:" + err.Error()
+				return
+			}
+			if count > 0 {
+				item.IsCollect = true
+			}
+		} else if item.Type == 2 {
+			//活动视频
+			count, err := models.GetActivityVideoCollectCount(user.UserId, item.Id)
+			if err != nil {
+				br.Msg = "获取数据失败!"
+				br.ErrMsg = "获取数据失败,Err:" + err.Error()
+				return
+			}
+			if count > 0 {
+				item.IsCollect = true
+			}
+		} else if item.Type == 3 {
+			//微路演视频
+			count, err := models.GetVideoCollectCount(user.UserId, item.Id)
+			if err != nil {
+				br.Msg = "获取数据失败!"
+				br.ErrMsg = "获取数据失败,Err:" + err.Error()
+				return
+			}
+			if count > 0 {
+				item.IsCollect = true
+			}
+		}
+	}
+	// 用户权限
+	authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
+		return
+	}
+
+	// 获取默认图配置
+	audioMap, videoMap, audioShareMap, videoShareMap, e := services.GetMicroRoadShowDefaultImgConfig()
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
+		return
+	}
+
+	for i := range list {
+		// 权限
+		au := new(models.UserPermissionAuthInfo)
+		au.SellerName = authInfo.SellerName
+		au.SellerMobile = authInfo.SellerMobile
+		au.HasPermission = authInfo.HasPermission
+		au.OperationMode = authInfo.OperationMode
+		if au.HasPermission == 1 {
+			// 非宏观权限进一步判断是否有权限
+			if list[i].ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, list[i].ChartPermissionName) {
+				au.HasPermission = 2
+			}
+		}
+		// 无权限的弹框提示
+		if au.HasPermission != 1 {
+			if au.OperationMode == services.UserPermissionOperationModeCall {
+				if list[i].Type == 1 {
+					au.PopupMsg = services.UserPermissionPopupMsgCallActivity
+				} else {
+					au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
+				}
+			} else {
+				if list[i].Type == 1 {
+					au.PopupMsg = services.UserPermissionPopupMsgApplyActivity
+				} else {
+					au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
+				}
+			}
+		}
+		list[i].AuthInfo = au
+		list[i].PublishTime = utils.StrTimeToTime(list[i].PublishTime).Format(utils.FormatDate)
+		// 默认图
+		if list[i].BackgroundImg == "" {
+			if list[i].Type == 1 {
+				list[i].BackgroundImg = audioMap[list[i].ChartPermissionId]
+			} else {
+				list[i].BackgroundImg = videoMap[list[i].ChartPermissionId]
+			}
+		}
+		// 分享图
+		if list[i].ShareImg == "" {
+			if list[i].Type == 1 {
+				list[i].ShareImg = audioShareMap[list[i].ChartPermissionId]
+			} else {
+				list[i].ShareImg = videoShareMap[list[i].ChartPermissionId]
+			}
+		}
+	}
+
+	resp := new(models.MicroRoadShowListResp)
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp.List = list
+	resp.Paging = page
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
 }

+ 30 - 9
models/article_collect.go

@@ -7,15 +7,18 @@ import (
 )
 
 type CygxArticleCollect struct {
-	Id          int `orm:"column(id);pk"`
-	ArticleId   int
-	UserId      int
-	CreateTime  time.Time
-	Mobile      string `description:"手机号"`
-	Email       string `description:"邮箱"`
-	CompanyId   int    `description:"公司id"`
-	CompanyName string `description:"公司名称"`
-	RealName    string `description:"用户实际名称"`
+	Id              int `orm:"column(id);pk"`
+	ArticleId       int
+	ActivityVoiceId int
+	ActivityVideoId int
+	VideoId         int
+	UserId          int
+	CreateTime      time.Time
+	Mobile          string `description:"手机号"`
+	Email           string `description:"邮箱"`
+	CompanyId       int    `description:"公司id"`
+	CompanyName     string `description:"公司名称"`
+	RealName        string `description:"用户实际名称"`
 }
 
 //添加收藏信息
@@ -149,3 +152,21 @@ func GetArticleCollectNum(articleId []string, uid int) (items []*CygxArticleNum,
 	_, err = o.Raw(sql, uid, articleId).QueryRows(&items)
 	return
 }
+
+func GetVoiceCollectCount(userId, voiceId int) (count int, err error) {
+	sql := `SELECT COUNT(1) AS count FROM cygx_article_collect WHERE user_id=? AND activity_voice_id=? `
+	err = orm.NewOrm().Raw(sql, userId, 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 GetVideoCollectCount(userId, videoId int) (count int, err error) {
+	sql := `SELECT COUNT(1) AS count FROM cygx_article_collect WHERE user_id=? AND video_id=? `
+	err = orm.NewOrm().Raw(sql, userId, videoId).QueryRow(&count)
+	return
+}

+ 1 - 0
models/micro_roadshow.go

@@ -27,6 +27,7 @@ type MicroRoadShowPageList struct {
 	IndustryName           string `description:"产业名称"`
 	PlaySeconds            string `description:"音视频时长"`
 	ActivityId             int    `description:"活动ID"`
+	IsCollect              bool   `description:"是否收藏"`
 	IndustrialManagementId int    `description:"产业ID"`
 	CreateTime             string `description:"视频创建时间"`
 	AuthInfo               *UserPermissionAuthInfo

+ 10 - 0
models/user.go

@@ -366,3 +366,13 @@ func GetArticleUserBrowseHistoryList(startSize, pageSize, userId int, endDate st
 	_, err = orm.NewOrm().Raw(sql, userId, endDate, startSize, pageSize).QueryRows(&items)
 	return
 }
+
+func GetUserMicroRoadshowCollectList(userId int) (items []*CygxArticleCollect, err error) {
+	sql := `SELECT a.* FROM cygx_article_collect AS a 
+			WHERE a.user_id=?  
+			AND a.article_id =0 
+           ORDER BY a.create_time DESC `
+	_, err = orm.NewOrm().Raw(sql, userId).QueryRows(&items)
+	return
+}
+

+ 9 - 0
routers/commentsRouter.go

@@ -511,6 +511,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:UserController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:UserController"],
+        beego.ControllerComments{
+            Method: "Mycollect",
+            Router: `/collect/microRoadShow`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:UserController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:UserController"],
         beego.ControllerComments{
             Method: "CommnetList",

+ 28 - 2
services/micro_roadshow.go

@@ -188,7 +188,7 @@ func GetMicroRoadshowVideoMap() (items map[int]int, err error) {
 }
 
 // GetMicroRoadShowPageList 获取微路演列表添加活动视频 更新与8.1版本
-func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId int, filter, keywords string) (respList []*models.MicroRoadShowPageList, total int, err error) {
+func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId int, filter, keywords, audioIds, videoIds, activityVideoIds string) (respList []*models.MicroRoadShowPageList, total int, err error) {
 	var e error
 	// 根据每页数据量获取音视频配比
 	startSize := utils.StartIndex(currentIndex, pageSize)
@@ -220,6 +220,15 @@ func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activi
 			audioCond += ` AND a.activity_voice_id = ?`
 			audioPars = append(audioPars, audioId)
 		}
+		if audioIds != "" {
+			sliceId := strings.Split(audioIds, ",")
+			var idSqlStr string
+			for _, v := range sliceId {
+				idSqlStr += "'" + v + "',"
+			}
+			idSqlStr = strings.TrimRight(idSqlStr, ",")
+			audioCond += ` AND a.activity_voice_id IN (` + idSqlStr + `)`
+		}
 	}
 	//活动视频的处理
 	var videoCondAct string
@@ -235,6 +244,15 @@ 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 + "',"
+			}
+			idSqlStr = strings.TrimRight(idSqlStr, ",")
+			videoCondAct += ` AND v.video_id IN (` + idSqlStr + `)`
+		}
 		videoCondAct += ` AND publish_status = 1`
 	}
 	//产业视频的处理
@@ -251,7 +269,15 @@ func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activi
 			videoCond += ` AND video_id = ?`
 			videoPars = append(videoPars, videoId)
 		}
-
+		if videoIds != "" {
+			sliceId := strings.Split(videoIds, ",")
+			var idSqlStr string
+			for _, v := range sliceId {
+				idSqlStr += "'" + v + "',"
+			}
+			idSqlStr = strings.TrimRight(idSqlStr, ",")
+			videoCond += ` AND video_id IN (` + idSqlStr + `)`
+		}
 		videoCond += ` AND publish_status = 1`
 	}
 	total, videoList, e = models.GetMicroRoadShowVideoPageListV8(startSize, pageSize, videoCond, videoPars, videoCondAct, videoParsAct, audioCond, audioPars, audioId, videoId, activityVideoId, 0)

+ 62 - 0
services/user.go

@@ -337,3 +337,65 @@ func BindSession(mobile, countryCode string) (wxUser *models.WxUserItem, err err
 	}
 	return
 }
+
+// 我的收藏
+func GetMicroRoadShowMycollect(pageSize, currentIndex int, audioIds, videoIds, activityVideoIds string) (respList []*models.MicroRoadShowPageList, total int, err error) {
+	var e error
+	// 根据每页数据量获取音视频配比
+	startSize := utils.StartIndex(currentIndex, pageSize)
+	videoList := make([]*models.MicroRoadShowPageList, 0)
+
+	//音频的查询
+	var audioCond string
+	var audioPars []interface{}
+	// 如果筛选条件为指定视频ID或只看视频则不做音频查询
+	// 活动已发布且已结束
+	audioCond += ` AND b.publish_status = 1 AND b.active_state = 3`
+	if audioIds != "" {
+		sliceId := strings.Split(audioIds, ",")
+		var idSqlStr string
+		for _, v := range sliceId {
+			idSqlStr += "'" + v + "',"
+		}
+		idSqlStr = strings.TrimRight(idSqlStr, ",")
+		audioCond += ` AND a.activity_voice_id IN (` + idSqlStr + `)`
+	} else {
+		audioCond += ` AND a.activity_voice_id = 0 `
+	}
+	//视频的处理
+	var videoCond string
+	var videoCondAct string
+	if activityVideoIds != "" {
+		sliceId := strings.Split(activityVideoIds, ",")
+		var idSqlStr string
+		for _, v := range sliceId {
+			idSqlStr += "'" + v + "',"
+		}
+		idSqlStr = strings.TrimRight(idSqlStr, ",")
+		videoCondAct += ` AND v.video_id IN (` + idSqlStr + `)`
+	} else {
+		videoCondAct += ` AND v.video_id  = 0 `
+	}
+	var videoPars []interface{}
+	var videoParsAct []interface{}
+	if videoIds != "" {
+		sliceId := strings.Split(videoIds, ",")
+		var idSqlStr string
+		for _, v := range sliceId {
+			idSqlStr += "'" + v + "',"
+		}
+		idSqlStr = strings.TrimRight(idSqlStr, ",")
+		videoCond += ` AND video_id IN (` + idSqlStr + `)`
+	} else {
+		videoCond += ` AND video_id  = 0 `
+	}
+	videoCond += ` AND publish_status = 1`
+
+	total, videoList, e = models.GetMicroRoadShowVideoPageListV8(startSize, pageSize, videoCond, videoPars, videoCondAct, videoParsAct, audioCond, audioPars, 0, 0, 0, 0)
+	if e != nil {
+		err = errors.New("获取微路演音视频列表失败, Err: " + e.Error())
+		return
+	}
+	respList = videoList
+	return
+}