tuoling805 2 жил өмнө
parent
commit
51ac941627

+ 4 - 0
models/response/report.go

@@ -29,6 +29,10 @@ type ReportChapterListItem struct {
 	Sort                   int       `json:"sort"`
 	PublishTime            time.Time `json:"publish_time"`
 	IsClose                int       `gorm:"column:is_close;type:tinyint(1);default:0" json:"is_close"` //音频品种是否关闭
+	VideoUrl               string    `json:"video_url" description:"音频文件URL"`
+	VideoName              string    `json:"video_name" description:"音频文件名称"`
+	VideoPlaySeconds       string    `json:"video_play_seconds" description:"音频播放时长"`
+	VideoSize              string    `json:"video_size" description:"音频文件大小,单位M"`
 }
 
 type ReportItem struct {

+ 2 - 2
models/tables/rddp/report_chapter/query.go

@@ -33,7 +33,7 @@ func GetListByReportId(reportId int, classifyNameFirst string) (list []*ReportCh
 	}
 
 	err = global.MYSQL["rddp"].Model(ReportChapter{}).
-		Select("report_chapter_id, report_id, type_id, type_name, abstract, title, author, publish_time, trend").
+		Select("report_chapter_id, report_id, type_id, type_name, abstract, title, author, publish_time, trend,video_url,video_name,video_play_seconds,video_size").
 		Where(where, reportId).
 		Order("sort asc, report_chapter_id asc").
 		Scan(&list).Error
@@ -193,4 +193,4 @@ func GetListByChapterIds(chapterIds []int) (list []*ReportChapter, err error) {
 		Order("sort asc, report_chapter_id asc").
 		Scan(&list).Error
 	return
-}
+}

+ 23 - 20
services/report/report_chapter.go

@@ -24,7 +24,7 @@ import (
 )
 
 // GetReportTypeIdsByPermissionIds 获取所有和权限绑定的报告章节ID
