123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- package services
- import (
- "hongze/hongze_clpt/models"
- "hongze/hongze_clpt/utils"
- "strconv"
- "strings"
- )
- func GetReoprtSearchListHz(condition string, userId, startSize, pageSize int) (items []*models.ArticleCollectionResp, err error) {
- listHz, err := models.GetReoprtSearchList(condition, userId, startSize, pageSize)
- if err != nil {
- return
- }
- for k, _ := range listHz {
- listHz[k].Source = 1
- }
- var articleIds string
- for _, v := range listHz {
- articleIds += strconv.Itoa(v.ArticleId) + ","
- }
- articleIds = strings.TrimRight(articleIds, ",")
- silcearticleIds := strings.Split(articleIds, ",")
- //获取文章关联的产业
- var pars []interface{}
- pars = make([]interface{}, 0)
- articleIdList := make([]string, 0)
- for _, v := range silcearticleIds {
- articleIdList = append(articleIdList, v)
- }
- condition = ` AND mg.article_id IN ( ` + utils.GetOrmInReplace(len(silcearticleIds)) + ` ) `
- pars = append(pars, articleIdList)
- industrialList, err := models.GetIndustrialListByarticleId(pars, condition)
- if err != nil {
- return
- }
- industrialMap := make(map[int][]*models.IndustrialManagementResp)
- if len(industrialList) > 0 {
- for _, v := range industrialList {
- item := new(models.IndustrialManagementResp)
- //item.ArticleId = v.ArticleId
- item.IndustrialManagementId = v.IndustrialManagementId
- item.IndustryName = v.IndustryName
- item.ChartPermissionId = v.ChartPermissionId
- industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
- }
- }
- detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
- if err != nil {
- return
- }
- categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
- mapCategoryUrl := make(map[string]string)
- var categoryId string
- var imgUrlChart string
- for _, v := range categoryUrlList {
- vslice := strings.Split(v, "_")
- categoryId = vslice[0]
- imgUrlChart = vslice[len(vslice)-1]
- mapCategoryUrl[categoryId] = imgUrlChart
- }
- for k, v := range listHz {
- if len(industrialMap[v.ArticleId]) > 0 {
- listHz[k].List = industrialMap[v.ArticleId]
- } else {
- listHz[k].List = make([]*models.IndustrialManagementResp, 0)
- }
- listHz[k].Body = ""
- listHz[k].Abstract, _ = GetReportContentTextSub(v.Abstract)
- listHz[k].Annotation, _ = GetReportContentTextSub(v.Annotation)
- //行业比较研究、资金流向,显示报告的摘要
- if listHz[k].CategoryName == "行业比较研究" || listHz[k].CategoryName == "资金流向" {
- listHz[k].Annotation = listHz[k].Abstract
- }
- listHz[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
- listHz[k].Body = ""
- }
- items = listHz
- return
- }
- func GetSearchResourceListHz(condition string, user *models.WxUserItem) (items []*models.IndustrialManagement, err error) {
- userId := user.UserId
- fllowList, err := models.GetUserFllowIndustrialList(userId)
- if err != nil {
- return
- }
- fllowMap := make(map[int]int)
- if len(fllowList) > 0 {
- for _, v := range fllowList {
- fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
- }
- }
- listHz, err := models.GetSearchResourceList(condition)
- if err != nil {
- return
- }
- listHz, err = HandleIndustryList(listHz, user, "")
- items = listHz
- return
- }
|