Browse Source

搜索返回一级分类标签

xyxie 1 year ago
parent
commit
4c1ab21844
2 changed files with 40 additions and 1 deletions
  1. 36 1
      controller/english_report/english_report.go
  2. 4 0
      models/english_report/report.go

+ 36 - 1
controller/english_report/english_report.go

@@ -273,7 +273,6 @@ func (er *EnglishReportController) FilterByEs(c *gin.Context) {
 					reportItem.ContentSub = v.Highlight["BodyContent"][0]
 				}
 				reportItem.ContentSub = "<div style=\"-webkit-line-clamp: 3;-webkit-box-orient: vertical;display: -webkit-box;overflow: hidden;text-overflow: ellipsis;\">" + reportItem.ContentSub + "</div>"
-
 			}
 			tempList = append(tempList, reportItem)
 		}
@@ -281,13 +280,28 @@ func (er *EnglishReportController) FilterByEs(c *gin.Context) {
 	videoIds := make([]uint, 0)
 	videoMap := make(map[uint]*english_video.EnglishVideo)
 	videoItem := new(english_video.EnglishVideo)
+	var classifyThirdIds []int
 	if len(tempList) > 0 {
 		for _, reportItem := range tempList {
 			if reportItem.VideoId > 0 {
 				videoIds = append(videoIds, reportItem.VideoId)
 			}
+			classifyThirdIds = append(classifyThirdIds, reportItem.ClassifyIdSecond)
 		}
 	}
+
+	enClassify := new(english_classify.Classify)
+	//查询分类详情
+	nameList, err := enClassify.GetEnglishClassifyFullNameByIds(classifyThirdIds)
+	if err != nil {
+		resp.FailMsg("获取分类失败", "获取分类信息失败,Err:"+err.Error(), c)
+		return
+	}
+	classifyMap := make(map[int]*english_classify.EnglishClassifyFullName)
+	for _, v := range nameList {
+		classifyMap[v.Id] = v
+	}
+
 	if len(videoIds) > 0 {
 		videoList, e := videoItem.GetVideosByIds(videoIds)
 		if e != nil {
@@ -307,6 +321,10 @@ func (er *EnglishReportController) FilterByEs(c *gin.Context) {
 			temp.ContentSub = reportItem.ContentSub
 			temp.PublishTime = reportItem.PublishTime
 			temp.ReportCode = reportItem.ReportCode
+			classifyInfo := new(english_classify.EnglishClassifyFullName)
+			if cv, ok := classifyMap[reportItem.ClassifyIdSecond]; ok {
+				classifyInfo = cv
+			}
 			if reportItem.ReportId > 0 {
 				temp.Id = reportItem.ReportId
 				temp.ClassifyIdFirst = reportItem.ClassifyIdFirst
@@ -314,6 +332,8 @@ func (er *EnglishReportController) FilterByEs(c *gin.Context) {
 				temp.ClassifyIdSecond = reportItem.ClassifyIdSecond
 				temp.ClassifyNameSecond = reportItem.ClassifyNameSecond
 				temp.Stage, _ = strconv.Atoi(reportItem.StageStr)
+				temp.ClassifyIdRoot = classifyInfo.RootId
+				temp.ClassifyNameRoot = classifyInfo.RootName
 			} else if reportItem.VideoId > 0 {
 				if videoTemp, ok := videoMap[reportItem.VideoId]; ok {
 					temp.ReportType = 1
@@ -325,6 +345,8 @@ func (er *EnglishReportController) FilterByEs(c *gin.Context) {
 					temp.VideoUrl = videoTemp.VideoUrl
 					temp.VideoCoverUrl = videoTemp.VideoCoverUrl
 					temp.VideoSeconds = videoTemp.VideoSeconds
+					temp.ClassifyIdRoot = classifyInfo.RootId
+					temp.ClassifyNameRoot = classifyInfo.RootName
 				}
 			}
 			reportList = append(reportList, temp)
@@ -376,6 +398,17 @@ func (er *EnglishReportController) Detail(c *gin.Context) {
 		return
 	}
 
+	// 查询分类
+	classifyItem := new(english_classify.Classify)
+	fullClassify := new(english_classify.EnglishClassifyFullName)
+	fullClassifyList, err := classifyItem.GetEnglishClassifyFullNameByIds([]int{reportItem.ClassifyIdSecond})
+	if err != nil {
+		resp.FailMsg("查询分类信息失败", "查询分类信息失败,Err:"+err.Error(), c)
+		return
+	}
+	if len(fullClassifyList) > 0 {
+		fullClassify = fullClassifyList[0]
+	}
 	// 记录邮箱
 	shareEmailId := userinfo.Id
 	if shareEmailId > 0 {
@@ -405,6 +438,8 @@ func (er *EnglishReportController) Detail(c *gin.Context) {
 		CreateTime:         utils.TimeTransferString(utils.FormatDateTime, reportItem.CreateTime),
 		ModifyTime:         utils.TimeTransferString(utils.FormatDateTime, reportItem.ModifyTime),
 		KeyTakeaways:       reportItem.KeyTakeaways,
+		ClassifyIdRoot:     fullClassify.RootId,
+		ClassifyNameRoot:   fullClassify.RootName,
 	}
 	baseData := new(english_report.ReportDetailResp)
 	baseData.Report = reportDetail

+ 4 - 0
models/english_report/report.go

@@ -108,6 +108,8 @@ type ReportDetail struct {
 	Overview           string `json:"overview"`             //概述
 	VideoSize          string `json:"video_size"`           //音频文件大小,单位M
 	KeyTakeaways       string `json:"key_takeaways"`        //关键点
+	ClassifyIdRoot     int    `json:"classify_id_root"`     //顶级分类ID
+	ClassifyNameRoot   string `json:"classify_name_root"`   //顶级分类名称
 }
 
 type ReportDetailResp struct {
@@ -132,6 +134,8 @@ type SearchEnglishReportItem struct {
 	VideoSeconds       string `json:"video_seconds"`        //视频时长
 	ReportType         int    `json:"report_type"`          //类型:0英文研报,1英文线上路演
 	Stage              int    `json:"stage"`                //期数
+	ClassifyIdRoot     int    `json:"classify_id_root"`     //顶级分类ID
+	ClassifyNameRoot   string `json:"classify_name_root"`   //顶级分类名称
 }
 
 type ElasticEnglishReportDetail struct {