Procházet zdrojové kódy

报告详情、路演视频列表互相关联

hsun před 2 roky
rodič
revize
75ae5b6146

+ 1 - 0
models/response/community.go

@@ -115,6 +115,7 @@ type RoadVideoItem struct {
 	LikeTotal           int                                 `json:"like_total" description:"点赞数"`
 	TeaseTotal          int                                 `json:"tease_total" description:"吐槽数"`
 	CommentTotal        int                                 `json:"comment_total" description:"总共评论数"`
+	ReportId            int                                 `json:"report_id" description:"绑定的报告ID"`
 	CommentList         []*CommunityQuestionCommentListItem `json:"comment_list"`
 	BulletChatList      []*BulletChatItem                   `json:"bullet_chat_list" description:"弹幕列表"`
 }

+ 1 - 0
models/response/report.go

@@ -13,6 +13,7 @@ type ReportDetail struct {
 	LikeEnabled       int8                     `description:"是否已点赞: 0-未点赞 1-已点赞" json:"like_enabled"`
 	ReportShowType    int                      `descritpion:"展示形式:1-列表 2-专栏" json:"report_show_type"`
 	CollectionId      int                      `description:"收藏ID: 大于0则表示已收藏" json:"collection_id"`
+	RoadVideoId       int                      `json:"road_video_id" description:"绑定的路演视频ID"`
 }
 
 type ReportChapterListItem struct {

+ 17 - 14
models/tables/yb_road_video/entity.go

@@ -20,6 +20,7 @@ type YbRoadVideo 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"`
+	ReportID           int       `gorm:"column:report_id;type:int(10) unsigned;not null;default:0" json:"reportId"` // 绑定的报告ID
 }
 
 // TableName get sql table name.获取数据库表名
@@ -29,20 +30,21 @@ func (r *YbRoadVideo) TableName() string {
 
 // YbCommunityVideoColumns get sql column name.获取数据库列名
 var YbRoadVideoColumns = struct {
-	RoadVideoID string
-	Title            string
-	ChartPermissionIds     string
-	CoverImgURL      string
-	VideoURL         string
-	VideoSeconds     string
-	PublishState     string
-	SendThsState     string
-	IsDeleted        string
-	PublishTime      string
-	SendThsTime      string
-	CreateTime       string
-	ModifyTime       string
-	DeleteTime       string
+	RoadVideoID        string
+	Title              string
+	ChartPermissionIds string
+	CoverImgURL        string
+	VideoURL           string
+	VideoSeconds       string
+	PublishState       string
+	SendThsState       string
+	IsDeleted          string
+	PublishTime        string
+	SendThsTime        string
+	CreateTime         string
+	ModifyTime         string
+	DeleteTime         string
+	ReportID           string
 }{
 	RoadVideoID:        "road_video_id",
 	Title:              "title",
@@ -58,4 +60,5 @@ var YbRoadVideoColumns = struct {
 	CreateTime:         "create_time",
 	ModifyTime:         "modify_time",
 	DeleteTime:         "delete_time",
+	ReportID:           "report_id",
 }

+ 8 - 0
models/tables/yb_road_video/model.go

@@ -52,3 +52,11 @@ func GetListByVideoIds(videoIds []int) (list []*YbRoadVideo, err error) {
 		Scan(&list).Error
 	return
 }
+
+// GetItemByReportId 报告ID获取已绑定的路演视频
+func GetItemByReportId(reportId int) (item *YbRoadVideo, err error) {
+	err = global.DEFAULT_MYSQL.Model(YbRoadVideo{}).
+		Where("report_id = ? AND is_deleted = 0 AND publish_state = 1", reportId).
+		First(&item).Error
+	return
+}

+ 2 - 2
services/community/video.go

@@ -402,6 +402,7 @@ func GetRoadVideoList(userInfo user.UserInfo, pageIndex, pageSize, videoId, char
 			PublishTime:         v.PublishTime.Format(utils.FormatDateTime),
 			CreateTime:          v.CreateTime.Format(utils.FormatDateTime),
 			ModifyTime:          v.ModifyTime.Format(utils.FormatDateTime),
+			ReportId:            v.ReportID,
 		}
 		list = append(list, item)
 		videoIds = append(videoIds, item.RoadVideoID)
@@ -422,7 +423,6 @@ func GetRoadVideoList(userInfo user.UserInfo, pageIndex, pageSize, videoId, char
 	return
 }
 
-
 // HandleLikeOrTeaseByRoadVideoItemList 路演视频 点赞/吐槽 数据
 func HandleLikeOrTeaseByRoadVideoItemList(userId uint64, videoList []*response.RoadVideoItem) (err error) {
 	listLen := len(videoList)
@@ -518,4 +518,4 @@ func HandleCommentByRoadVideoItemList(questionList []*response.RoadVideoItem) (e
 		v.CommentList = comments
 	}
 	return
-}
+}

+ 11 - 0
services/report/report.go

@@ -21,6 +21,7 @@ import (
 	"hongze/hongze_yb/models/tables/rddp/report_ppt_img"
 	"hongze/hongze_yb/models/tables/report_chapter_type"
 	"hongze/hongze_yb/models/tables/report_chapter_type_permission"
+	"hongze/hongze_yb/models/tables/yb_road_video"
 	"hongze/hongze_yb/services"
 	"hongze/hongze_yb/services/collection"
 	"hongze/hongze_yb/services/company"
@@ -518,6 +519,16 @@ func GetReportDetail(userinfo user.UserInfo, reportId int) (reportDetail respons
 		return
 	}
 	reportDetail.CollectionId = collectionId
+
+	// 绑定的路演视频
+	roadVideo, e := yb_road_video.GetItemByReportId(reportId)
+	if e != nil && e != utils.ErrNoRow {
+		err = e
+		return
+	}
+	if roadVideo != nil && roadVideo.RoadVideoID > 0 {
+		reportDetail.RoadVideoId = roadVideo.RoadVideoID
+	}
 	return
 }