|
@@ -9,6 +9,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"
|
|
@@ -18,7 +19,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 {
|
|
@@ -40,6 +41,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,
|
|
@@ -56,6 +58,17 @@ func GetVideoList(pageIndex, pageSize, videoId, varietyTagId int, keywords strin
|
|
|
ChartPermissionName: v.VarietyTagName,
|
|
|
}
|
|
|
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
|
|
|
}
|
|
@@ -69,7 +82,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 = "视频不存在或未发布"
|
|
@@ -132,7 +145,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 {
|
|
@@ -145,8 +158,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
|
|
@@ -159,13 +172,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 {
|
|
@@ -187,11 +200,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 {
|
|
@@ -227,6 +240,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)
|
|
@@ -237,7 +252,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 + ","
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -287,8 +302,20 @@ 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
|
|
|
-}
|
|
|
+}
|