Ver código fonte

修改首页报告汇总返回值,修改专栏列表vip标识,修改搜索高亮标签

xiexiaoyuan 3 anos atrás
pai
commit
af2baafc97

+ 1 - 1
models/response/classify.go

@@ -22,7 +22,7 @@ type ClassifyDetail struct {
 	Descript         string     `json:"descript"`
 	PermissionCheck     *PermissionCheckInfo    `json:"permission_check"`
 	AuthOk              bool `json:"auth_ok"`
-	IsVip           int       `json:"is_vip"'`
+	VipTitle           string       `json:"vip_title"'`
 }
 
 type ClassReportListItem struct {

+ 24 - 0
models/response/report.go

@@ -112,7 +112,17 @@ type ReportCollectListItem struct {
 	ContentSub         string `description:"内容前两个章节" json:"content_sub"`
 }
 
+type ReportCollectList struct {
+	Date     string   	`json:"date"`
+	SubList  []*ReportCollectListItem `json:"sub_list"`
+}
+
 type ReportCollectResp struct {
+	Paging     *PagingItem  		`json:"paging"`
+	List []*ReportCollectList `json:"list"`
+}
+
+type ReportSearchResp struct {
 	Paging     *PagingItem  		`json:"paging"`
 	List []*ReportCollectListItem `json:"list"`
 }
@@ -141,4 +151,18 @@ type TickerDataItem struct {
 	DdValue          float64       `json:"dd_value"`
 	WwValue          float64       `json:"ww_value"`
 	MmValue          float64       `json:"mm_value"`
+}
+
+type ReportCollectListResp []*ReportCollectList
+
+func (p ReportCollectListResp) Len() int {
+	return len(p)
+}
+
+func (p ReportCollectListResp) Less(i, j int) bool {
+	return p[i].Date > p[j].Date
+}
+
+func (p ReportCollectListResp) Swap(i, j int) {
+	p[i], p[j] = p[j], p[i]
 }

+ 18 - 20
services/elastic/report.go

@@ -41,25 +41,12 @@ func SearchReport(keyWord string, pageIndex, pageSize int) (searchResp *elastic.
 				},
 			},
 		},
-	}
-	mustMap := map[string]interface{}{
-		"bool": map[string]interface{}{
-			"should": shouldSub,
-		},
-	}
-	must = append(must, mustMap)
-
-	must = append(must, map[string]interface{}{
-		"match": map[string]interface{}{
-			"PublishState": 2,
-		},
-	})
-	should := []map[string]interface{}{
 		map[string]interface{}{
 			"match_phrase": map[string]interface{}{
 				"Title": map[string]interface{}{
 					"query": keyWord,
-					"slop": "50",
+					//"slop": "50",
+					"boost": 5,
 				},
 			},
 		},
@@ -67,7 +54,7 @@ func SearchReport(keyWord string, pageIndex, pageSize int) (searchResp *elastic.
 			"match_phrase": map[string]interface{}{
 				"Categories": map[string]interface{}{
 					"query": keyWord,
-					"slop": "50",
+					"boost": 4,
 				},
 			},
 		},
@@ -75,16 +62,27 @@ func SearchReport(keyWord string, pageIndex, pageSize int) (searchResp *elastic.
 			"match_phrase": map[string]interface{}{
 				"BodyContent": map[string]interface{}{
 					"query": keyWord,
-					"slop": "50",
+					"boost": 3,
 				},
 			},
 		},
 	}
+	mustMap := map[string]interface{}{
+		"bool": map[string]interface{}{
+			"should": shouldSub,
+		},
+	}
+	must = append(must, mustMap)
+
+	must = append(must, map[string]interface{}{
+		"match": map[string]interface{}{
+			"PublishState": 2,
+		},
+	})
 	source := map[string]interface{}{
 		"query": map[string]interface{}{
 			"bool": map[string]interface{}{
 				"must": must,
-				"should": should,
 			},
 		},
 	}
@@ -96,8 +94,8 @@ func SearchReport(keyWord string, pageIndex, pageSize int) (searchResp *elastic.
 			"Categories":map[string]interface{}{},
 			"BodyContent":map[string]interface{}{},
 		},
