yan_xuan.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package services
  2. import (
  3. "errors"
  4. "hongze/hongze_clpt/models"
  5. "hongze/hongze_clpt/utils"
  6. "strings"
  7. )
  8. // 处理研选关联的新标签
  9. func GetYanXuanIndustrialManagementIdNewMap(articleTypeIds string) (respMap map[int]bool, err error) {
  10. var condition string
  11. if articleTypeIds == "" {
  12. return
  13. }
  14. condition = ` AND a.article_type_id IN (` + articleTypeIds + `) `
  15. list, e := models.GetIndustrialManagementNewList(condition)
  16. if e != nil {
  17. err = errors.New("GetIndustrialManagementNewList, Err: " + e.Error())
  18. return
  19. }
  20. newMap := make(map[int]bool)
  21. for _, v := range list {
  22. newMap[v.IndustrialManagementId] = true
  23. }
  24. respMap = newMap
  25. return
  26. }
  27. // 处理研选关联的hot标签
  28. func GetYanXuanIndustrialManagementIdHotMap(articleTypeIds string) (respMap map[int]bool, err error) {
  29. var condition string
  30. var conditionOrder string
  31. if articleTypeIds == "" {
  32. return
  33. }
  34. condition = ` AND a.article_type_id IN (` + articleTypeIds + `) `
  35. conditionOrder = ` ORDER BY sum_num DESC `
  36. listHot, e := models.GetThemeHeatList(0, condition, conditionOrder, 0, 3)
  37. if e != nil {
  38. err = errors.New("GetIndustrialManagementNewList, Err: " + e.Error())
  39. return
  40. }
  41. hotMap := make(map[int]bool)
  42. for _, v := range listHot {
  43. hotMap[v.IndustrialManagementId] = true
  44. }
  45. respMap = hotMap
  46. return
  47. }
  48. // GetArticleSubjectName 获取文章关联的多个标的名称
  49. func GetArticleSubjectName(articleIds []int) (respMap, subjectMap map[int]string, err error) {
  50. lenarticleIds := len(articleIds)
  51. if lenarticleIds == 0 {
  52. return
  53. }
  54. var condition string
  55. var pars []interface{}
  56. condition = ` AND ag.article_id IN (` + utils.GetOrmInReplace(len(articleIds)) + `)`
  57. pars = append(pars, articleIds)
  58. list, e := models.GetSubjectArticlGroupList(condition, pars)
  59. if e != nil {
  60. err = errors.New("GetIndustrialManagementNewList, Err: " + e.Error())
  61. return
  62. }
  63. artMap := make(map[int]string)
  64. subMap := make(map[int]string)
  65. for _, v := range list {
  66. artMap[v.ArticleId] += v.SubjectName + "/"
  67. subMap[v.IndustrialSubjectId] = v.SubjectName
  68. }
  69. for _, v := range list {
  70. artMap[v.ArticleId] = strings.TrimRight(artMap[v.ArticleId], "/")
  71. }
  72. respMap = artMap
  73. subjectMap = subMap
  74. return
  75. }