Sfoglia il codice sorgente

fix:报告列表/搜索列表章节的展示形式

Roc 5 mesi fa
parent
commit
df96f93e37
2 ha cambiato i file con 60 aggiunte e 37 eliminazioni
  1. 36 35
      models/response/report.go
  2. 24 2
      services/report/report.go

+ 36 - 35
models/response/report.go

@@ -117,29 +117,29 @@ type ReportChapterMenu struct {
 }
 
 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"`
-	ClassifyIdThird    int              `description:"三级分类id" json:"classify_id_third"`
-	ClassifyNameThird  string           `description:"三级分类名称" json:"classify_name_third"`
-	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"`
-	HasChapter         int              `description:"是否有章节" json:"has_chapter"`
-	VideoUrl           string           `description:"报告音频" json:"video_url"`
-	VideoName          string           `description:"音频文件名称" json:"video_name"`
-	VideoSize          string           `description:"音频文件大小,单位M" json:"video_size"`
-	VideoPlaySeconds   string           `description:"音频播放时长" json:"video_play_seconds"`
-	VideoImg           string           `json:"video_img"` // 音频播放条前面展示的图片
-
+	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"`
+	ClassifyIdThird      int              `description:"三级分类id" json:"classify_id_third"`
+	ClassifyNameThird    string           `description:"三级分类名称" json:"classify_name_third"`
+	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"`
+	HasChapter           int              `description:"是否有章节" json:"has_chapter"`
+	VideoUrl             string           `description:"报告音频" json:"video_url"`
+	VideoName            string           `description:"音频文件名称" json:"video_name"`
+	VideoSize            string           `description:"音频文件大小,单位M" json:"video_size"`
+	VideoPlaySeconds     string           `description:"音频播放时长" json:"video_play_seconds"`
+	VideoImg             string           `json:"video_img"` // 音频播放条前面展示的图片
+	ReportDetailShowType int              `description:"报告详情的展示类型:1-拼接;2:目录" json:"report_detail_show_type"`
 }
 
 type VideoListItem struct {
@@ -156,18 +156,19 @@ type ReportList struct {
 }
 
 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"`
-	ClassifyId          int       `description:"最小分类id" json:"classify_id"`
-	ClassifyName        string    `description:"最小分类名称" json:"classify_name"`
+	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"`
+	ClassifyId           int       `description:"最小分类id" json:"classify_id"`
+	ClassifyName         string    `description:"最小分类名称" json:"classify_name"`
+	ReportDetailShowType int       `description:"报告详情的展示类型:1-拼接;2:目录" json:"report_detail_show_type"`
 }
 
 type ReportCollectList struct {

+ 24 - 2
services/report/report.go

@@ -950,12 +950,14 @@ func GetReportList(user user.UserInfo, keyWord string, classifyIdFirst, classify
 			err = errors.New("获取报告分类列表失败" + e.Error())
 			return
 		}
-		listImgMap := make(map[int]string, 0)
-		classifyNameMap := make(map[int]string, 0)
+		listImgMap := make(map[int]string)
+		classifyNameMap := make(map[int]string)
+		classifyMap := make(map[int]*classify.Classify)
 		classifyLen := len(classifyList)
 		for i := 0; i < classifyLen; i++ {
 			listImgMap[classifyList[i].Id] = classifyList[i].YbListImg
 			classifyNameMap[classifyList[i].Id] = classifyList[i].ClassifyName
+			classifyMap[classifyList[i].Id] = classifyList[i]
 		}
 
 		var videoReportIds []int
@@ -1079,6 +1081,20 @@ func GetReportList(user user.UserInfo, keyWord string, classifyIdFirst, classify
 				reportItem.AuthOk = authOk
 			}
 
+			// 报告详情展示形式
+			{
+				minClassifyId := reportItem.ClassifyIdThird
+				if minClassifyId <= 0 {
+					minClassifyId = reportItem.ClassifyIdSecond
+				}
+				if minClassifyId <= 0 {
+					minClassifyId = reportItem.ClassifyIdFirst
+				}
+				if tmpClassify, ok := classifyMap[minClassifyId]; ok {
+					reportItem.ReportDetailShowType = int(tmpClassify.ReportDetailShowType)
+				}
+			}
+
 			reportList = append(reportList, reportItem)
 		}
 
@@ -1285,6 +1301,7 @@ func SearchReport(user user.UserInfo, keyWord string, pageIndex, pageSize int) (
 	classifyIdList := make([]int, 0)
 	var classifyIdFirsts []int
 	classifyIdSeconds := []int{0}
+	classifyMap := make(map[int]*classify.Classify)
 	for _, v := range classifys {
 		if v.ParentId == 0 {
 			classifyIdFirsts = append(classifyIdFirsts, v.Id)
@@ -1292,6 +1309,7 @@ func SearchReport(user user.UserInfo, keyWord string, pageIndex, pageSize int) (
 			classifyIdSeconds = append(classifyIdSeconds, v.Id)
 		}
 		classifyIdList = append(classifyIdList, v.Id)
+		classifyMap[v.Id] = v
 	}
 	keyWord = addAliasToKeyword(keyWord)
 	searchResp, total, err := elasticService.SearchReport(keyWord, classifyIdList, pageIndex, pageSize)
@@ -1344,6 +1362,10 @@ func SearchReport(user user.UserInfo, keyWord string, pageIndex, pageSize int) (
 			//	}
 			//}
 			temp.ContentSub = GetReportContentSub(temp.ContentSub, false)
+
+			if tmpClassify, ok := classifyMap[temp.ClassifyId]; ok {
+				temp.ReportDetailShowType = int(tmpClassify.ReportDetailShowType)
+			}
 			reportList = append(reportList, temp)
 		}
 	}