|
@@ -36,6 +36,7 @@ func (er *EnglishReportController) List(c *gin.Context) {
|
|
|
page.SetPageSize(req.PageSize)
|
|
|
page.SetCurrent(req.Current)
|
|
|
item := new(english_report.Report)
|
|
|
+ enClassify := new(english_classify.Classify)
|
|
|
|
|
|
condition := " state=2"
|
|
|
var pars []interface{}
|
|
@@ -51,6 +52,21 @@ func (er *EnglishReportController) List(c *gin.Context) {
|
|
|
condition += " and classify_id_second = ?"
|
|
|
pars = append(pars, req.ClassifyIdSecond)
|
|
|
}
|
|
|
+ if req.ClassifyIdRoot > 0 && req.ClassifyIdFirst == 0 && req.ClassifyIdSecond == 0 {
|
|
|
+ //查询顶级分类下的所有二级分类
|
|
|
+ secondClassify, err := enClassify.GetSecondChild(req.ClassifyIdRoot)
|
|
|
+ if err != nil {
|
|
|
+ resp.FailMsg("获取分类失败", "获取分类信息失败,Err:"+err.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var classifyIdFirstSlice []int
|
|
|
+ for _, v := range secondClassify {
|
|
|
+ classifyIdFirstSlice = append(classifyIdFirstSlice, v.Id)
|
|
|
+ }
|
|
|
+
|
|
|
+ condition += " and classify_id_first in (?)"
|
|
|
+ pars = append(pars, classifyIdFirstSlice)
|
|
|
+ }
|
|
|
page.AddOrderItem(base.OrderItem{Column: "publish_time", Asc: false})
|
|
|
page.AddOrderItem(base.OrderItem{Column: "id", Asc: false})
|
|
|
total, tmpList, err = item.SelectPage(page, condition, pars)
|
|
@@ -59,7 +75,25 @@ func (er *EnglishReportController) List(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
if len(tmpList) > 0 {
|
|
|
+ var thirdIds []int
|
|
|
for _, v := range tmpList {
|
|
|
+ thirdIds = append(thirdIds, v.ClassifyIdSecond)
|
|
|
+ }
|
|
|
+ //查询分类详情
|
|
|
+ nameList, err := enClassify.GetEnglishClassifyFullNameByIds(thirdIds)
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ for _, v := range tmpList {
|
|
|
+ classifyInfo := new(english_classify.EnglishClassifyFullName)
|
|
|
+ if cv, ok := classifyMap[v.ClassifyIdSecond]; ok {
|
|
|
+ classifyInfo = cv
|
|
|
+ }
|
|
|
tmp := &english_report.ReportListItem{
|
|
|
Id: v.Id,
|
|
|
AddType: v.AddType,
|
|
@@ -73,6 +107,7 @@ func (er *EnglishReportController) List(c *gin.Context) {
|
|
|
Frequency: v.Frequency,
|
|
|
PublishTime: utils.TimeTransferString(utils.FormatDateTime, v.PublishTime),
|
|
|
Stage: v.Stage,
|
|
|
+ Overview: v.Overview,
|
|
|
VideoUrl: v.VideoUrl,
|
|
|
VideoName: v.VideoName,
|
|
|
VideoPlaySeconds: v.VideoPlaySeconds,
|
|
@@ -80,6 +115,8 @@ func (er *EnglishReportController) List(c *gin.Context) {
|
|
|
ShareUrl: "https://share.hzinsights.com/reportEn?code=" + v.ReportCode,
|
|
|
CreateTime: utils.TimeTransferString(utils.FormatDateTime, v.CreateTime),
|
|
|
ModifyTime: utils.TimeTransferString(utils.FormatDateTime, v.ModifyTime),
|
|
|
+ ClassifyIdRoot: classifyInfo.RootId,
|
|
|
+ ClassifyNameRoot: classifyInfo.RootName,
|
|
|
}
|
|
|
list = append(list, tmp)
|
|
|
}
|
|
@@ -92,7 +129,7 @@ func (er *EnglishReportController) List(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
func (er *EnglishReportController) Classify(c *gin.Context) {
|
|
|
- req := new(english_classify.ClassifyReq)
|
|
|
+ /*req := new(english_classify.ClassifyReq)
|
|
|
err := c.BindQuery(&req)
|
|
|
if err != nil {
|
|
|
errs, ok := err.(validator.ValidationErrors)
|
|
@@ -102,34 +139,64 @@ func (er *EnglishReportController) Classify(c *gin.Context) {
|
|
|
}
|
|
|
resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
|
|
|
return
|
|
|
- }
|
|
|
+ }*/
|
|
|
item := new(english_classify.Classify)
|
|
|
- parentList, err := item.GetParent(req.ClassifyType)
|
|
|
+ parentList, err := item.GetParent()
|
|
|
if err != nil {
|
|
|
resp.FailMsg("获取失败", "获取失败,Err:"+err.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
- childList, err := item.GetChild(req.ClassifyType)
|
|
|
+ childList, err := item.GetChild()
|
|
|
if err != nil {
|
|
|
resp.FailMsg("获取失败", "获取失败,Err:"+err.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
- parentMap := make(map[int][]*english_classify.ClassifyItem, 0)
|
|
|
+ rootMap := make(map[int][]*english_classify.ClassifyListItem, 0)
|
|
|
+ secondMap := make(map[int][]*english_classify.ClassifyListItem, 0)
|
|
|
+
|
|
|
for _, v := range childList {
|
|
|
- tmp := &english_classify.ClassifyItem{
|
|
|
- Id: v.Id,
|
|
|
- ClassifyName: v.ClassifyName,
|
|
|
- Sort: v.Sort,
|
|
|
- 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),
|
|
|
+ if v.ParentId != v.RootId { //三级分类
|
|
|
+ tmp := &english_classify.ClassifyListItem{
|
|
|
+ Id: v.Id,
|
|
|
+ ClassifyName: v.ClassifyName,
|
|
|
+ Sort: v.Sort,
|
|
|
+ ParentId: v.ParentId,
|
|
|
+ RootId: v.RootId,
|
|
|
+ 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),
|
|
|
+ }
|
|
|
+ secondMap[v.ParentId] = append(secondMap[v.ParentId], tmp)
|
|
|
}
|
|
|
- parentMap[v.ParentId] = append(parentMap[v.ParentId], tmp)
|
|
|
}
|
|
|
+
|
|
|
+ for _, v := range childList {
|
|
|
+ if v.ParentId == v.RootId { //二级分类
|
|
|
+ tmp := &english_classify.ClassifyListItem{
|
|
|
+ Id: v.Id,
|
|
|
+ ClassifyName: v.ClassifyName,
|
|
|
+ Sort: v.Sort,
|
|
|
+ ParentId: v.ParentId,
|
|
|
+ RootId: v.RootId,
|
|
|
+ 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),
|
|
|
+ }
|
|
|
+ if child, ok := secondMap[v.Id]; ok {
|
|
|
+ tmp.Child = child
|
|
|
+ } else {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ rootMap[v.ParentId] = append(rootMap[v.ParentId], tmp)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
list := make([]*english_classify.ClassifyListItem, 0)
|
|
|
for _, v := range parentList {
|
|
|
tmp := &english_classify.ClassifyListItem{
|
|
@@ -137,6 +204,7 @@ func (er *EnglishReportController) Classify(c *gin.Context) {
|
|
|
ClassifyName: v.ClassifyName,
|
|
|
Sort: v.Sort,
|
|
|
ParentId: v.ParentId,
|
|
|
+ RootId: v.RootId,
|
|
|
ClassifyLabel: v.ClassifyLabel,
|
|
|
ShowType: v.ShowType,
|
|
|
ClassifyType: v.ClassifyType,
|
|
@@ -144,7 +212,7 @@ func (er *EnglishReportController) Classify(c *gin.Context) {
|
|
|
CreateTime: utils.TimeTransferString(utils.FormatDateTime, v.CreateTime),
|
|
|
ModifyTime: utils.TimeTransferString(utils.FormatDateTime, v.ModifyTime),
|
|
|
}
|
|
|
- if child, ok := parentMap[v.Id]; ok {
|
|
|
+ if child, ok := rootMap[v.Id]; ok {
|
|
|
tmp.Child = child
|
|
|
} else {
|
|
|
continue
|
|
@@ -197,15 +265,14 @@ func (er *EnglishReportController) FilterByEs(c *gin.Context) {
|
|
|
resp.FailMsg("报告搜索失败 解析出错", "报告搜索失败,Err:"+tmpErr.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
- if len(v.Highlight["Title"]) > 0 {
|
|
|
- reportItem.Title = v.Highlight["Title"][0]
|
|
|
+ if len(v.Highlight["Abstract"]) > 0 {
|
|
|
+ reportItem.Abstract = v.Highlight["Abstract"][0]
|
|
|
}
|
|
|
if reportItem.ReportId > 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)
|
|
|
}
|
|
@@ -213,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 {
|
|
@@ -234,11 +316,16 @@ func (er *EnglishReportController) FilterByEs(c *gin.Context) {
|
|
|
for _, reportItem := range tempList {
|
|
|
temp := new(english_report.SearchEnglishReportItem)
|
|
|
temp.Title = reportItem.Title
|
|
|
+ temp.Abstract = reportItem.Abstract
|
|
|
temp.Author = reportItem.Author
|
|
|
temp.CreateTime = reportItem.CreateTime
|
|
|
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
|
|
@@ -246,6 +333,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
|
|
@@ -257,6 +346,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)
|
|
@@ -308,6 +399,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 {
|
|
@@ -337,6 +439,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
|