|
@@ -9,6 +9,7 @@ import (
|
|
|
"hongze/hongze_yb_en_api/models/base"
|
|
|
"hongze/hongze_yb_en_api/models/english_classify"
|
|
|
"hongze/hongze_yb_en_api/models/english_report"
|
|
|
+ "hongze/hongze_yb_en_api/models/english_video"
|
|
|
elasticService "hongze/hongze_yb_en_api/services/elastic"
|
|
|
english_report_service "hongze/hongze_yb_en_api/services/english_report"
|
|
|
"hongze/hongze_yb_en_api/utils"
|
|
@@ -39,7 +40,7 @@ func (er *EnglishReportController) List(c *gin.Context) {
|
|
|
var pars []interface{}
|
|
|
var total int64
|
|
|
var tmpList []*english_report.Report
|
|
|
- var list []*english_report.ReportListItem
|
|
|
+ list := make([]*english_report.ReportListItem, 0)
|
|
|
|
|
|
if req.ClassifyIdFirst >0 {
|
|
|
condition += " and classify_id_first = ?"
|
|
@@ -90,13 +91,24 @@ func (er *EnglishReportController) List(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
func (er *EnglishReportController) Classify(c *gin.Context) {
|
|
|
+ req := new(english_classify.ClassifyReq)
|
|
|
+ err := c.BindQuery(&req)
|
|
|
+ if err != nil {
|
|
|
+ errs, ok := err.(validator.ValidationErrors)
|
|
|
+ if !ok {
|
|
|
+ resp.FailData("参数解析失败", "Err:"+err.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
item := new(english_classify.Classify)
|
|
|
- parentList, err := item.GetParent()
|
|
|
+ parentList, err := item.GetParent(req.ClassifyType)
|
|
|
if err != nil {
|
|
|
resp.FailMsg("获取失败", "获取失败,Err:"+err.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
- childList, err := item.GetChild()
|
|
|
+ childList, err := item.GetChild(req.ClassifyType)
|
|
|
if err != nil {
|
|
|
resp.FailMsg("获取失败", "获取失败,Err:"+err.Error(), c)
|
|
|
return
|
|
@@ -110,6 +122,7 @@ func (er *EnglishReportController) Classify(c *gin.Context) {
|
|
|
ParentId: v.ParentId,
|
|
|
ClassifyLabel: v.ClassifyLabel,
|
|
|
ShowType: v.ShowType,
|
|
|
+ ClassifyType: v.ClassifyType,
|
|
|
IsShow: v.IsShow,
|
|
|
CreateTime: utils.TimeTransferString(utils.FormatDateTime, v.CreateTime),
|
|
|
ModifyTime: utils.TimeTransferString(utils.FormatDateTime, v.ModifyTime),
|
|
@@ -125,6 +138,7 @@ func (er *EnglishReportController) Classify(c *gin.Context) {
|
|
|
ParentId: v.ParentId,
|
|
|
ClassifyLabel: v.ClassifyLabel,
|
|
|
ShowType: v.ShowType,
|
|
|
+ ClassifyType: v.ClassifyType,
|
|
|
IsShow: v.IsShow,
|
|
|
CreateTime: utils.TimeTransferString(utils.FormatDateTime, v.CreateTime),
|
|
|
ModifyTime: utils.TimeTransferString(utils.FormatDateTime, v.ModifyTime),
|
|
@@ -168,12 +182,12 @@ func (er *EnglishReportController) FilterByEs(c *gin.Context) {
|
|
|
resp.FailMsg("报告搜索失败", "报告搜索失败,Err:" + err.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
+ var tempList []*english_report.ElasticEnglishReportDetail
|
|
|
if searchResp.Hits != nil {
|
|
|
for _, v := range searchResp.Hits.Hits {
|
|
|
- temp := new(english_report.SearchEnglishReportItem)
|
|
|
itemJson, tmpErr := v.Source.MarshalJSON()
|
|
|
if tmpErr != nil {
|
|
|
- resp.FailMsg("报告搜索失败 解析出错", "报告搜索失败,Err:" + tmpErr.Error(), c)
|
|
|
+ resp.FailMsg("报告搜索失败 解析出错", "报告搜索失败,Err:"+tmpErr.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
reportItem := new(english_report.ElasticEnglishReportDetail)
|
|
@@ -182,26 +196,68 @@ func (er *EnglishReportController) FilterByEs(c *gin.Context) {
|
|
|
resp.FailMsg("报告搜索失败 解析出错", "报告搜索失败,Err:" + tmpErr.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
- temp.Id = reportItem.ReportId
|
|
|
- temp.ClassifyIdFirst = reportItem.ClassifyIdFirst
|
|
|
- temp.ClassifyNameFirst = reportItem.ClassifyNameFirst
|
|
|
- temp.ClassifyIdSecond = reportItem.ClassifyIdSecond
|
|
|
- temp.ClassifyNameSecond = reportItem.ClassifyNameSecond
|
|
|
+ if reportItem.ReportId > 0 {
|
|
|
+ if len(v.Highlight["Title"]) > 0 {
|
|
|
+ reportItem.Title = v.Highlight["Title"][0]
|
|
|
+ }
|
|
|
+ if len(v.Highlight["BodyContent"]) > 0 {
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ videoIds := make([]uint, 0)
|
|
|
+ videoMap := make(map[uint]*english_video.EnglishVideo)
|
|
|
+ videoItem := new(english_video.EnglishVideo)
|
|
|
+ if len(tempList)> 0 {
|
|
|
+ for _, reportItem := range tempList {
|
|
|
+ if reportItem.VideoId > 0 {
|
|
|
+ videoIds = append(videoIds, reportItem.VideoId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(videoIds) > 0 {
|
|
|
+ videoList, e := videoItem.GetVideosByIds(videoIds)
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("查询线上路演列表出错", "查询线上路演列表出错,Err:" + e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range videoList {
|
|
|
+ videoMap[v.Id] = v
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(tempList)> 0 {
|
|
|
+ for _, reportItem := range tempList {
|
|
|
+ temp := new(english_report.SearchEnglishReportItem)
|
|
|
temp.Title = reportItem.Title
|
|
|
temp.Author = reportItem.Author
|
|
|
temp.CreateTime = reportItem.CreateTime
|
|
|
- // 默认应该从数据库中查询
|
|
|
temp.ContentSub = reportItem.ContentSub
|
|
|
temp.PublishTime = reportItem.PublishTime
|
|
|
temp.ReportCode = reportItem.ReportCode
|
|
|
- if len(v.Highlight["Title"]) > 0 {
|
|
|
- temp.Title = v.Highlight["Title"][0]
|
|
|
- }
|
|
|
- if len(v.Highlight["BodyContent"]) > 0 {
|
|
|
- temp.ContentSub = v.Highlight["BodyContent"][0]
|
|
|
+ if reportItem.ReportId > 0 {
|
|
|
+ temp.Id = reportItem.ReportId
|
|
|
+ temp.ClassifyIdFirst = reportItem.ClassifyIdFirst
|
|
|
+ temp.ClassifyNameFirst = reportItem.ClassifyNameFirst
|
|
|
+ temp.ClassifyIdSecond = reportItem.ClassifyIdSecond
|
|
|
+ temp.ClassifyNameSecond = reportItem.ClassifyNameSecond
|
|
|
+ }else if reportItem.VideoId > 0 {
|
|
|
+ if videoTemp, ok := videoMap[reportItem.VideoId]; ok {
|
|
|
+ temp.ReportType = 1
|
|
|
+ temp.Id = videoTemp.Id
|
|
|
+ temp.ClassifyIdFirst = videoTemp.ClassifyIdFirst
|
|
|
+ temp.ClassifyNameFirst = videoTemp.ClassifyNameFirst
|
|
|
+ temp.ClassifyIdSecond = videoTemp.ClassifyIdSecond
|
|
|
+ temp.ClassifyNameSecond = videoTemp.ClassifyNameSecond
|
|
|
+ temp.VideoUrl = videoTemp.VideoUrl
|
|
|
+ temp.VideoCoverUrl = videoTemp.VideoCoverUrl
|
|
|
+ temp.VideoSeconds = videoTemp.VideoSeconds
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- temp.ContentSub = "<div style=\"-webkit-line-clamp: 3;-webkit-box-orient: vertical;display: -webkit-box;overflow: hidden;text-overflow: ellipsis;\">" + temp.ContentSub + "</div>"
|
|
|
reportList = append(reportList, temp)
|
|
|
}
|
|
|
}
|