123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package services
- import (
- "errors"
- "hongze/hongze_web_mfyx/models"
- "hongze/hongze_web_mfyx/utils"
- )
- // GetArticleGroupSubjectMap 获取文章所关联的标的
- func GetArticleGroupSubjectMap(articleIds []int) (mapResp map[int][]*models.IndustrialSubject, subjectMap map[int]string, err error) {
- lenArticleIds := len(articleIds)
- if lenArticleIds == 0 {
- return
- }
- var condition string
- var pars []interface{}
- condition = ` AND g.article_id IN (` + utils.GetOrmInReplace(len(articleIds)) + `)`
- pars = append(pars, articleIds)
- list, e := models.GetArticleGroupSubjectList(pars, condition)
- if e != nil {
- err = errors.New("GetArticleGroupSubjectList " + e.Error())
- return
- }
- listMap := make(map[int][]*models.IndustrialSubject)
- subMap := make(map[int]string)
- mapName := make(map[int]int)
- if len(list) > 0 {
- for _, v := range list {
- item := models.IndustrialSubject{
- IndustrialSubjectId: v.IndustrialSubjectId,
- IndustrialManagementId: v.IndustrialManagementId,
- SubjectName: v.SubjectName,
- }
- listMap[v.ArticleId] = append(listMap[v.ArticleId], &item)
- subMap[v.IndustrialSubjectId] = v.SubjectName
- mapName[v.IndustrialSubjectId] = v.IndustrialManagementId
- }
- }
- mapResp = listMap
- subjectMap = subMap
- return
- }
|