yan_xuan.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package services
  2. import (
  3. "errors"
  4. "hongze/hongze_cygx/models"
  5. "strconv"
  6. "strings"
  7. )
  8. // 获取研选类型的文章分类Id
  9. func GetYanXuanArticleTypeIds() (articleTypeIds string, err error) {
  10. var condition string
  11. condition = " AND is_show_yanx = 1 "
  12. listType, e := models.GetCygxArticleTypeListCondition(condition)
  13. if e != nil {
  14. err = errors.New("GetCygxArticleTypeListCondition, Err: " + e.Error())
  15. return
  16. }
  17. for _, v := range listType {
  18. articleTypeIds += strconv.Itoa(v.ArticleTypeId) + ","
  19. }
  20. articleTypeIds = strings.TrimRight(articleTypeIds, ",")
  21. if articleTypeIds == "" {
  22. err = errors.New("研选分类ID不能为空")
  23. return
  24. }
  25. return
  26. }
  27. // 处理研选关联的新标签
  28. func GetYanXuanIndustrialManagementIdNewMap(articleTypeIds string) (respMa map[int]bool, err error) {
  29. var condition string
  30. if articleTypeIds == "" {
  31. return
  32. }
  33. condition = ` AND a.article_type_id IN (` + articleTypeIds + `) `
  34. list, e := models.GetIndustrialManagementNewList(condition)
  35. if e != nil {
  36. err = errors.New("GetIndustrialManagementNewList, Err: " + e.Error())
  37. return
  38. }
  39. newMap := make(map[int]bool)
  40. for _, v := range list {
  41. newMap[v.IndustrialManagementId] = true
  42. }
  43. return
  44. }
  45. // 处理研选关联的hot标签
  46. func GetYanXuanIndustrialManagementIdHotMap(articleTypeIds string) (respMa map[int]bool, err error) {
  47. var condition string
  48. var conditionOrder string
  49. if articleTypeIds == "" {
  50. return
  51. }
  52. condition = ` AND a.article_type_id IN (` + articleTypeIds + `) `
  53. conditionOrder = ` ORDER BY sum_num DESC `
  54. listHot, e := models.GetThemeHeatList(0, condition, conditionOrder, 0, 3)
  55. if e != nil {
  56. err = errors.New("GetIndustrialManagementNewList, Err: " + e.Error())
  57. return
  58. }
  59. newHot := make(map[int]bool)
  60. for _, v := range listHot {
  61. newHot[v.IndustrialManagementId] = true
  62. }
  63. return
  64. }