report.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package services
  2. import (
  3. "hongze/hongze_clpt/models"
  4. "hongze/hongze_clpt/utils"
  5. "strconv"
  6. "strings"
  7. )
  8. func GetReoprtSearchListHz(condition string, userId, startSize, pageSize int) (items []*models.ArticleCollectionResp, err error) {
  9. listHz, err := models.GetReoprtSearchList(condition, userId, startSize, pageSize)
  10. if err != nil {
  11. return
  12. }
  13. for k, _ := range listHz {
  14. listHz[k].Source = 1
  15. }
  16. var articleIds string
  17. for _, v := range listHz {
  18. articleIds += strconv.Itoa(v.ArticleId) + ","
  19. }
  20. articleIds = strings.TrimRight(articleIds, ",")
  21. silcearticleIds := strings.Split(articleIds, ",")
  22. //获取文章关联的产业
  23. var pars []interface{}
  24. pars = make([]interface{}, 0)
  25. articleIdList := make([]string, 0)
  26. for _, v := range silcearticleIds {
  27. articleIdList = append(articleIdList, v)
  28. }
  29. condition = ` AND mg.article_id IN ( ` + utils.GetOrmInReplace(len(silcearticleIds)) + ` ) `
  30. pars = append(pars, articleIdList)
  31. industrialList, err := models.GetIndustrialListByarticleId(pars, condition)
  32. if err != nil {
  33. return
  34. }
  35. industrialMap := make(map[int][]*models.IndustrialManagementResp)
  36. if len(industrialList) > 0 {
  37. for _, v := range industrialList {
  38. item := new(models.IndustrialManagementResp)
  39. //item.ArticleId = v.ArticleId
  40. item.IndustrialManagementId = v.IndustrialManagementId
  41. item.IndustryName = v.IndustryName
  42. item.ChartPermissionId = v.ChartPermissionId
  43. industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
  44. }
  45. }
  46. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  47. if err != nil {
  48. return
  49. }
  50. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  51. mapCategoryUrl := make(map[string]string)
  52. var categoryId string
  53. var imgUrlChart string
  54. for _, v := range categoryUrlList {
  55. vslice := strings.Split(v, "_")
  56. categoryId = vslice[0]
  57. imgUrlChart = vslice[len(vslice)-1]
  58. mapCategoryUrl[categoryId] = imgUrlChart
  59. }
  60. for k, v := range listHz {
  61. if len(industrialMap[v.ArticleId]) > 0 {
  62. listHz[k].List = industrialMap[v.ArticleId]
  63. } else {
  64. listHz[k].List = make([]*models.IndustrialManagementResp, 0)
  65. }
  66. listHz[k].Body = ""
  67. listHz[k].Abstract, _ = GetReportContentTextSub(v.Abstract)
  68. listHz[k].Annotation, _ = GetReportContentTextSub(v.Annotation)
  69. //行业比较研究、资金流向,显示报告的摘要
  70. if listHz[k].CategoryName == "行业比较研究" || listHz[k].CategoryName == "资金流向" {
  71. listHz[k].Annotation = listHz[k].Abstract
  72. }
  73. listHz[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  74. listHz[k].Body = ""
  75. }
  76. items = listHz
  77. return
  78. }
  79. func GetSearchResourceListHz(condition string, user *models.WxUserItem) (items []*models.IndustrialManagement, err error) {
  80. userId := user.UserId
  81. fllowList, err := models.GetUserFllowIndustrialList(userId)
  82. if err != nil {
  83. return
  84. }
  85. fllowMap := make(map[int]int)
  86. if len(fllowList) > 0 {
  87. for _, v := range fllowList {
  88. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  89. }
  90. }
  91. listHz, err := models.GetSearchResourceList(condition)
  92. if err != nil {
  93. return
  94. }
  95. listHz, err = HandleIndustryList(listHz, user, "")
  96. items = listHz
  97. return
  98. }