|
@@ -28,6 +28,7 @@ import (
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
+// GetLatestClassReport 已购列表最新报告
|
|
|
func GetLatestClassReport(permissionIds []int, userId uint64) (purchaseList []*purchase.PurchaseListItem, err error) {
|
|
|
var errMsg string
|
|
|
defer func() {
|
|
@@ -458,7 +459,7 @@ func GetReportList(user user.UserInfo, keyWord string, classifyIdFirst, classify
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if classifyIdSecond > 0 {
|
|
|
+ if classifyIdSecond > 0 && keyWord == "" {
|
|
|
classifyInfo, tErr := classify.GetByClassifyId(classifyIdSecond)
|
|
|
if tErr != nil {
|
|
|
errMsg = tErr.Error()
|
|
@@ -489,6 +490,7 @@ func GetReportList(user user.UserInfo, keyWord string, classifyIdFirst, classify
|
|
|
}else{
|
|
|
if classifyParent.ClassifyName == "晨报" || classifyParent.ClassifyName == "周报"{
|
|
|
reportImgUrl = chartPermissionImageMap[1]
|
|
|
+ classifyIdSeconds = append(classifyIdSeconds,0)
|
|
|
}
|
|
|
|
|
|
chartPermissions, tErr := chart_permission_search_key_word_mapping.GetChartPermissionByFrom("rddp")
|
|
@@ -548,24 +550,75 @@ func GetReportList(user user.UserInfo, keyWord string, classifyIdFirst, classify
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if keyWord != "" {
|
|
|
- condition += ` AND (title LIKE ? OR abstract LIKE ?) `
|
|
|
- pars = append(pars, "%" + keyWord + "%")
|
|
|
- pars = append(pars, "%" + keyWord + "%")
|
|
|
- }
|
|
|
- offset := (pageIndex - 1) * pageSize
|
|
|
- list, err := report.GetReportList(condition, pars, offset, pageSize)
|
|
|
- if err != nil {
|
|
|
- errMsg = err.Error()
|
|
|
- err = errors.New("报告查询出错")
|
|
|
- return
|
|
|
- }
|
|
|
- total, err := report.GetReportListCount(condition, pars)
|
|
|
- if err != nil {
|
|
|
- errMsg = err.Error()
|
|
|
- err = errors.New("查询报告总数出错")
|
|
|
- return
|
|
|
+ var total int64
|
|
|
+ var list []*report.Report
|
|
|
+ if keyWord == "" {
|
|
|
+ offset := (pageIndex - 1) * pageSize
|
|
|
+ list, err = report.GetReportList(condition, pars, offset, pageSize)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = err.Error()
|
|
|
+ err = errors.New("报告查询出错")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ total, err = report.GetReportListCount(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = err.Error()
|
|
|
+ err = errors.New("查询报告总数出错")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if classifyIdSecond > 0 {
|
|
|
+ classifyIdSeconds = append(classifyIdSeconds, classifyIdSecond)
|
|
|
+ }
|
|
|
+ if classifyParent.ClassifyName == "晨报" || classifyParent.ClassifyName == "周报" {
|
|
|
+ classifyIdSeconds = append(classifyIdSeconds,0)
|
|
|
+ }
|
|
|
+ searchResp, total1, tErr := elasticService.ReportListSearch(keyWord, classifyIdFirst, classifyIdSeconds, pageIndex, pageSize)
|
|
|
+ if tErr != nil {
|
|
|
+ errMsg = tErr.Error()
|
|
|
+ err = errors.New("查询失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ total = int64(total1)
|
|
|
+ if searchResp.Hits != nil {
|
|
|
+ for _, v := range searchResp.Hits.Hits {
|
|
|
+ temp := new(report.Report)
|
|
|
+ itemJson, tmpErr := v.Source.MarshalJSON()
|
|
|
+ if tmpErr != nil {
|
|
|
+ errMsg = tmpErr.Error()
|
|
|
+ err = errors.New("解析出错")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ reportItem := new(response.EsReportItem)
|
|
|
+ tmpErr = json.Unmarshal(itemJson, &reportItem)
|
|
|
+ if tmpErr != nil {
|
|
|
+ errMsg = tmpErr.Error()
|
|
|
+ err = errors.New("解析json出错")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ temp.Id = reportItem.ReportId
|
|
|
+ temp.ClassifyIdFirst = reportItem.ClassifyIdFirst
|
|
|
+ temp.ClassifyNameFirst = reportItem.ClassifyNameFirst
|
|
|
+ temp.ClassifyIdSecond = reportItem.ClassifyIdSecond
|
|
|
+ temp.ClassifyNameSecond = reportItem.ClassifyNameSecond
|
|
|
+ temp.Abstract = reportItem.Abstract
|
|
|
+ temp.StageStr = reportItem.StageStr
|
|
|
+ temp.Title = reportItem.Title
|
|
|
+ temp.PublishTime, err = time.Parse("2006-01-02 15:04:05", reportItem.PublishTime)
|
|
|
+ if len(v.Highlight["Title"]) > 0 {
|
|
|
+ temp.Title = v.Highlight["Title"][0]
|
|
|
+ }
|
|
|
+ if len(v.Highlight["Abstract"]) > 0 {
|
|
|
+ temp.Title = v.Highlight["Abstract"][0]
|
|
|
+ }
|
|
|
+ if len(v.Highlight["StageStr"]) > 0 {
|
|
|
+ temp.Title = v.Highlight["StageStr"][0]
|
|
|
+ }
|
|
|
+ list = append(list, temp)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
var reportList []*response.ReportListItem
|
|
|
if len(list) > 0 {
|
|
|
for _, reportInfo := range list {
|
|
@@ -580,8 +633,14 @@ func GetReportList(user user.UserInfo, keyWord string, classifyIdFirst, classify
|
|
|
reportItem.Stage = reportInfo.Stage
|
|
|
reportItem.Abstract = reportInfo.Abstract
|
|
|
reportItem.Author = reportInfo.Author
|
|
|
+ stageStr := reportInfo.StageStr
|
|
|
+ if stageStr == "" {
|
|
|
+ stageStr = strconv.Itoa(reportInfo.Stage)
|
|
|
+ }
|
|
|
+ reportItem.TitleInfo = fmt.Sprintf("【第%s期|FICC|%s】%s", stageStr, reportItem.ClassifyNameSecond, reportItem.Title)
|
|
|
if reportInfo.ClassifyNameFirst == "晨报" || reportInfo.ClassifyNameFirst == "周报" || classifyIdSecond > 0{
|
|
|
reportItem.ReportImgUrl = utils.ALIYUN_YBIMG_HOST + reportImgUrl
|
|
|
+ reportItem.TitleInfo = fmt.Sprintf("【第%s期|FICC|%s】%s", stageStr, reportItem.ClassifyNameFirst, reportItem.Title)
|
|
|
} else if url,ok := permissionImageMap[reportInfo.ClassifyNameSecond]; ok {
|
|
|
reportItem.ReportImgUrl = utils.ALIYUN_YBIMG_HOST + url
|
|
|
}
|
|
@@ -590,6 +649,7 @@ func GetReportList(user user.UserInfo, keyWord string, classifyIdFirst, classify
|
|
|
reportItem.VideoUrl = reportInfo.VideoUrl
|
|
|
reportItem.AuthOk = authOk
|
|
|
}
|
|
|
+
|
|
|
reportList = append(reportList, reportItem)
|
|
|
}
|
|
|
|
|
@@ -694,7 +754,23 @@ func SearchReport(user user.UserInfo, keyWord string, pageIndex, pageSize int)(r
|
|
|
global.LOG.Critical(fmt.Sprintf("SearchReport: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
|
|
|
}
|
|
|
}()
|
|
|
- searchResp, total, err := elasticService.SearchReport(keyWord, pageIndex, pageSize)
|
|
|
+ //查询正常状态的分类
|
|
|
+ classifys, err := classify.GetSimpleAll()
|
|
|
+ if err != nil {
|
|
|
+ errMsg = err.Error()
|
|
|
+ err = errors.New("分类查询出错")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var classifyIdFirsts []int
|
|
|
+ classifyIdSeconds := []int{0}
|
|
|
+ for _, v := range classifys{
|
|
|
+ if v.ParentId == 0 {
|
|
|
+ classifyIdFirsts = append(classifyIdFirsts, v.Id)
|
|
|
+ }else{
|
|
|
+ classifyIdSeconds = append(classifyIdSeconds, v.Id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ searchResp, total, err := elasticService.SearchReport(keyWord, classifyIdFirsts, classifyIdSeconds, pageIndex, pageSize)
|
|
|
if err != nil {
|
|
|
errMsg = err.Error()
|
|
|
err = errors.New("查询失败")
|