|
@@ -2333,8 +2333,6 @@ func (this *ReportController) SearchReport() {
|
|
|
condition = `AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
|
|
|
sqlGroup = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
|
|
|
//对应产业名称、标的名称。
|
|
|
- //OR a.article_id IN ( SELECT article_id FROM cygx_industrial_article_group_subject WHERE industrial_subject_id IN ( SELECT industrial_subject_id FROM cygx_industrial_subject WHERE subject_name LIKE '%` + keyWord + `%' ) )
|
|
|
- //OR a.article_id IN ( SELECT article_id FROM cygx_industrial_article_group_management WHERE industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_management WHERE industry_name LIKE '%` + keyWord + `%' ) )
|
|
|
listYx, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition+sqlGroup, user.UserId)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取信息失败"
|
|
@@ -2420,7 +2418,7 @@ func (this *ReportController) SearchResource() {
|
|
|
conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
|
|
|
condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
|
|
|
|
|
|
- listHz, err := models.GetSearchResourceList(condition)
|
|
|
+ listHz, err := models.GetSearchResourceList(condition, 0, 0)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取信息失败"
|
|
|
br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
|
|
@@ -2430,7 +2428,7 @@ func (this *ReportController) SearchResource() {
|
|
|
conditionOr = ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
|
|
|
condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
|
|
|
|
|
|
- listYx, err := models.GetSearchResourceList(condition)
|
|
|
+ listYx, err := models.GetSearchResourceList(condition, 0, 0)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取信息失败"
|
|
|
br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
|
|
@@ -2510,3 +2508,174 @@ func (this *ReportController) SearchResource() {
|
|
|
br.Msg = "获取成功"
|
|
|
br.Data = resp
|
|
|
}
|
|
|
+
|
|
|
+// @Title 报告搜索、资源包搜索接口
|
|
|
+// @Description 报告搜索、资源包搜索接口接口
|
|
|
+// @Param KeyWord query string true "搜索关键词"
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
+// @Success 200 {object} models.SearchReportAndResourceResp
|
|
|
+// @router /searchReportAndResource [get]
|
|
|
+func (this *ReportController) SearchReportAndResource() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ user := this.User
|
|
|
+ if user == nil {
|
|
|
+ br.Msg = "请重新登录"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+ uid := user.UserId
|
|
|
+ keyWord := this.GetString("KeyWord")
|
|
|
+ pageSize, _ := this.GetInt("PageSize")
|
|
|
+ var condition string
|
|
|
+ var sqlGroup string
|
|
|
+ //匹配报告标题、
|
|
|
+ condition = `AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
|
|
|
+ sqlGroup = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
|
|
|
+ if pageSize > 0 {
|
|
|
+ sqlGroup += ` LIMIT 5 `
|
|
|
+ }
|
|
|
+ ListYxReport, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition+sqlGroup, user.UserId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for k, v := range ListYxReport {
|
|
|
+ ListYxReport[k].Source = 2
|
|
|
+ if v.MyCollectNum > 0 {
|
|
|
+ ListYxReport[k].IsCollect = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ListHzReport, err := models.GetReoprtSearchList(` AND a.article_id < 1000000 `+condition+` OR ( article_type = 'lyjh' `+condition+` ) `+sqlGroup, user.UserId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for k, v := range ListHzReport {
|
|
|
+ ListHzReport[k].Source = 1
|
|
|
+ if v.MyCollectNum > 0 {
|
|
|
+ ListHzReport[k].IsCollect = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(ListYxReport) == 0 {
|
|
|
+ ListYxReport = make([]*models.ArticleCollectionResp, 0)
|
|
|
+ }
|
|
|
+ if len(ListHzReport) == 0 {
|
|
|
+ ListHzReport = make([]*models.ArticleCollectionResp, 0)
|
|
|
+ }
|
|
|
+
|
|
|
+ fllowList, err := models.GetUserFllowIndustrialList(uid)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fllowMap := make(map[int]int)
|
|
|
+ if len(fllowList) > 0 {
|
|
|
+ for _, v := range fllowList {
|
|
|
+ fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var conditionOr string
|
|
|
+ conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
|
|
|
+ condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
|
|
|
+
|
|
|
+ listHzResource, err := models.GetSearchResourceList(condition, 0, pageSize)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ conditionOr = ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
|
|
|
+ condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
|
|
|
+
|
|
|
+ listYxResource, err := models.GetSearchResourceList(condition, 0, pageSize)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //合并产业关联的标的
|
|
|
+ listSubjcet, err := models.GetThemeHeatSubjectList("")
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ industrialIdArr := make([]int, 0)
|
|
|
+ for k, v := range listHzResource {
|
|
|
+ listHzResource[k].Source = 1
|
|
|
+ if fllowMap[v.IndustrialManagementId] > 0 {
|
|
|
+ listHzResource[k].IsFollw = true
|
|
|
+ }
|
|
|
+ industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
|
|
|
+ }
|
|
|
+
|
|
|
+ for k, v := range listYxResource {
|
|
|
+ listYxResource[k].Source = 2
|
|
|
+ if fllowMap[v.IndustrialManagementId] > 0 {
|
|
|
+ listYxResource[k].IsFollw = true
|
|
|
+ }
|
|
|
+ industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(industrialIdArr) > 0 {
|
|
|
+ //合并产业关联的标的
|
|
|
+ listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ mapIndustrial := make(map[string]int)
|
|
|
+ for _, v := range listSubjcet {
|
|
|
+ for k2, v2 := range listYxResource {
|
|
|
+ if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 {
|
|
|
+ listYxResource[k2].IndustrialSubjectList = append(listYxResource[k2].IndustrialSubjectList, v)
|
|
|
+ mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for k2, v2 := range listHzResource {
|
|
|
+ if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
|
|
|
+ listHzResource[k2].IndustrialSubjectList = append(listHzResource[k2].IndustrialSubjectList, v)
|
|
|
+ mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ resp := new(models.SearchReportAndResourceResp)
|
|
|
+ if len(listYxResource) == 0 {
|
|
|
+ listYxResource = make([]*models.IndustrialManagementHotResp, 0)
|
|
|
+ }
|
|
|
+ if len(listHzResource) == 0 {
|
|
|
+ listHzResource = make([]*models.IndustrialManagementHotResp, 0)
|
|
|
+ }
|
|
|
+
|
|
|
+ if keyWord != "" {
|
|
|
+ keyWordItem := new(models.CygxUserSearchKeyWord)
|
|
|
+ keyWordItem.UserId = user.UserId
|
|
|
+ keyWordItem.KeyWord = keyWord
|
|
|
+ keyWordItem.PageType = "ReortSearch"
|
|
|
+ keyWordItem.CreateTime = time.Now()
|
|
|
+ go models.AddUserSearchKeyWord(keyWordItem)
|
|
|
+ go services.AddUserSearchLog(user, keyWord, 5)
|
|
|
+ }
|
|
|
+
|
|
|
+ resp.ListHzResource = listHzResource
|
|
|
+ resp.ListYxResource = listYxResource
|
|
|
+ resp.ListYxReport = ListYxReport
|
|
|
+ resp.ListHzReport = ListHzReport
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = resp
|
|
|
+}
|