浏览代码

视频社区腾讯视频链接

hsun 2 年之前
父节点
当前提交
fbd23be94e
共有 3 个文件被更改,包括 20 次插入2 次删除
  1. 3 2
      models/response/community.go
  2. 3 0
      models/tables/yb_community_video/entity.go
  3. 14 0
      services/community/video.go

+ 3 - 2
models/response/community.go

@@ -86,6 +86,7 @@ type CommunityVideoItem struct {
 	CreateTime          string `json:"create_time"`
 	ModifyTime          string `json:"modify_time"`
 	ChartPermissionName string `json:"chart_permission_name"`
+	TencentId           string `json:"tencent_id"`
 }
 
 // RespCommunityQuestionLikeTease
@@ -127,7 +128,7 @@ type RespCommunityQuestionCommentList struct {
 
 // CommunityQuestionCommentListItem 问答列表评论列表
 type CommunityQuestionCommentListItem struct {
-	QaAvatarUrl     string `description:"用户头像" json:"qa_avatar_url"`
-	Comment         string `description:"评论" json:"comment"`
+	QaAvatarUrl string `description:"用户头像" json:"qa_avatar_url"`
+	Comment     string `description:"评论" json:"comment"`
 	//CommentUserName string `description:"评论人" json:"comment_user_name"`
 }

+ 3 - 0
models/tables/yb_community_video/entity.go

@@ -19,6 +19,7 @@ type YbCommunityVideo struct {
 	CreateTime       time.Time `gorm:"column:create_time;type:datetime;default:CURRENT_TIMESTAMP" json:"createTime"`                                // 创建时间
 	ModifyTime       time.Time `gorm:"column:modify_time;type:datetime;default:CURRENT_TIMESTAMP" json:"modifyTime"`                                // 更新时间
 	DeleteTime       time.Time `gorm:"column:delete_time;type:datetime" json:"deleteTime"`
+	TencentURL       string    `gorm:"column:tencent_url;type:varchar(255);not null;default:''" json:"tencentUrl"` // 腾讯视频地址
 }
 
 // TableName get sql table name.获取数据库表名
@@ -43,6 +44,7 @@ var YbCommunityVideoColumns = struct {
 	CreateTime       string
 	ModifyTime       string
 	DeleteTime       string
+	TencentURL       string
 }{
 	CommunityVideoID: "community_video_id",
 	Title:            "title",
@@ -59,4 +61,5 @@ var YbCommunityVideoColumns = struct {
 	CreateTime:       "create_time",
 	ModifyTime:       "modify_time",
 	DeleteTime:       "delete_time",
+	TencentURL:       "tencent_url",
 }

+ 14 - 0
services/community/video.go

@@ -8,6 +8,7 @@ import (
 	"hongze/hongze_yb/models/tables/yb_community_video_play_log"
 	"hongze/hongze_yb/services/user"
 	"hongze/hongze_yb/utils"
+	"strings"
 	"time"
 )
 
@@ -48,6 +49,7 @@ func GetVideoList(pageIndex, pageSize, videoId, varietyTagId int, keywords strin
 			CreateTime:          v.CreateTime.Format(utils.FormatDateTime),
 			ModifyTime:          v.ModifyTime.Format(utils.FormatDateTime),
 			ChartPermissionName: v.VarietyTagName,
+			TencentId:           getSubTencentUrl(v.TencentURL),
 		}
 		resp = append(resp, item)
 	}
@@ -93,3 +95,15 @@ func SaveVideoPlayLog(userInfo user.UserInfo, videoId, sourceAgent int) (errMsg
 	}
 	return
 }
+
+// getSubTencentUrl 获取腾讯视频链接子字符串
+func getSubTencentUrl(tencentUrl string) (sub string) {
+	if tencentUrl != "" {
+		st := strings.LastIndex(tencentUrl, "/")
+		ed := strings.LastIndex(tencentUrl, ".")
+		if st > 0 && ed > st {
+			sub = tencentUrl[st+1 : ed]
+		}
+	}
+	return
+}