-		"pre_tags" : "<font size='4.5' color='#473BFF'>",
-		"post_tags": "</font>",
+		"pre_tags" : "<span style=\"color:#efefef\">",
+		"post_tags": "</span>",
 	}
 
 	source["sort"] = []map[string]interface{}{

+ 4 - 1
services/report/classify.go

@@ -127,7 +127,10 @@ func GetClassifyDetail(user user.UserInfo, classifyIdSecond int) (detail *respon
 	detail.ClassifyNameSecond = classifyInfo.ClassifyName
 	detail.Abstract = classifyInfo.Abstract
 	detail.Descript = classifyInfo.Descript
-	detail.IsVip = int(classifyInfo.IsVip)
+	if  classifyInfo.IsVip > 0{
+		detail.VipTitle = "弘则研究董事长"
+	}
+
 	detail.PermissionCheck = &permissionCheckInfo
 	detail.AuthOk = authOk
 

+ 25 - 7
services/report/report.go

@@ -22,6 +22,7 @@ import (
 	"hongze/hongze_yb/services/user"
 	"hongze/hongze_yb/utils"
 	"html"
+	"sort"
 	"strconv"
 	"time"
 )
@@ -561,6 +562,7 @@ func GetCollectReportList(user user.UserInfo, chartPermissionId, pageIndex, page
 	}
 
 	var reportList []*response.ReportCollectListItem
+	list := response.ReportCollectListResp{}
 	var total int64
 	if len(reportChapterTypeIds) > 0 || len(classifySecondIds) > 0 {
 		offset := (pageIndex - 1) * pageSize
@@ -570,20 +572,36 @@ func GetCollectReportList(user user.UserInfo, chartPermissionId, pageIndex, page
 			err = errors.New("查询报告信息出错")
 			return
 		}
+		listMap := make(map[string]*response.ReportCollectList)
+		for _, v := range reportList {
+			v.ContentSub = html.UnescapeString(v.ContentSub)
+			if _, ok := listMap[v.PublishTime.Format("2006-01-02")]; !ok {
+				temp := new(response.ReportCollectList)
+				temp.Date = v.PublishTime.Format("2006-01-02")
+				listMap[v.PublishTime.Format("2006-01-02")] = temp
+			}
+			listMap[v.PublishTime.Format("2006-01-02")].SubList = append(listMap[v.PublishTime.Format("2006-01-02")].SubList, v)
+		}
+		for _, v := range listMap {
+			list = append(list, v)
+		}
 		total, err = report.GetReportCollectCountByPermission(classifySecondIds, reportChapterTypeIds)
 		if err != nil {
 			errMsg = err.Error()
 			err = errors.New("查询报告总数出错")
 			return
 		}
+		if len(list) > 0 {
+			sort.Sort(list)
+		}
 	}
 	ret = new(response.ReportCollectResp)
-	ret.List = reportList
+	ret.List = list
 	ret.Paging = response.GetPaging(pageIndex, pageSize, int(total))
 	return
 }
 
-func SearchReport(user user.UserInfo, keyWord string, pageIndex, pageSize int)(ret *response.ReportCollectResp, err error) {
+func SearchReport(user user.UserInfo, keyWord string, pageIndex, pageSize int)(ret *response.ReportSearchResp, err error) {
 	var errMsg string
 	defer func() {
 		if err != nil {
@@ -619,27 +637,27 @@ func SearchReport(user user.UserInfo, keyWord string, pageIndex, pageSize int)(r
 			temp.ClassifyIdSecond = reportItem.ClassifyIdSecond
 			temp.ClassifyNameSecond = reportItem.ClassifyNameSecond
 			temp.Title = reportItem.Title
-			temp.ContentSub = html.UnescapeString(reportItem.BodyContent)
+			temp.ContentSub = html.UnescapeString(html.UnescapeString(reportItem.BodyContent))
 			temp.PublishTime, err = time.Parse("2006-01-02 15:04:05", reportItem.PublishTime)
 			fmt.Println(*reportItem)
 			if len(v.Highlight["Title"]) > 0 {
 				temp.Title = v.Highlight["Title"][0]
 			}
 			if len(v.Highlight["BodyContent"]) > 0 {
-				temp.ContentSub = html.UnescapeString(v.Highlight["BodyContent"][0])
+				temp.ContentSub = html.UnescapeString(html.UnescapeString(v.Highlight["BodyContent"][0]))
 			}
 			if len(v.Highlight["Categories"]) > 0 {
 				if temp.ClassifyNameSecond != "" {
-					temp.ClassifyNameSecond = "<font size='4.5' color='#473BFF'>"+temp.ClassifyNameSecond+"</font>"
+					temp.ClassifyNameSecond = "<span style=\"color:#efefef\">"+temp.ClassifyNameSecond+"</span>"
 				}
 				if temp.ClassifyNameFirst != "" {
-					temp.ClassifyNameFirst = "<font size='4.5' color='#473BFF'>"+temp.ClassifyNameFirst+"</font>"
+					temp.ClassifyNameFirst = "<span style=\"color:#efefef\">"+temp.ClassifyNameFirst+"</span>"
 				}
 			}
 			reportList = append(reportList, temp)
 		}
 	}
-	ret = new(response.ReportCollectResp)
+	ret = new(response.ReportSearchResp)
 	ret.List = reportList
 	ret.Paging = response.GetPaging(pageIndex, pageSize, int(total))
 	return