|
@@ -11,6 +11,7 @@ import (
|
|
|
"hongze/hongze_yb/models/tables/yb_community_video"
|
|
|
"hongze/hongze_yb/models/tables/yb_community_video_play_log"
|
|
|
"hongze/hongze_yb/models/tables/yb_road_video"
|
|
|
+ "hongze/hongze_yb/services/collection"
|
|
|
"hongze/hongze_yb/services/company"
|
|
|
"hongze/hongze_yb/services/user"
|
|
|
"hongze/hongze_yb/utils"
|
|
@@ -20,7 +21,7 @@ import (
|
|
|
)
|
|
|
|
|
|
// GetVideoList 获取视频列表
|
|
|
-func GetVideoList(pageIndex, pageSize, videoId, varietyTagId int, keywords string) (resp []*response.CommunityVideoItem, err error) {
|
|
|
+func GetVideoList(userId, pageIndex, pageSize, videoId, varietyTagId int, keywords string) (resp []*response.CommunityVideoItem, err error) {
|
|
|
condition := make(map[string]interface{})
|
|
|
// 分享点进来的直接定位到具体视频
|
|
|
if videoId > 0 {
|
|
@@ -42,6 +43,7 @@ func GetVideoList(pageIndex, pageSize, videoId, varietyTagId int, keywords strin
|
|
|
if len(list) <= 0 {
|
|
|
return
|
|
|
}
|
|
|
+ videoIds := make([]int, 0)
|
|
|
for _, v := range list {
|
|
|
item := &response.CommunityVideoItem{
|
|
|
CommunityVideoID: v.CommunityVideoID,
|
|
@@ -59,6 +61,17 @@ func GetVideoList(pageIndex, pageSize, videoId, varietyTagId int, keywords strin
|
|
|
TencentId: getSubTencentUrl(v.TencentURL),
|
|
|
}
|
|
|
resp = append(resp, item)
|
|
|
+ videoIds = append(videoIds, v.CommunityVideoID)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 收藏
|
|
|
+ collectMap, e := collection.GetUserCollectByList(userId, collection.CollectionTypeVideo, videoIds)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for i := range resp {
|
|
|
+ resp[i].CollectionId = collectMap[resp[i].CommunityVideoID]
|
|
|
}
|
|
|
return
|
|
|
}
|
|
@@ -72,7 +85,7 @@ func SaveVideoPlayLog(userInfo user.UserInfo, videoId, sourceAgent int, videoTyp
|
|
|
err = errors.New("获取视频信息失败, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
_, e := yb_road_video.GetItemById(videoId)
|
|
|
if e != nil {
|
|
|
errMsg = "视频不存在或未发布"
|
|
@@ -150,7 +163,7 @@ func GetRoadVideoList(userInfo user.UserInfo, pageIndex, pageSize, videoId, char
|
|
|
ParentPermissionNameMap := make(map[string]string)
|
|
|
ParentPermissionChildMap := make(map[string]int)
|
|
|
for _, v := range validPermissionList {
|
|
|
- permissionIds += "'"+strconv.Itoa(v.ChartPermissionID) + "'|"
|
|
|
+ permissionIds += "'" + strconv.Itoa(v.ChartPermissionID) + "'|"
|
|
|
validPermissionMap["'"+strconv.Itoa(v.ChartPermissionID)+"'"] = struct{}{}
|
|
|
}
|
|
|
for _, v := range ficcPermissionList {
|
|
@@ -163,8 +176,8 @@ func GetRoadVideoList(userInfo user.UserInfo, pageIndex, pageSize, videoId, char
|
|
|
resp.Paging = response.GetPaging(pageIndex, pageSize, 0)
|
|
|
return
|
|
|
}
|
|
|
- permissionIds = strings.Trim(permissionIds,"|")
|
|
|
- condition := `is_deleted = 0 AND publish_state = 1 and chart_permission_ids REGEXP "(`+permissionIds+`)"`
|
|
|
+ permissionIds = strings.Trim(permissionIds, "|")
|
|
|
+ condition := `is_deleted = 0 AND publish_state = 1 and chart_permission_ids REGEXP "(` + permissionIds + `)"`
|
|
|
var par []interface{}
|
|
|
// 分享点进来的直接定位到具体视频
|
|
|
var videoList []*yb_road_video.YbRoadVideo
|
|
@@ -177,13 +190,13 @@ func GetRoadVideoList(userInfo user.UserInfo, pageIndex, pageSize, videoId, char
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
- if videoInfo != nil && videoInfo.RoadVideoID > 0{
|
|
|
- if videoInfo.IsDeleted != 0 || videoInfo.PublishState !=1 {
|
|
|
+ if videoInfo != nil && videoInfo.RoadVideoID > 0 {
|
|
|
+ if videoInfo.IsDeleted != 0 || videoInfo.PublishState != 1 {
|
|
|
resp.List = list
|
|
|
resp.Paging = response.GetPaging(pageIndex, pageSize, 0)
|
|
|
return
|
|
|
}
|
|
|
- permissionIdsSlice := strings.Split(permissionIds,"|")
|
|
|
+ permissionIdsSlice := strings.Split(permissionIds, "|")
|
|
|
videoPermissionIdsSlice := strings.Split(videoInfo.ChartPermissionIds, ",")
|
|
|
hasPermission := false
|
|
|
for _, v1 := range permissionIdsSlice {
|
|
@@ -205,11 +218,11 @@ func GetRoadVideoList(userInfo user.UserInfo, pageIndex, pageSize, videoId, char
|
|
|
}
|
|
|
} else {
|
|
|
if chartPermissionId > 0 {
|
|
|
- condition += ` and FIND_IN_SET("'`+strconv.Itoa(chartPermissionId)+`'", chart_permission_ids)`
|
|
|
+ condition += ` and FIND_IN_SET("'` + strconv.Itoa(chartPermissionId) + `'", chart_permission_ids)`
|
|
|
}
|
|
|
if keywords != "" {
|
|
|
condition += " and title like ? "
|
|
|
- par = append(par,"%" + keywords + "%")
|
|
|
+ par = append(par, "%"+keywords+"%")
|
|
|
}
|
|
|
videoList, total, err = yb_road_video.GetPageListByCondition(condition, par, pageIndex, pageSize)
|
|
|
if err != nil {
|
|
@@ -245,6 +258,8 @@ func GetRoadVideoList(userInfo user.UserInfo, pageIndex, pageSize, videoId, char
|
|
|
}
|
|
|
}
|
|
|
var chartPermissionNames string
|
|
|
+
|
|
|
+ videoIds := make([]int, 0)
|
|
|
for _, v := range videoList {
|
|
|
chartPermissionNames = ""
|
|
|
itemParentPermissionNum := make(map[string]int)
|
|
@@ -255,7 +270,7 @@ func GetRoadVideoList(userInfo user.UserInfo, pageIndex, pageSize, videoId, char
|
|
|
if p, ok := ParentPermissionNameMap[cid]; ok {
|
|
|
if _, ok1 := itemParentPermissionNum[p]; !ok1 {
|
|
|
itemParentPermissionNum[p] = 0
|
|
|
- chartPermissionNames += p +","
|
|
|
+ chartPermissionNames += p + ","
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -305,7 +320,19 @@ func GetRoadVideoList(userInfo user.UserInfo, pageIndex, pageSize, videoId, char
|
|
|
ModifyTime: v.ModifyTime.Format(utils.FormatDateTime),
|
|
|
}
|
|
|
list = append(list, item)
|
|
|
+ videoIds = append(videoIds, item.RoadVideoID)
|
|
|
}
|
|
|
+
|
|
|
+ // 收藏
|
|
|
+ collectMap, e := collection.GetUserCollectByList(int(userInfo.UserID), collection.CollectionTypeRoadVideo, videoIds)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for i := range list {
|
|
|
+ list[i].CollectionId = collectMap[list[i].RoadVideoID]
|
|
|
+ }
|
|
|
+
|
|
|
resp.List = list
|
|
|
resp.Paging = response.GetPaging(pageIndex, pageSize, int(total))
|
|
|
return
|
|
@@ -407,4 +434,4 @@ func HandleCommentByCommunityVideoItemList(questionList []*response.CommunityVid
|
|
|
}
|
|
|
|
|
|
return
|
|
|
-}
|
|
|
+}
|