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 }