-func GetReportTypeIdsByPermissionIds(permissionIds []int) (ids []int, err error)   {
+func GetReportTypeIdsByPermissionIds(permissionIds []int) (ids []int, err error) {
 	ids, err = chart_permission_chapter_mapping.GetReportIdsByPermisssionIds(permissionIds, "week")
 	return
 }
@@ -32,7 +32,7 @@ func GetReportTypeIdsByPermissionIds(permissionIds []int) (ids []int, err error)
 // GetLatestWeek 获取有权限的最新的周报
 func GetLatestWeek(permissionIds []int, typeIds []int) (reportInfo *report.Report, err error) {
 	newTypeIds, err := GetWeekTypeIdsByPermissionIds(permissionIds, typeIds)
-	chapters, err := report_chapter.GetLatestChaptersByTypeIdsAndClass(newTypeIds,"week")
+	chapters, err := report_chapter.GetLatestChaptersByTypeIdsAndClass(newTypeIds, "week")
 	if err != nil {
 		return
 	}
@@ -45,7 +45,7 @@ func GetLatestWeek(permissionIds []int, typeIds []int) (reportInfo *report.Repor
 }
 
 // GetWeekTypeIdsByPermissionIds 获取有权限的章节类型ID
-func GetWeekTypeIdsByPermissionIds(permissionIds []int, typeIds []int) (newTypeIds []int, err error)  {
+func GetWeekTypeIdsByPermissionIds(permissionIds []int, typeIds []int) (newTypeIds []int, err error) {
 	ids, err := GetReportTypeIdsByPermissionIds(permissionIds)
 	if err != nil {
 		return
@@ -101,7 +101,7 @@ func GetChapterListByReport(classifyNameFirst string, reportId int, validWeekTyp
 	}
 	//获取所有当前研报的章节
 	chapterList, tErr := report_chapter.GetListByReportId(reportId, classifyNameFirst)
-	if tErr != nil && tErr != utils.ErrNoRow{
+	if tErr != nil && tErr != utils.ErrNoRow {
 		errMsg = err.Error()
 		err = errors.New("章节查询出错")
 		return
@@ -114,7 +114,7 @@ func GetChapterListByReport(classifyNameFirst string, reportId int, validWeekTyp
 	for _, item := range chapterList {
 		if typeItem, ok := typeMap[uint64(item.TypeId)]; ok {
 			// 如果是周报只展示有权限的章节
-			if  classifyNameFirst == "周报" {
+			if classifyNameFirst == "周报" {
 				if _, ok1 := newTypeMap[item.TypeId]; !ok1 {
 					continue
 				}
@@ -132,6 +132,10 @@ func GetChapterListByReport(classifyNameFirst string, reportId int, validWeekTyp
 				temp.ReportChapterTypeKey = typeItem.ReportChapterTypeKey
 				temp.ReportChapterTypeName = typeItem.ReportChapterTypeName
 				temp.ReportChapterTypeThumb = typeItem.YbIconUrl
+				temp.VideoUrl = item.VideoUrl
+				temp.VideoName = item.VideoName
+				temp.VideoPlaySeconds = item.VideoPlaySeconds
+				temp.VideoSize = item.VideoSize
 				reportTypeList = append(reportTypeList, temp)
 			}
 		}
@@ -213,14 +217,14 @@ func GetChapterDetail(user user.UserInfo, reportChapterId int) (reportChapterDet
 	}
 	//判断权限
 	var newTypeIds []int
-	if reportInfo.ClassifyNameFirst == "晨报"{
+	if reportInfo.ClassifyNameFirst == "晨报" {
 		authOk, permissionCheckInfo, err = CheckDayReportPermission(user, productAuthOk)
 		if err != nil && err != utils.ErrNoRow {
 			errMsg = err.Error()
 			err = errors.New("权限查询出错")
 			return
 		}
-	}else if reportInfo.ClassifyNameFirst == "周报"{
+	} else if reportInfo.ClassifyNameFirst == "周报" {
 		authOk, permissionCheckInfo, newTypeIds, err = CheckWeekReportPermission(user, productAuthOk)
 		if err != nil && err != utils.ErrNoRow {
 			errMsg = err.Error()
@@ -251,7 +255,7 @@ func GetChapterDetail(user user.UserInfo, reportChapterId int) (reportChapterDet
 	}
 	reportChapterItem.VideoSize = reportChapter.VideoSize
 	videoImgMap := map[string]string{
-		"day": "report_list_chen.png",
+		"day":  "report_list_chen.png",
 		"week": "report_list_zhou.png",
 	}
 	reportChapterItem.VideoImg = utils.ALIYUN_YBIMG_HOST + videoImgMap[reportChapter.ReportType]
@@ -278,13 +282,13 @@ func GetChapterDetail(user user.UserInfo, reportChapterId int) (reportChapterDet
 		//底部菜单切换
 		if reportInfo.ClassifyNameFirst == "周报" {
 			chapterMenu, err = GetMenuChapter(reportInfo.Id, newTypeIds, reportInfo.ClassifyNameFirst, reportInfo.CreateTime)
-		}else{
+		} else {
 			chapterMenu, err = GetMenuChapter(reportInfo.Id, typeIds, reportInfo.ClassifyNameFirst, reportInfo.CreateTime)
 		}
 		//查询点赞数
-		likeNum,likeEnabled, _ = services.GetReportLikeByReportIdOldReportId(user.UserID, reportInfo.Id, reportChapter.ReportChapterId,0,0)
+		likeNum, likeEnabled, _ = services.GetReportLikeByReportIdOldReportId(user.UserID, reportInfo.Id, reportChapter.ReportChapterId, 0, 0)
 		go AddViewRecord(user, reportInfo.Id, reportInfo.ClassifyNameFirst, reportChapterId)
-	}else{
+	} else {
 		reportChapterItem.ContentSub = html.UnescapeString(reportChapter.ContentSub)
 	}
 
@@ -307,7 +311,7 @@ func GetChapterDetail(user user.UserInfo, reportChapterId int) (reportChapterDet
 	return
 }
 
-func GetMenuChapter(reportId int, typeIds []int, classifyNameFirst string, reportCreateTime time.Time) (reportTypeList response.ReportChapterMenuList, err error)  {
+func GetMenuChapter(reportId int, typeIds []int, classifyNameFirst string, reportCreateTime time.Time) (reportTypeList response.ReportChapterMenuList, err error) {
 	//查询有效的章节
 	typeList, tErr := report_chapter_type.GetEffectTypes()
 	if tErr != nil {
@@ -325,7 +329,7 @@ func GetMenuChapter(reportId int, typeIds []int, classifyNameFirst string, repor
 
 	//获取所有当前研报的章节
 	chapterList, tErr := report_chapter.GetListByReportIdTypeIds(reportId, typeIds, classifyNameFirst)
-	if tErr != nil && tErr != utils.ErrNoRow{
+	if tErr != nil && tErr != utils.ErrNoRow {
 		return
 	}
 	if len(chapterList) > 0 {
@@ -345,16 +349,16 @@ func GetMenuChapter(reportId int, typeIds []int, classifyNameFirst string, repor
 			}
 		}
 	}
-	if len(reportTypeList) > 0{
+	if len(reportTypeList) > 0 {
 		sort.Sort(reportTypeList)
 	}
 	return
 }
 
 // CheckWeekReportPermission 验证周报的权限
-func CheckWeekReportPermission(userInfo user.UserInfo, productAuthOk bool) (authOk bool, permissionCheckInfo response.PermissionCheckInfo, validTypeIds []int,  err error) {
+func CheckWeekReportPermission(userInfo user.UserInfo, productAuthOk bool) (authOk bool, permissionCheckInfo response.PermissionCheckInfo, validTypeIds []int, err error) {
 	var permissionIds []int
-	var validPermissionIds []int    //最后允许显示的章节
+	var validPermissionIds []int //最后允许显示的章节
 	if productAuthOk {
 		permissionIds, err = chart_permission_chapter_mapping.GetPermissionIdsByWeek()
 		if err != nil && err != utils.ErrNoRow {
@@ -378,11 +382,10 @@ func CheckDayReportPermission(userInfo user.UserInfo, productAuthOk bool) (authO
 		authOk = true
 		return
 	}
-	authOk, permissionCheckInfo,_, err = company.GetCheckPermission(userInfo.CompanyID, int(userInfo.UserID), []int{})
+	authOk, permissionCheckInfo, _, err = company.GetCheckPermission(userInfo.CompanyID, int(userInfo.UserID), []int{})
 	return
 }
 
-
 // GetReportChapterVideoList 根据报告获取章节的音频列表
 func GetReportChapterVideoList(permissionIds []int, classifyName string, list []*report.Report) (videoMap map[int][]*response.VideoListItem, weekAuthMap map[int]bool, errMsg string, err error) {
 	videoMap = make(map[int][]*response.VideoListItem)
@@ -424,7 +427,7 @@ func GetReportChapterVideoList(permissionIds []int, classifyName string, list []
 		}
 		// 查询章节列表
 		chapters, err = report_chapter.GetByTypeIdsAndReportIds(newTypeIds, reportIds, classifyName)
-	}else{
+	} else {
 		// 查询章节列表
 		chapters, err = report_chapter.GetByTypeIdsAndReportIds(typeIds, reportIds, classifyName)
 	}
@@ -457,4 +460,4 @@ func GetReportChapterVideoList(permissionIds []int, classifyName string, list []
 	}
 
 	return
-}
+}