|
@@ -64,52 +64,70 @@ func (this *HomeController) NewList() {
|
|
|
|
|
|
}
|
|
|
|
|
|
- //var total int
|
|
|
+ var total int
|
|
|
+ var list []*models.CygxResourceDataResp
|
|
|
+ var err error
|
|
|
resp := new(models.HomeResourceDataListResp)
|
|
|
- condition += " AND source IN ('article','activity','yanxuanspecial') " // 只有研选的文章、研选的活动、研选的专栏这三种
|
|
|
|
|
|
- if labelKeyword == "" {
|
|
|
- //查询近一个月的数据
|
|
|
- condition += " AND search_order_time > '" + time.Now().AddDate(0, 0, -60).Format(utils.FormatDateTime) + "'"
|
|
|
- yanxuanActivityIds = services.GetYanxuanActivityIds() // 获取所有的研选活动ID
|
|
|
- yanxuanArticleIds = services.GetYanxuanArticleIds() //获取所有研选文章ID
|
|
|
- } else {
|
|
|
- var errIds error
|
|
|
- yanxuanActivityIds, yanxuanArticleIds, errIds = services.GetConditionInitByTagIds(labelKeyword)
|
|
|
- if errIds != nil {
|
|
|
+ if keyWord == "" {
|
|
|
+ condition += " AND source IN ('article','activity','yanxuanspecial') " // 只有研选的文章、研选的活动、研选的专栏这三种
|
|
|
+ if labelKeyword == "" {
|
|
|
+ //查询近一个月的数据
|
|
|
+ condition += " AND search_order_time > '" + time.Now().AddDate(0, 0, -60).Format(utils.FormatDateTime) + "'"
|
|
|
+ yanxuanActivityIds = services.GetYanxuanActivityIds() // 获取所有的研选活动ID
|
|
|
+ yanxuanArticleIds = services.GetYanxuanArticleIds() //获取所有研选文章ID
|
|
|
+ } else {
|
|
|
+ yanxuanActivityIds, yanxuanArticleIds, err = services.GetConditionInitByTagIds(labelKeyword)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取活动权限数据失败,GetConditionInitByTagIds Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //如果不是 "全部报告" 、 "专栏" 的关键词查询,就不做研选专栏的查询
|
|
|
+ if labelKeyword != utils.LABEL_L2_1 && labelKeyword != utils.LABEL_L2_2 {
|
|
|
+ condition += ` AND IF ( source = 'yanxuanspecial' , source_id IN (0) ,1=1 ) `
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ yanxuanArticleIds = append(yanxuanArticleIds, 0)
|
|
|
+ yanxuanActivityIds = append(yanxuanActivityIds, 0)
|
|
|
+ //yanxuanspecialIds = append(yanxuanspecialIds, 0)
|
|
|
+ condition += ` AND IF ( source = 'article' , source_id IN (` + utils.GetOrmInReplace(len(yanxuanArticleIds)) + `) ,1=1 ) `
|
|
|
+ pars = append(pars, yanxuanArticleIds)
|
|
|
+
|
|
|
+ condition += ` AND IF ( source = 'activity' , source_id IN (` + utils.GetOrmInReplace(len(yanxuanActivityIds)) + `) ,1=1 ) `
|
|
|
+ pars = append(pars, yanxuanActivityIds)
|
|
|
+
|
|
|
+ total, err = models.GetResourceDataCount(condition, pars)
|
|
|
+ if err != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取活动权限数据失败,GetConditionInitByTagIds Err:" + errIds.Error()
|
|
|
+ br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- //如果不是 "全部报告" 、 "专栏" 的关键词查询,就不做研选专栏的查询
|
|
|
- if labelKeyword != utils.LABEL_L2_1 && labelKeyword != utils.LABEL_L2_2 {
|
|
|
- condition += ` AND IF ( source = 'yanxuanspecial' , source_id IN (0) ,1=1 ) `
|
|
|
+ list, err = services.GetResourceDataList(condition, pars, startSize, pageSize, user)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- yanxuanArticleIds = append(yanxuanArticleIds, 0)
|
|
|
- yanxuanActivityIds = append(yanxuanActivityIds, 0)
|
|
|
- //yanxuanspecialIds = append(yanxuanspecialIds, 0)
|
|
|
- condition += ` AND IF ( source = 'article' , source_id IN (` + utils.GetOrmInReplace(len(yanxuanArticleIds)) + `) ,1=1 ) `
|
|
|
- pars = append(pars, yanxuanArticleIds)
|
|
|
-
|
|
|
- condition += ` AND IF ( source = 'activity' , source_id IN (` + utils.GetOrmInReplace(len(yanxuanActivityIds)) + `) ,1=1 ) `
|
|
|
- pars = append(pars, yanxuanActivityIds)
|
|
|
+ } else {
|
|
|
|
|
|
- total, err := models.GetResourceDataCount(condition, pars)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
- return
|
|
|
+ tmpResult, tmpTotalResult, err := services.SqlComprehensiveSearch(keyWord, startSize, pageSize)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "检索失败"
|
|
|
+ br.ErrMsg = "检索失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ total = tmpTotalResult
|
|
|
+ list, err = services.GetResourceDataEsList(tmpResult, user)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
- list, err := services.GetResourceDataList(condition, pars, startSize, pageSize, user)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- page = paging.GetPaging(currentIndex, pageSize, total)
|
|
|
+
|
|
|
if currentIndex == 1 && keyWord != "" {
|
|
|
go services.AddSearchKeyWord(user, keyWord, 1)
|
|
|
}
|