12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- package services
- import (
- "errors"
- "hongze/hongze_clpt/models"
- "hongze/hongze_clpt/utils"
- "strings"
- )
- // 处理研选关联的新标签
- func GetYanXuanIndustrialManagementIdNewMap(articleTypeIds string) (respMap map[int]bool, err error) {
- var condition string
- if articleTypeIds == "" {
- return
- }
- condition = ` AND a.article_type_id IN (` + articleTypeIds + `) `
- list, e := models.GetIndustrialManagementNewList(condition)
- if e != nil {
- err = errors.New("GetIndustrialManagementNewList, Err: " + e.Error())
- return
- }
- newMap := make(map[int]bool)
- for _, v := range list {
- newMap[v.IndustrialManagementId] = true
- }
- respMap = newMap
- return
- }
- // 处理研选关联的hot标签
- func GetYanXuanIndustrialManagementIdHotMap(articleTypeIds string) (respMap map[int]bool, err error) {
- var condition string
- var conditionOrder string
- if articleTypeIds == "" {
- return
- }
- condition = ` AND a.article_type_id IN (` + articleTypeIds + `) `
- conditionOrder = ` ORDER BY sum_num DESC `
- listHot, e := models.GetThemeHeatList(0, condition, conditionOrder, 0, 3)
- if e != nil {
- err = errors.New("GetIndustrialManagementNewList, Err: " + e.Error())
- return
- }
- hotMap := make(map[int]bool)
- for _, v := range listHot {
- hotMap[v.IndustrialManagementId] = true
- }
- respMap = hotMap
- return
- }
- // GetArticleSubjectName 获取文章关联的多个标的名称
- func GetArticleSubjectName(articleIds []int) (respMap, subjectMap map[int]string, err error) {
- lenarticleIds := len(articleIds)
- if lenarticleIds == 0 {
- return
- }
- var condition string
- var pars []interface{}
- condition = ` AND ag.article_id IN (` + utils.GetOrmInReplace(len(articleIds)) + `)`
- pars = append(pars, articleIds)
- list, e := models.GetSubjectArticlGroupList(condition, pars)
- if e != nil {
- err = errors.New("GetIndustrialManagementNewList, Err: " + e.Error())
- return
- }
- artMap := make(map[int]string)
- subMap := make(map[int]string)
- for _, v := range list {
- artMap[v.ArticleId] += v.SubjectName + "/"
- subMap[v.IndustrialSubjectId] = v.SubjectName
- }
- for _, v := range list {
- artMap[v.ArticleId] = strings.TrimRight(artMap[v.ArticleId], "/")
- }
- respMap = artMap
- subjectMap = subMap
- return
- }
|