article_industry_label.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package services
  2. import (
  3. "errors"
  4. "fmt"
  5. "hongze/hongze_cygx/models"
  6. "hongze/hongze_cygx/utils"
  7. )
  8. // 文章关联产业标签处理List
  9. func GetArticleIndustrialLabelMapListByArticleids(articleIds []int) (mapResp map[int][]*models.IndustrialManagementIdInt) {
  10. var err error
  11. defer func() {
  12. if err != nil {
  13. fmt.Println(err)
  14. go utils.SendAlarmMsg(fmt.Sprint("文章关联产业标签处理,信息失败,GetArticleIndustrialLabelMapListByArticleids Err:"+err.Error(), articleIds), 3)
  15. }
  16. }()
  17. lenIds := len(articleIds)
  18. if lenIds == 0 {
  19. return
  20. }
  21. var condition string
  22. var pars []interface{}
  23. //获取文章关联的产业
  24. pars = make([]interface{}, 0)
  25. condition = ` AND mg.article_id IN ( ` + utils.GetOrmInReplace(len(articleIds)) + ` ) `
  26. pars = append(pars, articleIds)
  27. industrialList, e := models.GetIndustrialListByarticleId(pars, condition)
  28. if e != nil && e.Error() != utils.RunMode {
  29. err = errors.New("GetIndustrialListByarticleId, Err: " + e.Error())
  30. return
  31. }
  32. mapResp = make(map[int][]*models.IndustrialManagementIdInt, 0)
  33. if len(industrialList) > 0 {
  34. for _, v := range industrialList {
  35. item := new(models.IndustrialManagementIdInt)
  36. item.ArticleId = v.ArticleId
  37. if v.ArticleId > utils.SummaryArticleId {
  38. item.IsResearch = true
  39. }
  40. item.IndustrialManagementId = v.IndustrialManagementId
  41. item.IndustryName = v.IndustryName
  42. mapResp[v.ArticleId] = append(mapResp[v.ArticleId], item)
  43. }
  44. }
  45. return
  46. }