瀏覽代碼

音频相关页面新增图标

hsun 2 年之前
父節點
當前提交
c1843310de
共有 5 個文件被更改,包括 149 次插入108 次删除
  1. 109 105
      models/response/report.go
  2. 1 1
      models/tables/rddp/report_chapter/query.go
  3. 31 0
      services/report/report.go
  4. 7 2
      services/report/report_chapter.go
  5. 1 0
      utils/constants.go

+ 109 - 105
models/response/report.go

@@ -5,135 +5,138 @@ import (
 )
 
 type ReportDetail struct {
-	ReportInfo          *ReportItem  `json:"report_info"`
-	ReportChapterList        []*ReportChapterListItem `json:"report_chapter_list"`
-	PermissionCheck     *PermissionCheckInfo    `json:"permission_check"`
-	AuthOk              bool `json:"auth_ok"`
+	ReportInfo        *ReportItem              `json:"report_info"`
+	ReportChapterList []*ReportChapterListItem `json:"report_chapter_list"`
+	PermissionCheck   *PermissionCheckInfo     `json:"permission_check"`
+	AuthOk            bool                     `json:"auth_ok"`
 }
 
 type ReportChapterListItem struct {
-	ReportChapterId    int    `json:"report_chapter_id"`
-	ReportId        int    `json:"report_id"`
-	Title           string    `json:"title"`
-	TypeId                  int         `json:"type_id"`
-	TypeName                string         	`json:"type_name"`
-	Trend                   string      `json:"trend"`
-	ReportChapterTypeKey    string      `json:"report_chapter_type_key"`
-	ReportChapterTypeThumb  string	    `json:"report_chapter_type_thumb"`
-	ReportChapterTypeName   string       `json:"report_chapter_type_name"`
-	Sort                    int          `json:"sort"`
-	PublishTime         time.Time    `json:"publish_time"`
+	ReportChapterId        int       `json:"report_chapter_id"`
+	ReportId               int       `json:"report_id"`
+	Title                  string    `json:"title"`
+	TypeId                 int       `json:"type_id"`
+	TypeName               string    `json:"type_name"`
+	Trend                  string    `json:"trend"`
+	ReportChapterTypeKey   string    `json:"report_chapter_type_key"`
+	ReportChapterTypeThumb string    `json:"report_chapter_type_thumb"`
+	ReportChapterTypeName  string    `json:"report_chapter_type_name"`
+	Sort                   int       `json:"sort"`
+	PublishTime            time.Time `json:"publish_time"`
 }
 
 type ReportItem struct {
-	ReportId           int    `json:"report_id"`
-	ClassifyNameFirst  string `description:"一级分类名称" json:"classify_name_first"`
-	ClassifyNameSecond string `description:"二级分类名称" json:"classify_name_second"`
-	Title              string `description:"标题" json:"title"`
-	Abstract           string `description:"摘要" json:"abstract"`
-	Author             string `description:"作者" json:"author"`
-	Frequency          string `description:"频度" json:"frequency"`
+	ReportId           int       `json:"report_id"`
+	ClassifyNameFirst  string    `description:"一级分类名称" json:"classify_name_first"`
+	ClassifyNameSecond string    `description:"二级分类名称" json:"classify_name_second"`
+	Title              string    `description:"标题" json:"title"`
+	Abstract           string    `description:"摘要" json:"abstract"`
+	Author             string    `description:"作者" json:"author"`
+	Frequency          string    `description:"频度" json:"frequency"`
 	PublishTime        time.Time `description:"发布时间" json:"publish_time"`
-	Stage              int    `description:"期数" json:"stage"`
-	Content            string `description:"内容" json:"content"`
-	VideoUrl           string `description:"音频文件URL" json:"video_url"`
-	VideoName          string `description:"音频文件名称" json:"video_name"`
-	VideoPlaySeconds   string `description:"音频播放时长" json:"video_play_seconds"`
-	ContentSub         string `description:"内容前两个章节" json:"content_sub"`
-	BannerUrl          string `description:"详情页banner" json:"banner_url"`
+	Stage              int       `description:"期数" json:"stage"`
+	Content            string    `description:"内容" json:"content"`
+	VideoUrl           string    `description:"音频文件URL" json:"video_url"`
+	VideoName          string    `description:"音频文件名称" json:"video_name"`
+	VideoPlaySeconds   string    `description:"音频播放时长" json:"video_play_seconds"`
+	VideoImg           string    `description:"音频播放条的图片" json:"video_img"`
+	ContentSub         string    `description:"内容前两个章节" json:"content_sub"`
+	BannerUrl          string    `description:"详情页banner" json:"banner_url"`
 }
 
 type ReportChapterItem struct {
-	ReportChapterId    int    `json:"report_chapter_id"`
-	ReportId        int    `json:"report_id"`
-	Title           string    `json:"title"`
-	TypeId                  int         `json:"type_id"`
-	TypeName                string         	`json:"type_name"`
-	Trend                   string      `json:"trend"`
-	ReportChapterTypeName   string       `json:"report_chapter_type_name"`
-	PublishTime         time.Time    `json:"publish_time"`
-	Content            string `description:"内容" json:"content"`
-	ContentSub         string `description:"内容前两个章节" json:"content_sub"`
-	VideoUrl            string    `json:"video_url"`                    //音频文件URL
-	VideoName           string    `json:"video_name"`                  //音频文件名称
-	VideoPlaySeconds    string    `json:"video_play_seconds"`      //音频播放时长
-	VideoSize           string    `json:"video_size"`
-	Author              string    `description:"作者" json:"author"`
-	Stage              int        `description:"期数" json:"stage"`
-	ClassifyIdFirst    int        `description:"一级分类id" json:"classify_id_first"`
-	ClassifyNameFirst  string     `description:"一级分类名称" json:"classify_name_first"`
+	ReportChapterId       int       `json:"report_chapter_id"`
+	ReportId              int       `json:"report_id"`
+	Title                 string    `json:"title"`
+	TypeId                int       `json:"type_id"`
+	TypeName              string    `json:"type_name"`
+	Trend                 string    `json:"trend"`
+	ReportChapterTypeName string    `json:"report_chapter_type_name"`
+	PublishTime           time.Time `json:"publish_time"`
+	Content               string    `description:"内容" json:"content"`
+	ContentSub            string    `description:"内容前两个章节" json:"content_sub"`
+	VideoUrl              string    `json:"video_url"`          //音频文件URL
+	VideoName             string    `json:"video_name"`         //音频文件名称
+	VideoPlaySeconds      string    `json:"video_play_seconds"` //音频播放时长
+	VideoSize             string    `json:"video_size"`
+	VideoImg              string    `description:"音频播放条的图片" json:"video_img"`
+	Author                string    `description:"作者" json:"author"`
+	Stage                 int       `description:"期数" json:"stage"`
+	ClassifyIdFirst       int       `description:"一级分类id" json:"classify_id_first"`
+	ClassifyNameFirst     string    `description:"一级分类名称" json:"classify_name_first"`
 }
 
 type ReportChapterDetail struct {
-	ReportChapterItem  * ReportChapterItem  `json:"report_chapter_item"`
-	PermissionCheck     *PermissionCheckInfo    `json:"permission_check"`
-	ReportChapterMenuList        []*ReportChapterMenu `json:"report_chapter_menu_list""`
-	AuthOk              bool `json:"auth_ok"`
+	ReportChapterItem     *ReportChapterItem   `json:"report_chapter_item"`
+	PermissionCheck       *PermissionCheckInfo `json:"permission_check"`
+	ReportChapterMenuList []*ReportChapterMenu `json:"report_chapter_menu_list"`
+	AuthOk                bool                 `json:"auth_ok"`
 }
 
 type ReportChapterMenu struct {
-	ReportChapterId    int    `json:"report_chapter_id"`
-	ReportId        int    `json:"report_id"`
-	ReportChapterTypeName   string       `json:"report_chapter_type_name"`
-	ReportChapterTypeThumb  string	    `json:"report_chapter_type_thumb"`
-	Sort             int  `json:"sort"`
+	ReportChapterId        int    `json:"report_chapter_id"`
+	ReportId               int    `json:"report_id"`
+	ReportChapterTypeName  string `json:"report_chapter_type_name"`
+	ReportChapterTypeThumb string `json:"report_chapter_type_thumb"`
+	Sort                   int    `json:"sort"`
 }
 
 type ReportListItem struct {
-	ReportId                 int    `description:"报告Id" json:"report_id"`
-	ClassifyIdFirst    int    `description:"一级分类id" json:"classify_id_first"`
-	ClassifyNameFirst  string `description:"一级分类名称" json:"classify_name_first"`
-	ClassifyIdSecond   int    `description:"二级分类id" json:"classify_id_second"`
-	ClassifyNameSecond string `description:"二级分类名称" json:"classify_name_second"`
-	Title              string `description:"标题" json:"title"`
-	Abstract           string `description:"摘要" json:"abstract"`
-	Author             string `description:"作者" json:"author"`
-	ReportImgUrl       string `description:"作者头像" json:"report_img_url"`
-	PublishTime        time.Time `description:"发布时间" json:"publish_time"`
-	Stage              int    `description:"期数" json:"stage"`
+	ReportId           int              `description:"报告Id" json:"report_id"`
+	ClassifyIdFirst    int              `description:"一级分类id" json:"classify_id_first"`
+	ClassifyNameFirst  string           `description:"一级分类名称" json:"classify_name_first"`
+	ClassifyIdSecond   int              `description:"二级分类id" json:"classify_id_second"`
+	ClassifyNameSecond string           `description:"二级分类名称" json:"classify_name_second"`
+	Title              string           `description:"标题" json:"title"`
+	Abstract           string           `description:"摘要" json:"abstract"`
+	Author             string           `description:"作者" json:"author"`
+	ReportImgUrl       string           `description:"作者头像" json:"report_img_url"`
+	PublishTime        time.Time        `description:"发布时间" json:"publish_time"`
+	Stage              int              `description:"期数" json:"stage"`
 	VideoList          []*VideoListItem `json:"video_list"`
-	AuthOk             bool   `json:"auth_ok"`
-	TitleInfo          string `json:"title_info"`
+	AuthOk             bool             `json:"auth_ok"`
+	TitleInfo          string           `json:"title_info"`
 }
 
 type VideoListItem struct {
-	VideoUrl            string `description:"音频文件URL" json:"video_url"`
-	Sort                int `description:"音频内容排序" json:"sort"`
-	VideoName           string    `json:"video_name"`               //音频文件名称
-	VideoPlaySeconds    string    `json:"video_play_seconds"`      //音频播放时长
+	VideoUrl         string `description:"音频文件URL" json:"video_url"`
+	Sort             int    `description:"音频内容排序" json:"sort"`
+	VideoName        string `json:"video_name"`         //音频文件名称
+	VideoPlaySeconds string `json:"video_play_seconds"` //音频播放时长
+	VideoImg         string `json:"video_img"`          // 音频播放条前面展示的图片
 }
 
 type ReportList struct {
-	Paging     *PagingItem  		`json:"paging"`
-	List        []*ReportListItem `json:"list"`
+	Paging *PagingItem       `json:"paging"`
+	List   []*ReportListItem `json:"list"`
 }
 
 type ReportCollectListItem struct {
-	ReportId                 int    `description:"报告Id" json:"report_id"`
-	ReportChapterId    int    `json:"report_chapter_id"`
-	ClassifyIdFirst    int    `description:"一级分类id" json:"classify_id_first"`
-	ClassifyNameFirst  string `description:"一级分类名称" json:"classify_name_first"`
-	ClassifyIdSecond   int    `description:"二级分类id" json:"classify_id_second"`
-	ClassifyNameSecond string `description:"二级分类名称" json:"classify_name_second"`
-	ReportChapterTypeId                  int         `json:"report_chapter_type_id"`
-	PublishTime        time.Time `description:"发布时间" json:"publish_time"`
-	Title              string `description:"标题" json:"title"`
-	ContentSub         string `description:"内容前两个章节" json:"content_sub"`
+	ReportId            int       `description:"报告Id" json:"report_id"`
+	ReportChapterId     int       `json:"report_chapter_id"`
+	ClassifyIdFirst     int       `description:"一级分类id" json:"classify_id_first"`
+	ClassifyNameFirst   string    `description:"一级分类名称" json:"classify_name_first"`
+	ClassifyIdSecond    int       `description:"二级分类id" json:"classify_id_second"`
+	ClassifyNameSecond  string    `description:"二级分类名称" json:"classify_name_second"`
+	ReportChapterTypeId int       `json:"report_chapter_type_id"`
+	PublishTime         time.Time `description:"发布时间" json:"publish_time"`
+	Title               string    `description:"标题" json:"title"`
+	ContentSub          string    `description:"内容前两个章节" json:"content_sub"`
 }
 
 type ReportCollectList struct {
-	Date     string   	`json:"date"`
-	SubList  []*ReportCollectListItem `json:"sub_list"`
+	Date    string                   `json:"date"`
+	SubList []*ReportCollectListItem `json:"sub_list"`
 }
 
 type ReportCollectResp struct {
-	Paging     *PagingItem  		`json:"paging"`
-	List []*ReportCollectList `json:"list"`
+	Paging *PagingItem          `json:"paging"`
+	List   []*ReportCollectList `json:"list"`
 }
 
 type ReportSearchResp struct {
-	Paging     *PagingItem  		`json:"paging"`
-	List []*ReportCollectListItem `json:"list"`
+	Paging *PagingItem              `json:"paging"`
+	List   []*ReportCollectListItem `json:"list"`
 }
 
 type EsReportItem struct {
@@ -154,24 +157,24 @@ type EsReportItem struct {
 }
 
 type TickerDataItem struct {
-	Date             string        `json:"date"`
-	Ticker			 string        `json:"ticker"`
-	BaseColumnName   string        `json:"base_column_name"`
-	TickerValue      float64       `json:"ticker_value"`
-	LastValue        float64       `json:"last_value"`
-	DdValue          float64       `json:"dd_value"`
-	WwValue          float64       `json:"ww_value"`
-	MmValue          float64       `json:"mm_value"`
+	Date           string  `json:"date"`
+	Ticker         string  `json:"ticker"`
+	BaseColumnName string  `json:"base_column_name"`
+	TickerValue    float64 `json:"ticker_value"`
+	LastValue      float64 `json:"last_value"`
+	DdValue        float64 `json:"dd_value"`
+	WwValue        float64 `json:"ww_value"`
+	MmValue        float64 `json:"mm_value"`
 }
 type TickerTitleData struct {
-	TickerTitle      string      `json:"ticker_title"`
-	ReportChapterTypeId  int     `json:"report_chapter_type_id"`
+	TickerTitle           string `json:"ticker_title"`
+	ReportChapterTypeId   int    `json:"report_chapter_type_id"`
 	ReportChapterTypeName string `json:"report_chapter_type_name"`
-	DataTableImage string   `json:"data_table_image"`
+	DataTableImage        string `json:"data_table_image"`
 }
 type TickerData struct {
-	List []*TickerDataItem `json:"list"`
-	TickerTitle *TickerTitleData `json:"ticker_title"`
+	List        []*TickerDataItem `json:"list"`
+	TickerTitle *TickerTitleData  `json:"ticker_title"`
 }
 
 type ReportCollectListResp []*ReportCollectList
@@ -189,6 +192,7 @@ func (p ReportCollectListResp) Swap(i, j int) {
 }
 
 type ReportChapterList []*ReportChapterListItem
+
 func (r ReportChapterList) Len() int {
 	return len(r)
 }
@@ -213,4 +217,4 @@ func (rc ReportChapterMenuList) Less(i, j int) bool {
 
 func (rc ReportChapterMenuList) Swap(i, j int) {
 	rc[i], rc[j] = rc[j], rc[i]
-}
+}

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

@@ -58,7 +58,7 @@ func GetListByReportIdTypeIds(reportId int, typeIds []int, classifyNameFirst str
 
 // GetContentById 根据ID获取章节详情
 func GetContentById(id int, typeIds []int) (info *ReportChapter, err error)  {
-	err = global.MYSQL["rddp"].Model(ReportChapter{}).Select("report_chapter_id, report_id,  is_edit, classify_name_first, classify_id_first, content, trend, type_id, type_name, abstract, title, author, stage, publish_time, content, content_sub, video_url, video_name, video_play_seconds, video_size").
+	err = global.MYSQL["rddp"].Model(ReportChapter{}).Select("report_chapter_id, report_id,  is_edit, classify_name_first, classify_id_first, content, trend, type_id, type_name, abstract, title, author, stage, publish_time, content, content_sub, video_url, video_name, video_play_seconds, video_size, report_type").
 		Where("report_chapter_id = ? and type_id in (?) AND publish_state = 2 ", id, typeIds).
 		First(&info).Error
 	if err == utils.ErrNoRow {

+ 31 - 0
services/report/report.go

@@ -441,6 +441,30 @@ func GetReportDetail(userinfo user.UserInfo, reportId int) (reportDetail respons
 				return
 			}
 		}
+	} else {
+		// 音频播放条图片用分类图片
+		reportItem.VideoImg = utils.HZ_DEFAULT_AVATAR
+		permissionIds, tmpErr := chart_permission_search_key_word_mapping.GetChartPermissionIdsByKeyWord(reportItem.ClassifyNameSecond)
+		if tmpErr != nil {
+			errMsg = tmpErr.Error()
+			err = errors.New("查询报告权限失败")
+			return
+		}
+		if len(permissionIds) > 0 {
+			chartPermission, tmpErr := chart_permission.GetListByIds(permissionIds)
+			if tmpErr != nil {
+				errMsg = tmpErr.Error()
+				err = errors.New("查询品种信息失败")
+				return
+			}
+			lenChart := len(chartPermission)
+			for i := 0; i < lenChart; i++ {
+				if chartPermission[i].YbImgUrl != "" {
+					reportItem.VideoImg = utils.ALIYUN_YBIMG_HOST + chartPermission[i].YbImgUrl
+					break
+				}
+			}
+		}
 	}
 	//如果有权限则展示content
 	if authOk {
@@ -786,6 +810,9 @@ func GetReportList(user user.UserInfo, keyWord string, classifyIdFirst, classify
 			if classifyParent.ClassifyName == "晨报" && productAuthOk {
 				// 查询当前晨报的所有音频
 				if vList, ok := videoMap[reportInfo.Id]; ok {
+					for _,vd := range vList {
+						vd.VideoImg = reportItem.ReportImgUrl
+					}
 					reportItem.VideoList = vList
 				}
 				reportItem.AuthOk = productAuthOk
@@ -795,6 +822,9 @@ func GetReportList(user user.UserInfo, keyWord string, classifyIdFirst, classify
 					if wAuth {
 						// 查询当前晨报的所有音频
 						if vList, ok2 := videoMap[reportInfo.Id]; ok2 {
+							for _,vd := range vList {
+								vd.VideoImg = reportItem.ReportImgUrl
+							}
 							reportItem.VideoList = vList
 						}
 					}
@@ -808,6 +838,7 @@ func GetReportList(user user.UserInfo, keyWord string, classifyIdFirst, classify
 						videoTemp.VideoName = reportInfo.Title
 					}
 					videoTemp.VideoPlaySeconds = reportInfo.VideoPlaySeconds
+					videoTemp.VideoImg = reportItem.ReportImgUrl
 					reportItem.VideoList = append(reportItem.VideoList, videoTemp)
 				}
 				reportItem.AuthOk = authOk

+ 7 - 2
services/report/report_chapter.go

@@ -197,7 +197,7 @@ func GetChapterDetail(user user.UserInfo, reportChapterId int) (reportChapterDet
 
 	reportInfo, tErr := report.GetByReportId(reportChapter.ReportId)
 	if tErr != nil {
-		errMsg = err.Error()
+		errMsg = tErr.Error()
 		err = errors.New("报告查询出错")
 		return
 	}
@@ -209,7 +209,7 @@ func GetChapterDetail(user user.UserInfo, reportChapterId int) (reportChapterDet
 		err = errors.New("章节未编辑")
 		return
 	}
-	//判断权限 TODO 查询章节相关的报告的charPermissionId
+	//判断权限
 	var newTypeIds []int
 	if reportInfo.ClassifyNameFirst == "晨报"{
 		authOk, permissionCheckInfo, err = CheckDayReportPermission(user, productAuthOk)
@@ -248,6 +248,11 @@ func GetChapterDetail(user user.UserInfo, reportChapterId int) (reportChapterDet
 		reportChapterItem.VideoName = reportChapter.Title
 	}
 	reportChapterItem.VideoSize = reportChapter.VideoSize
+	videoImgMap := map[string]string{
+		"day": "report_list_chen.png",
+		"week": "report_list_zhou.png",
+	}
+	reportChapterItem.VideoImg = utils.ALIYUN_YBIMG_HOST + videoImgMap[reportChapter.ReportType]
 	reportChapterItem.TypeName = reportChapter.TypeName
 	reportChapterItem.Author = reportChapter.Author
 	reportChapterItem.Stage = reportChapter.Stage

+ 1 - 0
utils/constants.go

@@ -120,5 +120,6 @@ var (
 )
 
 const ALIYUN_YBIMG_HOST = "https://hzstatic.hzinsights.com/static/yb_wx/"
+const HZ_DEFAULT_AVATAR = "https://hzstatic.hzinsights.com/static/yb_wx/hz_default_avatar.png"
 
 const HZPHONE = "057187186319"    //弘则电话