package services import ( "errors" "fmt" "hongze/hongze_cygx/models" "hongze/hongze_cygx/utils" ) // 文章关联产业标签处理List func GetArticleIndustrialLabelMapListByArticleids(articleIds []int) (mapResp map[int][]*models.IndustrialManagementIdInt) { var err error defer func() { if err != nil { fmt.Println(err) go utils.SendAlarmMsg(fmt.Sprint("文章关联产业标签处理,信息失败,GetArticleIndustrialLabelMapListByArticleids Err:"+err.Error(), articleIds), 3) } }() lenIds := len(articleIds) if lenIds == 0 { return } var condition string var pars []interface{} //获取文章关联的产业 pars = make([]interface{}, 0) condition = ` AND mg.article_id IN ( ` + utils.GetOrmInReplace(len(articleIds)) + ` ) ` pars = append(pars, articleIds) industrialList, e := models.GetIndustrialListByarticleId(pars, condition) if e != nil && e.Error() != utils.RunMode { err = errors.New("GetIndustrialListByarticleId, Err: " + e.Error()) return } mapResp = make(map[int][]*models.IndustrialManagementIdInt, 0) if len(industrialList) > 0 { for _, v := range industrialList { item := new(models.IndustrialManagementIdInt) item.ArticleId = v.ArticleId if v.ArticleId > utils.SummaryArticleId { item.IsResearch = true } item.IndustrialManagementId = v.IndustrialManagementId item.IndustryName = v.IndustryName mapResp[v.ArticleId] = append(mapResp[v.ArticleId], item) } } return }