12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199 |
- package services
- import (
- "context"
- "encoding/json"
- "fmt"
- "hongze/hongze_clpt/models"
- "hongze/hongze_clpt/utils"
- "strconv"
- //"strconv"
- "errors"
- "strings"
- "time"
- )
- type SearchComprehensiveItem struct {
- SourceId int `description:"资源ID"`
- IsSummary int `description:"是否是纪要"`
- Source string `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial 、 本周研究汇总: researchsummary 、 上周纪要汇总 :minutessummary 、晨会精华 :meetingreviewchapt 、 产品内测:productinterior"`
- Title string `description:"标题"`
- BodyText string `description:"内容"`
- PublishDate string `description:"发布时间"`
- Abstract string `description:"摘要"`
- Annotation string `description:"核心观点"`
- IndustryName string `description:"产业名称"`
- SubjectNames string `description:"标的名称"`
- Body []string
- }
- type ElasticComprehensiveDetail struct {
- SourceId int `description:"资源ID"`
- IsSummary int `description:"是否是纪要"`
- Source string `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial 、 本周研究汇总: researchsummary 、 上周纪要汇总 :minutessummary 、晨会精华 :meetingreviewchapt 、 产品内测:productinterior 、 产业资源包:industrialsource"`
- Title string `description:"标题"`
- BodyText string `description:"内容"`
- PublishDate string `description:"发布时间"`
- Abstract string `description:"摘要"`
- Annotation string `description:"核心观点"`
- IndustryName string `description:"产业名称"`
- SubjectNames string `description:"标的名称"`
- }
- func EsComprehensiveSearch(keyWord string, startSize, pageSize int) (result []*SearchComprehensiveItem, total int64, err error) {
- indexName := utils.IndexNameComprehensive
- client := utils.Client
- keyWordArr, err := GetIndustryMapNameSliceV3(keyWord)
- keyWordArr = RemoveDuplicatesAndEmpty(keyWordArr)
- keyWordLen := len(keyWordArr)
- if keyWordLen <= 0 {
- keyWordArr = append(keyWordArr, keyWord)
- keyWordLen = len(keyWordArr)
- }
- fmt.Println(keyWordArr)
- //Es 的高级查询有 自定义排序 文档一时半会儿撸不懂,先做多次查询手动过滤 2023.2.2
- //ikType 查询方式 ,0:查所有 、 1:查询键入词 、 2:查询除了查询键入词之外的联想词
- mustMap := make([]interface{}, 0)
- shouldMap := make(map[string]interface{}, 0)
- shouldMapquery := make([]interface{}, 0)
- mustNotMap := make([]interface{}, 0)
- shouldNotMap := make(map[string]interface{}, 0)
- shouldNotMapquery := make([]interface{}, 0)
- // @Param OrderColumn query int true "排序字段 ,Comprehensive综合 ,Matching匹配度 ,PublishDate 发布时间 "
- //keyWordWeight := GetWeight(keyWordLen)
- var boost int
- //lenkeyWordArr := len(keyWordArr)
- for k, v := range keyWordArr {
- if k > 0 {
- continue
- }
- if k == 0 {
- boost = 2 * 1000
- } else {
- boost = 1
- }
- if v != "" {
- shouldMapquery = append(shouldMapquery, map[string]interface{}{
- "function_score": map[string]interface{}{
- "query": map[string]interface{}{
- "multi_match": map[string]interface{}{
- //"boost": (lenkeyWordArr - k) * boost, //给查询的值赋予权重
- "boost": boost, //给查询的值赋予权重
- "fields": []interface{}{"Title"},
- "query": v,
- },
- },
- },
- })
- shouldMapquery = append(shouldMapquery, map[string]interface{}{
- "function_score": map[string]interface{}{
- "query": map[string]interface{}{
- "multi_match": map[string]interface{}{
- "boost": boost, //给查询的值赋予权重
- "fields": []interface{}{"Abstract"},
- "query": v,
- },
- },
- },
- })
- shouldMapquery = append(shouldMapquery, map[string]interface{}{
- "function_score": map[string]interface{}{
- "query": map[string]interface{}{
- "multi_match": map[string]interface{}{
- "boost": boost, //给查询的值赋予权重
- "fields": []interface{}{"Annotation"},
- "query": v,
- },
- },
- },
- })
- shouldMapquery = append(shouldMapquery, map[string]interface{}{
- "function_score": map[string]interface{}{
- "query": map[string]interface{}{
- "multi_match": map[string]interface{}{
- //"boost": (lenkeyWordArr-k)*boost - 1, //给查询的值赋予权重
- "boost": boost, //给查询的值赋予权重
- "fields": []interface{}{"BodyText"},
- "query": v,
- },
- },
- },
- })
- shouldMapquery = append(shouldMapquery, map[string]interface{}{
- "function_score": map[string]interface{}{
- "query": map[string]interface{}{
- "multi_match": map[string]interface{}{
- //"boost": (lenkeyWordArr-k)*boost - 1, //给查询的值赋予权重
- "boost": boost, //给查询的值赋予权重
- "fields": []interface{}{"IndustryName"},
- "query": v,
- },
- },
- },
- })
- shouldMapquery = append(shouldMapquery, map[string]interface{}{
- "function_score": map[string]interface{}{
- "query": map[string]interface{}{
- "multi_match": map[string]interface{}{
- //"boost": (lenkeyWordArr-k)*boost - 1, //给查询的值赋予权重
- "boost": boost, //给查询的值赋予权重
- "fields": []interface{}{"SubjectNames"},
- "query": v,
- },
- },
- },
- })
- }
- }
- shouldMap = map[string]interface{}{
- "should": shouldMapquery,
- }
- shouldNotMap = map[string]interface{}{
- "should": shouldNotMapquery,
- }
- //排序
- sortMap := make([]interface{}, 0)
- //时间
- sortMap = append(sortMap, map[string]interface{}{
- "PublishDate": map[string]interface{}{
- "order": "desc",
- },
- })
- //sortMap = append(sortMap, map[string]interface{}{
- // "_score": map[string]interface{}{
- // "order": "desc",
- // },
- //})
- //高亮
- highlightMap := make(map[string]interface{}, 0)
- highlightMap = map[string]interface{}{
- "fields": map[string]interface{}{
- "BodyText": map[string]interface{}{},
- "Title": map[string]interface{}{},
- "Abstract": map[string]interface{}{},
- "Annotation": map[string]interface{}{},
- },
- //样式 红色
- "post_tags": []interface{}{"</font>"},
- "pre_tags": []interface{}{"<font color='red'>"},
- "fragment_size": 50,
- }
- mustMap = append(mustMap, map[string]interface{}{
- "bool": shouldMap,
- })
- mustNotMap = append(mustNotMap, map[string]interface{}{
- "bool": shouldNotMap,
- })
- queryMap := map[string]interface{}{
- "query": map[string]interface{}{
- "bool": map[string]interface{}{
- "must": mustMap,
- },
- },
- }
- queryMap["sort"] = sortMap
- queryMap["from"] = startSize
- queryMap["size"] = pageSize
- queryMap["highlight"] = highlightMap
- jsonBytes, _ := json.Marshal(queryMap)
- fmt.Println(string(jsonBytes))
- //utils.FileLog.Info(string(jsonBytes))
- request := client.Search(indexName).Source(queryMap) // sets the JSON request
- searchByMatch, err := request.Do(context.Background())
- if searchByMatch != nil {
- if searchByMatch.Hits != nil {
- for _, v := range searchByMatch.Hits.Hits {
- var isAppend bool
- articleJson, err := v.Source.MarshalJSON()
- if err != nil {
- return nil, 0, err
- }
- article := new(ElasticComprehensiveDetail)
- err = json.Unmarshal(articleJson, &article)
- if err != nil {
- return nil, 0, err
- }
- fmt.Println(article.SourceId, article.Title, article.Source)
- searchItem := new(SearchComprehensiveItem)
- searchItem.SourceId = article.SourceId
- if len(v.Highlight["Annotation"]) > 0 {
- for _, vText := range v.Highlight["Annotation"] {
- searchItem.Body = append(searchItem.Body, vText)
- }
- }
- if len(v.Highlight["Abstract"]) > 0 {
- for _, vText := range v.Highlight["Abstract"] {
- searchItem.Body = append(searchItem.Body, vText)
- }
- }
- if len(v.Highlight["BodyText"]) > 0 {
- for _, vText := range v.Highlight["BodyText"] {
- searchItem.Body = append(searchItem.Body, vText)
- }
- }
- searchItem.IsSummary = article.IsSummary
- if len(searchItem.Body) == 0 {
- bodyRune := []rune(article.BodyText)
- bodyRuneLen := len(bodyRune)
- if bodyRuneLen > 100 {
- bodyRuneLen = 100
- }
- body := string(bodyRune[:bodyRuneLen])
- searchItem.Body = []string{body}
- }
- var title string
- if len(v.Highlight["Title"]) > 0 {
- title = v.Highlight["Title"][0]
- } else {
- title = article.Title
- }
- searchItem.Title = title
- searchItem.Source = article.Source
- searchItem.PublishDate = article.PublishDate
- if !isAppend {
- result = append(result, searchItem)
- }
- }
- }
- total = searchByMatch.Hits.TotalHits.Value
- }
- return
- }
- //func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserItem) (items []*models.HomeResourceDataListNewResp, err error) {
- // var condition string
- // var pars []interface{}
- // uid := user.UserId
- //
- // mapItems := make(map[string]*models.CygxResourceDataNewResp)
- // for _, v := range list {
- // //预处理文章
- // item := new(models.CygxResourceDataNewResp)
- // item.SourceId = v.SourceId
- // item.Source = v.Source
- // if v.IsSummary == 1 {
- // item.BodyHeight = v.Body
- // } else {
- // item.BodyHeight = make([]string, 0)
- // }
- // item.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
- // mapItems[fmt.Sprint(v.Source, v.SourceId)] = item
- // }
- //
- // var articleIds []int
- // var newchartIds []int
- // var roadshowIds []string
- // var activityIds []int
- // var activityvideoIds []string
- // var activityvoiceIds []string
- // var activityspecialIds []int
- // var researchsummaryIds []int
- // var minutessummaryIds []int
- // var meetingreviewchaptIds []int
- // var productinteriorIds []int
- // var industrialResourceIds []int
- // //Source string `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial 、 本周研究汇总: researchsummary 、 上周纪要汇总 :minutessummary 、晨会精华 :meetingreviewchapt "`
- // for _, v := range list {
- // if v.Source == "article" {
- // articleIds = append(articleIds, v.SourceId)
- // } else if v.Source == "newchart" {
- // newchartIds = append(newchartIds, v.SourceId)
- // } else if v.Source == "roadshow" {
- // roadshowIds = append(roadshowIds, strconv.Itoa(v.SourceId))
- // } else if v.Source == "activity" {
- // activityIds = append(activityIds, v.SourceId)
- // } else if v.Source == "activityvideo" {
- // activityvideoIds = append(activityvideoIds, strconv.Itoa(v.SourceId))
- // } else if v.Source == "activityvoice" {
- // activityvoiceIds = append(activityvoiceIds, strconv.Itoa(v.SourceId))
- // } else if v.Source == "activityspecial" {
- // activityspecialIds = append(activityspecialIds, v.SourceId)
- // } else if v.Source == "researchsummary" {
- // researchsummaryIds = append(researchsummaryIds, v.SourceId)
- // } else if v.Source == "minutessummary" {
- // minutessummaryIds = append(minutessummaryIds, v.SourceId)
- // } else if v.Source == "meetingreviewchapt" {
- // meetingreviewchaptIds = append(meetingreviewchaptIds, v.SourceId)
- // } else if v.Source == "productinterior" {
- // productinteriorIds = append(productinteriorIds, v.SourceId)
- // } else if v.Source == "industrialsource" {
- // industrialResourceIds = append(industrialResourceIds, v.SourceId)
- // }
- //
- // }
- // //处理文章
- // if len(articleIds) > 0 {
- // pars = make([]interface{}, 0)
- // condition = ` AND a.article_id IN (` + utils.GetOrmInReplace(len(articleIds)) + `)`
- // pars = append(pars, articleIds)
- //
- // listArticle, e := models.GetHomeList(condition, pars, 0, len(articleIds))
- // if e != nil {
- // err = errors.New("GetResourceDataList, Err: " + e.Error())
- // return
- // }
- //
- // listArticle, e = HandleArticleCategoryImg(listArticle)
- // if e != nil {
- // err = errors.New("HandleArticleCategoryImg, Err: " + e.Error())
- // return
- // }
- // for _, v := range listArticle {
- // v.Body = ""
- // v.BodyHtml = ""
- // mapItems[fmt.Sprint("article", v.ArticleId)].Article = v
- // }
- // }
- //
- // //处理晨会精华
- // if len(meetingreviewchaptIds) > 0 {
- // pars = make([]interface{}, 0)
- // condition = ` AND c.id IN (` + utils.GetOrmInReplace(len(meetingreviewchaptIds)) + `)`
- // pars = append(pars, meetingreviewchaptIds)
- //
- // listrMeet, e := models.GetCygxMorningMeetingReviewChapterList(condition, pars)
- // if e != nil {
- // err = errors.New("GetResourceDataList, Err: " + e.Error())
- // return
- // }
- // for _, v := range listrMeet {
- // v.Content = AnnotationHtml(v.Content)
- // v.PublishTime = utils.TimeRemoveHms2(v.PublishTime)
- // mapItems[fmt.Sprint("meetingreviewchapt", v.Id)].Meetingreviewchapt = v
- // }
- // }
- //
- // //处理上周纪要汇总
- // if len(minutessummaryIds) > 0 {
- // pars = make([]interface{}, 0)
- // condition = ` AND article_id IN (` + utils.GetOrmInReplace(len(minutessummaryIds)) + `)`
- // pars = append(pars, minutessummaryIds)
- //
- // listresearchsummary, e := models.GetReportSelectionListHome(condition, "cygx_minutes_summary", pars, 0, len(minutessummaryIds))
- // if e != nil {
- // err = errors.New("GetResourceDataList, Err: " + e.Error())
- // return
- // }
- // for _, v := range listresearchsummary {
- // v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
- // mapItems[fmt.Sprint("minutessummary", v.ArticleId)].Minutessummary = v
- // }
- // }
- //
- // //处理本周纪要汇总
- // if len(researchsummaryIds) > 0 {
- // pars = make([]interface{}, 0)
- // condition = ` AND article_id IN (` + utils.GetOrmInReplace(len(researchsummaryIds)) + `)`
- // pars = append(pars, researchsummaryIds)
- //
- // listresearchsummary, e := models.GetReportSelectionListHome(condition, "cygx_research_summary", pars, 0, len(researchsummaryIds))
- // if e != nil {
- // err = errors.New("GetReportSelectionListHome, Err: " + e.Error())
- // return
- // }
- // for _, v := range listresearchsummary {
- // v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
- // mapItems[fmt.Sprint("researchsummary", v.ArticleId)].Researchsummary = v
- // }
- // }
- //
- // //处理产品内测
- // if len(productinteriorIds) > 0 {
- // pars = make([]interface{}, 0)
- // condition = ` AND art.status = 1 AND art.product_interior_id IN (` + utils.GetOrmInReplace(len(productinteriorIds)) + `)`
- // pars = append(pars, productinteriorIds)
- // listProductInterior, e := models.GetCygxProductInteriorList(condition, pars, 0, len(productinteriorIds))
- // if e != nil {
- // err = errors.New("GetCygxProductInteriorList, Err: " + e.Error())
- // return
- // }
- // for _, v := range listProductInterior {
- // v.Body = ProductInteriorHtml(v.Body)
- // v.PublishTime = utils.TimeRemoveHms2(v.PublishTime)
- // mapItems[fmt.Sprint("productinterior", v.ProductInteriorId)].ProductInterior = v
- // }
- // }
- //
- // detail, e := models.GetConfigByCode("city_img_url")
- // if e != nil {
- // err = errors.New("GetResourceDataList, Err: " + e.Error())
- // return
- // }
- // detailChart, e := models.GetConfigByCode("chart_img_url")
- // if e != nil {
- // err = errors.New("GetResourceDataList, Err: " + e.Error())
- // return
- // }
- // addressList := strings.Split(detail.ConfigValue, "{|}")
- // mapAddress := make(map[string]string)
- // chartList := strings.Split(detailChart.ConfigValue, "{|}")
- // mapChart := make(map[string]string)
- // var cityName string
- // var chartName string
- // var imgUrl string
- // var imgUrlChart string
- // for _, v := range addressList {
- // vslice := strings.Split(v, "_")
- // cityName = vslice[0]
- // imgUrl = vslice[len(vslice)-1]
- // mapAddress[cityName] = imgUrl
- // }
- // for _, v := range chartList {
- // vslice := strings.Split(v, "_")
- // chartName = vslice[0]
- // imgUrlChart = vslice[len(vslice)-1]
- // mapChart[chartName] = imgUrlChart
- // }
- // var imgUrlResp string
- // fmt.Println(activityIds)
- // //处理活动
- // if len(activityIds) > 0 {
- // for _, vss := range activityIds {
- // imgUrlResp += strconv.Itoa(vss) + ","
- // }
- // pars = make([]interface{}, 0)
- // condition = ` AND art.activity_id IN (` + utils.GetOrmInReplace(len(activityIds)) + `)`
- // pars = append(pars, activityIds)
- // activityList, e := models.GetActivityListNew(condition, pars, uid, 0, len(activityIds), 0, 0, "")
- // if e != nil {
- // err = errors.New("GetResourceDataList, Err: " + e.Error())
- // return
- // }
- // //处理不同的报名方式按钮回显
- // mapActivitySignup, e := GetActivitySignupResp(activityIds, user)
- // if e != nil {
- // e = errors.New("GetActivitySignupResp, Err: " + e.Error())
- // return
- // }
- //
- // var activityListRersp []*models.ActivityDetail
- // for _, v := range activityList {
- // v.SignupType = mapActivitySignup[v.ActivityId]
- // activityListRersp = append(activityListRersp, ActivityButtonShow(v))
- // }
- // for _, v := range activityListRersp {
- // if v == nil {
- // continue
- // }
- // if v.ActivityType == 0 {
- // if mapAddress[v.City] != "" {
- // imgUrlResp = mapAddress[v.City]
- // } else {
- // imgUrlResp = mapAddress["其它"]
- // }
- // } else {
- // if mapChart[v.ChartPermissionName] != "" {
- // imgUrlResp = mapChart[v.ChartPermissionName]
- // }
- // }
- // v.SourceType = 1
- // v.Expert, _ = GetReportContentTextSub(v.Expert)
- // mapItems[fmt.Sprint("activity", v.ActivityId)].Activity = v
- // }
- // }
- //
- // //产业资源包
- // if len(industrialResourceIds) > 0 {
- // pars = make([]interface{}, 0)
- //
- // var industrialResourceIdstring []string
- // for _, v := range industrialResourceIds {
- // industrialResourceIdstring = append(industrialResourceIdstring, strconv.Itoa(v))
- // }
- // industrialId := strings.Join(industrialResourceIdstring, ",")
- // condition = ` AND m.industrial_management_id IN (` + industrialId + `) `
- // listIndustrialResourceIds, e := models.GetSearchResourceList(user.UserId, condition, 0, len(industrialResourceIds))
- // if e != nil {
- // err = errors.New("GetSearchResourceList, Err: " + e.Error())
- // return
- // }
- // //合并产业关联的标的
- // listSubjcet, e := models.GetIndustrialSubjectAllByIndustrialId(industrialResourceIds)
- // if e != nil {
- // e = errors.New("GetIndustrialSubjectAllByIndustrialId, Err: " + e.Error())
- // return
- // }
- // mapIndustrial := make(map[string]int)
- // for _, v := range listSubjcet {
- // for k2, v2 := range listIndustrialResourceIds {
- // if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 {
- // listIndustrialResourceIds[k2].IndustrialSubjectList = append(listIndustrialResourceIds[k2].IndustrialSubjectList, v)
- // }
- // }
- // }
- // for _, v := range listIndustrialResourceIds {
- // mapItems[fmt.Sprint("industrialsource", v.IndustrialManagementId)].IndustrialResource = v
- // }
- // }
- //
- // //处理图表
- // if len(newchartIds) > 0 {
- // pars = make([]interface{}, 0)
- // condition = ` AND a.chart_id IN (` + utils.GetOrmInReplace(len(newchartIds)) + `)`
- // pars = append(pars, newchartIds)
- // chartDateList, e := models.GetChartListCollectionNew(condition, pars, uid, 0, len(newchartIds))
- // if e != nil {
- // err = errors.New("GetResourceDataList, Err: " + e.Error())
- // return
- // }
- // for _, v := range chartDateList {
- // mapItems[fmt.Sprint("newchart", v.ChartId)].Newchart = v
- // }
- // }
- //
- // //处理专项调研
- // if len(activityspecialIds) > 0 {
- // pars = make([]interface{}, 0)
- // condition = ` AND art.activity_id IN (` + utils.GetOrmInReplace(len(activityspecialIds)) + `)`
- // pars = append(pars, activityspecialIds)
- // activitySpeciallist, e := models.GetCygxActivitySpecialDetailList(condition, pars, user.UserId, 0, len(activityspecialIds))
- // if e != nil {
- // err = errors.New("GetCygxActivitySpecialDetailList, Err: " + e.Error())
- // return
- // }
- // UserMap, e := GetSpecialTripUserMap(activityIds, user.UserId)
- // if e != nil {
- // err = errors.New("GetSpecialTripUserMap, Err: " + e.Error())
- // return
- // }
- // for _, v := range activitySpeciallist {
- // if mapChart[v.ChartPermissionName] != "" {
- // imgUrlResp = mapChart[v.ChartPermissionName]
- // }
- // if _, ok := UserMap[v.ActivityId]; ok {
- // v.IsTrip = 1
- // }
- // if v.Days == 0 {
- // v.TripStatus = 1
- // v.TripImgLink = v.TripImgLink
- // } else {
- // v.TripStatus = 2
- // v.TripImgLink = v.TripImgLinkFix
- // v.ActivityTimeText = v.ActivityTimeTextByDay
- // }
- // resultTimeStart := utils.StrTimeToTime(v.ActivityTime) //时间字符串格式转时间格式
- // resultTimeEnd := utils.StrTimeToTime(v.ActivityTimeEnd) //时间字符串格式转时间格式
- // if resultTimeStart.After(time.Now()) {
- // v.ActiveState = 1
- // } else if time.Now().After(resultTimeEnd) {
- // v.ActiveState = 3
- // } else {
- // v.ActiveState = 2
- // }
- // v.ImgUrl = imgUrlResp
- // mapItems[fmt.Sprint("activityspecial", v.ActivityId)].Activityspecial = v
- //
- // }
- // }
- //
- // if len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds) > 0 {
- //
- // audioIdstr := strings.Join(activityvoiceIds, ",")
- // ideoIdsStr := strings.Join(roadshowIds, ",")
- // activityVideoIdsStr := strings.Join(activityvideoIds, ",")
- //
- // list, _, e := GetMicroRoadShowMycollect(len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds), 0, audioIdstr, ideoIdsStr, activityVideoIdsStr)
- // if e != nil {
- // err = errors.New("GetMicroRoadShowMycollect, Err: " + e.Error())
- // return
- // }
- //
- // for _, item := range list {
- // if item.Type == 1 {
- // //音频
- // count, e := models.GetVoiceCollectCount(user.UserId, item.Id)
- // if e != nil {
- // err = errors.New("GetVoiceCollectCount, Err: " + e.Error())
- // return
- // }
- // if count > 0 {
- // item.IsCollect = true
- // }
- // } else if item.Type == 2 {
- // //活动视频
- // count, e := models.GetActivityVideoCollectCount(user.UserId, item.Id)
- // if e != nil {
- // err = errors.New("GetActivityVideoCollectCount, Err: " + e.Error())
- // return
- // }
- // if count > 0 {
- // item.IsCollect = true
- // }
- // } else if item.Type == 3 {
- // //微路演视频
- // count, e := models.GetVideoCollectCount(user.UserId, item.Id)
- // if e != nil {
- // err = errors.New("GetVideoCollectCount, Err: " + e.Error())
- // return
- // }
- // if count > 0 {
- // item.IsCollect = true
- // }
- // }
- // }
- // // 用户权限
- // authInfo, permissionArr, e := GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
- // if e != nil {
- // err = errors.New("GetUserRaiPermissionInfo, Err: " + e.Error())
- // return
- // }
- //
- // // 获取默认图配置
- // audioMap, videoMap, audioShareMap, videoShareMap, e := GetMicroRoadShowDefaultImgConfig()
- // if e != nil {
- // err = errors.New("GetMicroRoadShowDefaultImgConfig, Err: " + e.Error())
- // return
- // }
- // //Source string `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
- // for i := range list {
- // // 权限
- // au := new(models.UserPermissionAuthInfo)
- // au.SellerName = authInfo.SellerName
- // au.SellerMobile = authInfo.SellerMobile
- // au.HasPermission = authInfo.HasPermission
- // au.OperationMode = authInfo.OperationMode
- // if au.HasPermission == 1 {
- // // 非宏观权限进一步判断是否有权限
- // if list[i].ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, list[i].ChartPermissionName) {
- // au.HasPermission = 2
- // }
- // }
- // // 无权限的弹框提示
- // if au.HasPermission != 1 {
- // if au.OperationMode == UserPermissionOperationModeCall {
- // if list[i].Type == 1 {
- // au.PopupMsg = UserPermissionPopupMsgCallActivity
- // } else {
- // au.PopupMsg = UserPermissionPopupMsgCallMicroVideo
- // }
- // } else {
- // if list[i].Type == 1 {
- // au.PopupMsg = UserPermissionPopupMsgApplyActivity
- // } else {
- // au.PopupMsg = UserPermissionPopupMsgApplyMicroVideo
- // }
- // }
- // }
- // list[i].AuthInfo = au
- // list[i].PublishTime = utils.StrTimeToTime(list[i].PublishTime).Format(utils.FormatDate)
- // // 默认图
- // if list[i].BackgroundImg == "" {
- // if list[i].Type == 1 {
- // list[i].BackgroundImg = audioMap[list[i].ChartPermissionId]
- // } else {
- // list[i].BackgroundImg = videoMap[list[i].ChartPermissionId]
- // }
- // }
- // // 分享图
- // if list[i].ShareImg == "" {
- // if list[i].Type == 1 {
- // list[i].ShareImg = audioShareMap[list[i].ChartPermissionId]
- // } else {
- // list[i].ShareImg = videoShareMap[list[i].ChartPermissionId]
- // }
- // }
- // }
- // //Type int `description:"类型: 1-音频; 2-活动视频; 3-产业视频"`
- // for _, item := range list {
- // if item.Type == 1 {
- // mapItems[fmt.Sprint("activityvoice", item.Id)].Activityvoice = item
- // } else if item.Type == 2 {
- // mapItems[fmt.Sprint("activityvideo", item.Id)].Activityvideo = item
- // } else if item.Type == 3 {
- // mapItems[fmt.Sprint("roadshow", item.Id)].Roadshow = item
- // }
- // }
- // }
- //
- // for _, vList := range list {
- // for _, v := range mapItems {
- // if v.SourceId == vList.SourceId {
- // items = append(items, v)
- // }
- // }
- // }
- // return
- //}
- func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserItem) (items []*models.CygxResourceDataNewResp, err error) {
- var condition string
- var pars []interface{}
- uid := user.UserId
- titleHighlight := make(map[int]string)
- bodyHighlight := make(map[int][]string)
- mapItems := make(map[string]*models.CygxResourceDataNewResp)
- for _, v := range list {
- //预处理文章
- item := new(models.CygxResourceDataNewResp)
- item.SourceId = v.SourceId
- item.Source = v.Source
- item.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
- if v.IsSummary == 1 {
- item.BodyHighlight = v.Body
- titleHighlight[v.SourceId] = v.Title
- bodyHighlight[v.SourceId] = v.Body
- //fmt.Println(v.Title)
- } else {
- item.BodyHighlight = make([]string, 0)
- }
- mapItems[fmt.Sprint(v.Source, v.SourceId)] = item
- }
- var articleIds []int //报告
- var newchartIds []int //图表
- var roadshowIds []string //微路演
- var activityIds []int //活动
- var activityvideoIds []string // 活动视频
- var activityvoiceIds []string //活动音频
- var activityspecialIds []int //专项调研活动
- var researchsummaryIds []int //本周研究汇总
- var minutessummaryIds []int //上周纪要汇总
- var meetingreviewchaptIds []int //晨会精华
- var productinteriorIds []int //产品内测
- var industrialResourceIds []int // 产业资源包
- //Source string `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial 、 本周研究汇总: researchsummary 、 上周纪要汇总 :minutessummary 、晨会精华 :meetingreviewchapt 、 产品内测:productinterior
- for _, v := range list {
- if v.Source == "article" {
- articleIds = append(articleIds, v.SourceId)
- } else if v.Source == "newchart" {
- newchartIds = append(newchartIds, v.SourceId)
- } else if v.Source == "roadshow" {
- roadshowIds = append(roadshowIds, strconv.Itoa(v.SourceId))
- } else if v.Source == "activity" {
- activityIds = append(activityIds, v.SourceId)
- } else if v.Source == "activityvideo" {
- activityvideoIds = append(activityvideoIds, strconv.Itoa(v.SourceId))
- } else if v.Source == "activityvoice" {
- activityvoiceIds = append(activityvoiceIds, strconv.Itoa(v.SourceId))
- } else if v.Source == "activityspecial" {
- activityspecialIds = append(activityspecialIds, v.SourceId)
- } else if v.Source == "researchsummary" {
- researchsummaryIds = append(researchsummaryIds, v.SourceId)
- } else if v.Source == "minutessummary" {
- minutessummaryIds = append(minutessummaryIds, v.SourceId)
- } else if v.Source == "meetingreviewchapt" {
- meetingreviewchaptIds = append(meetingreviewchaptIds, v.SourceId)
- } else if v.Source == "productinterior" {
- productinteriorIds = append(productinteriorIds, v.SourceId)
- } else if v.Source == "industrialsource" {
- industrialResourceIds = append(industrialResourceIds, v.SourceId)
- }
- }
- detail, e := models.GetConfigByCode("city_img_url")
- if e != nil {
- err = errors.New("GetResourceDataList, Err: " + e.Error())
- return
- }
- detailChart, e := models.GetConfigByCode("chart_img_url")
- if e != nil {
- err = errors.New("GetResourceDataList, Err: " + e.Error())
- return
- }
- addressList := strings.Split(detail.ConfigValue, "{|}")
- mapAddress := make(map[string]string)
- chartList := strings.Split(detailChart.ConfigValue, "{|}")
- mapChart := make(map[string]string)
- var cityName string
- var chartName string
- var imgUrl string
- var imgUrlChart string
- for _, v := range addressList {
- vslice := strings.Split(v, "_")
- cityName = vslice[0]
- imgUrl = vslice[len(vslice)-1]
- mapAddress[cityName] = imgUrl
- }
- for _, v := range chartList {
- vslice := strings.Split(v, "_")
- chartName = vslice[0]
- imgUrlChart = vslice[len(vslice)-1]
- mapChart[chartName] = imgUrlChart
- }
- var imgUrlResp string
- //处理文章
- if len(articleIds) > 0 {
- pars = make([]interface{}, 0)
- condition = ` AND a.article_id IN (` + utils.GetOrmInReplace(len(articleIds)) + `)`
- pars = append(pars, articleIds)
- articleList, e := models.GetHomeListPublic(condition, pars, 0, len(articleIds))
- if e != nil {
- err = errors.New("GetResourceDataList, Err: " + e.Error())
- return
- }
- articleList, e = HandleArticleCategoryImg(articleList, user)
- if e != nil {
- err = errors.New("HandleArticleCategoryImg, Err: " + e.Error())
- return
- }
- for _, v := range articleList {
- v.Body = ""
- if titleHighlight[v.ArticleId] != "" {
- v.Title = titleHighlight[v.ArticleId]
- }
- if len(bodyHighlight[v.ArticleId]) > 0 {
- v.Abstract = ""
- v.Annotation = ""
- v.BodyHighlight = bodyHighlight[v.ArticleId]
- } else {
- v.BodyHighlight = make([]string, 0)
- }
- mapItems[fmt.Sprint("article", v.ArticleId)].Article = v
- }
- }
- //处理晨会精华
- if len(meetingreviewchaptIds) > 0 {
- pars = make([]interface{}, 0)
- condition = ` AND c.id IN (` + utils.GetOrmInReplace(len(meetingreviewchaptIds)) + `)`
- pars = append(pars, meetingreviewchaptIds)
- listrMeet, e := models.GetCygxMorningMeetingReviewChapterList(condition, pars)
- if e != nil {
- err = errors.New("GetResourceDataList, Err: " + e.Error())
- return
- }
- for _, v := range listrMeet {
- v.Content = AnnotationHtml(v.Content)
- v.PublishTime = utils.TimeRemoveHms2(v.PublishTime)
- mapItems[fmt.Sprint("meetingreviewchapt", v.Id)].Meetingreviewchapt = v
- }
- }
- //处理上周纪要汇总
- if len(minutessummaryIds) > 0 {
- pars = make([]interface{}, 0)
- condition = ` AND article_id IN (` + utils.GetOrmInReplace(len(minutessummaryIds)) + `)`
- pars = append(pars, minutessummaryIds)
- listresearchsummary, e := models.GetReportSelectionListHome(condition, "cygx_minutes_summary", pars, 0, len(minutessummaryIds))
- if e != nil {
- err = errors.New("GetResourceDataList, Err: " + e.Error())
- return
- }
- for _, v := range listresearchsummary {
- v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
- mapItems[fmt.Sprint("minutessummary", v.ArticleId)].Minutessummary = v
- }
- }
- //处理本周纪要汇总
- if len(researchsummaryIds) > 0 {
- pars = make([]interface{}, 0)
- condition = ` AND article_id IN (` + utils.GetOrmInReplace(len(researchsummaryIds)) + `)`
- pars = append(pars, researchsummaryIds)
- listresearchsummary, e := models.GetReportSelectionListHome(condition, "cygx_research_summary", pars, 0, len(researchsummaryIds))
- if e != nil {
- err = errors.New("GetReportSelectionListHome, Err: " + e.Error())
- return
- }
- for _, v := range listresearchsummary {
- v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
- mapItems[fmt.Sprint("researchsummary", v.ArticleId)].Researchsummary = v
- }
- }
- //处理产品内测
- if len(productinteriorIds) > 0 {
- pars = make([]interface{}, 0)
- condition = ` AND art.status = 1 AND art.product_interior_id IN (` + utils.GetOrmInReplace(len(productinteriorIds)) + `)`
- pars = append(pars, productinteriorIds)
- listProductInterior, e := models.GetCygxProductInteriorList(condition, pars, 0, len(productinteriorIds))
- if e != nil {
- err = errors.New("GetCygxProductInteriorList, Err: " + e.Error())
- return
- }
- for _, v := range listProductInterior {
- v.Body = ProductInteriorHtml(v.Body)
- v.PublishTime = utils.TimeRemoveHms2(v.PublishTime)
- mapItems[fmt.Sprint("productinterior", v.ProductInteriorId)].ProductInterior = v
- }
- }
- //处理活动
- if len(activityIds) > 0 {
- for _, vss := range activityIds {
- imgUrlResp += strconv.Itoa(vss) + ","
- }
- pars = make([]interface{}, 0)
- condition = ` AND art.activity_id IN (` + utils.GetOrmInReplace(len(activityIds)) + `) `
- pars = append(pars, activityIds)
- activityList, e := models.GetActivityListNew(condition, pars, uid, 0, len(activityIds), 0, 0, "")
- if e != nil {
- err = errors.New("GetResourceDataList, Err: " + e.Error())
- return
- }
- var activityListRersp []*models.ActivityListResp
- for _, v := range activityList {
- activityListRersp = append(activityListRersp, ActivityButtonShow(v, user, make([]string, 0)))
- }
- //处理不同的报名方式按钮回显
- mapActivitySignup, e := GetActivitySignupResp(activityIds, user)
- if e != nil {
- err = errors.New("GetActivitySignupResp, Err: " + e.Error())
- return
- }
- for _, v := range activityListRersp {
- if v == nil {
- continue
- }
- if v.ActivityType == 0 {
- if mapAddress[v.City] != "" {
- imgUrlResp = mapAddress[v.City]
- } else {
- imgUrlResp = mapAddress["其它"]
- }
- } else {
- if mapChart[v.ChartPermissionName] != "" {
- imgUrlResp = mapChart[v.ChartPermissionName]
- }
- }
- v.ImgUrl = imgUrlResp
- v.SourceType = mapActivitySignup[v.ActivityId]
- mapItems[fmt.Sprint("activity", v.ActivityId)].Activity = v
- }
- }
- //产业资源包
- if len(industrialResourceIds) > 0 {
- pars = make([]interface{}, 0)
- var industrialResourceIdstring []string
- for _, v := range industrialResourceIds {
- industrialResourceIdstring = append(industrialResourceIdstring, strconv.Itoa(v))
- }
- industrialId := strings.Join(industrialResourceIdstring, ",")
- condition = ` AND m.industrial_management_id IN (` + industrialId + `) `
- listIndustrialResourceIds, e := models.GetSearchResourceList(condition)
- if e != nil {
- err = errors.New("GetSearchResourceList, Err: " + e.Error())
- return
- }
- conditionSubject := condition + ` AND m.industrial_management_id IN (` + utils.GetOrmInReplace(len(industrialResourceIds)) + `)`
- pars = append(pars, industrialResourceIds)
- listSubjcet, e := models.GetIndustrialSubjectAllByIndustrialId(pars, conditionSubject)
- //合并产业关联的标的
- if e != nil {
- e = errors.New("GetIndustrialSubjectAllByIndustrialId, Err: " + e.Error())
- return
- }
- mapIndustrial := make(map[string]int)
- for _, v := range listSubjcet {
- for k2, v2 := range listIndustrialResourceIds {
- if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 {
- listIndustrialResourceIds[k2].IndustrialSubjectList = append(listIndustrialResourceIds[k2].IndustrialSubjectList, v)
- }
- }
- }
- for _, v := range listIndustrialResourceIds {
- mapItems[fmt.Sprint("industrialsource", v.IndustrialManagementId)].IndustrialResource = v
- }
- }
- //处理图表
- if len(newchartIds) > 0 {
- pars = make([]interface{}, 0)
- condition = ` AND a.chart_id IN (` + utils.GetOrmInReplace(len(newchartIds)) + `)`
- pars = append(pars, newchartIds)
- chartDateList, e := models.GetChartListCollection(condition, pars, uid, 0, len(newchartIds))
- if e != nil {
- err = errors.New("GetResourceDataList, Err: " + e.Error())
- return
- }
- for _, v := range chartDateList {
- mapItems[fmt.Sprint("newchart", v.ChartId)].Newchart = v
- }
- }
- //处理专项调研
- if len(activityspecialIds) > 0 {
- pars = make([]interface{}, 0)
- condition = ` AND art.activity_id IN (` + utils.GetOrmInReplace(len(activityspecialIds)) + `)`
- pars = append(pars, activityspecialIds)
- activitySpeciallist, e := models.GetCygxActivitySpecialDetailList(condition, pars, user.UserId, 0, len(activityspecialIds))
- if e != nil {
- err = errors.New("GetCygxActivitySpecialDetailList, Err: " + e.Error())
- return
- }
- UserMap, e := GetSpecialTripUserMap(activityspecialIds, user.UserId)
- if e != nil {
- err = errors.New("GetSpecialTripUserMap, Err: " + e.Error())
- return
- }
- for _, v := range activitySpeciallist {
- if mapChart[v.ChartPermissionName] != "" {
- imgUrlResp = mapChart[v.ChartPermissionName]
- }
- if _, ok := UserMap[v.ActivityId]; ok {
- v.IsTrip = 1
- }
- if v.Days == 0 {
- v.TripStatus = 1
- v.TripImgLink = v.TripImgLink
- } else {
- v.TripStatus = 2
- v.TripImgLink = v.TripImgLinkFix
- v.ActivityTimeText = v.ActivityTimeTextByDay
- }
- resultTimeStart := utils.StrTimeToTime(v.ActivityTime) //时间字符串格式转时间格式
- resultTimeEnd := utils.StrTimeToTime(v.ActivityTimeEnd) //时间字符串格式转时间格式
- if resultTimeStart.After(time.Now()) {
- v.ActiveState = "1"
- } else if time.Now().After(resultTimeEnd) {
- v.ActiveState = "3"
- } else {
- v.ActiveState = "2"
- }
- v.ImgUrl = imgUrlResp
- mapItems[fmt.Sprint("activityspecial", v.ActivityId)].Activityspecial = v
- }
- }
- //处理路演 处理路活动视频 处理路活音频
- if len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds) > 0 {
- audioIdstr := strings.Join(activityvoiceIds, ",")
- ideoIdsStr := strings.Join(roadshowIds, ",")
- activityVideoIdsStr := strings.Join(activityvideoIds, ",")
- list, _, e := GetMicroRoadShowMycollect(len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds), 0, audioIdstr, ideoIdsStr, activityVideoIdsStr)
- if e != nil {
- err = errors.New("GetMicroRoadShowMycollect, Err: " + e.Error())
- return
- }
- for _, item := range list {
- if item.Type == 1 {
- //音频
- count, e := models.GetVoiceCollectCount(user.UserId, item.Id)
- if e != nil {
- err = errors.New("GetVoiceCollectCount, Err: " + e.Error())
- return
- }
- if count > 0 {
- item.IsCollect = true
- }
- } else if item.Type == 2 {
- //活动视频
- count, e := models.GetActivityVideoCollectCount(user.UserId, item.Id)
- if e != nil {
- err = errors.New("GetActivityVideoCollectCount, Err: " + e.Error())
- return
- }
- if count > 0 {
- item.IsCollect = true
- }
- } else if item.Type == 3 {
- //微路演视频
- count, e := models.GetVideoCollectCount(user.UserId, item.Id)
- if e != nil {
- err = errors.New("GetVideoCollectCount, Err: " + e.Error())
- return
- }
- if count > 0 {
- item.IsCollect = true
- }
- }
- }
- // 用户权限
- authInfo, permissionArr, e := GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
- if e != nil {
- err = errors.New("GetUserRaiPermissionInfo, Err: " + e.Error())
- return
- }
- // 获取默认图配置
- audioMap, videoMap, audioShareMap, videoShareMap, e := GetMicroRoadShowDefaultImgConfig()
- if e != nil {
- err = errors.New("GetMicroRoadShowDefaultImgConfig, Err: " + e.Error())
- return
- }
- //Source string `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
- for i := range list {
- // 权限
- au := new(models.UserPermissionAuthInfo)
- au.SellerName = authInfo.SellerName
- au.SellerMobile = authInfo.SellerMobile
- au.HasPermission = authInfo.HasPermission
- au.OperationMode = authInfo.OperationMode
- if au.HasPermission == 1 {
- // 非宏观权限进一步判断是否有权限
- if list[i].ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, list[i].ChartPermissionName) {
- au.HasPermission = 2
- }
- }
- // 无权限的弹框提示
- if au.HasPermission != 1 {
- if au.OperationMode == UserPermissionOperationModeCall {
- if list[i].Type == 1 {
- au.PopupMsg = UserPermissionPopupMsgCallActivity
- } else {
- au.PopupMsg = UserPermissionPopupMsgCallMicroVideo
- }
- } else {
- if list[i].Type == 1 {
- au.PopupMsg = UserPermissionPopupMsgApplyActivity
- } else {
- au.PopupMsg = UserPermissionPopupMsgApplyMicroVideo
- }
- }
- }
- list[i].AuthInfo = au
- list[i].PublishTime = utils.StrTimeToTime(list[i].PublishTime).Format(utils.FormatDate)
- // 默认图
- if list[i].BackgroundImg == "" {
- if list[i].Type == 1 {
- list[i].BackgroundImg = audioMap[list[i].ChartPermissionId]
- } else {
- list[i].BackgroundImg = videoMap[list[i].ChartPermissionId]
- }
- }
- // 分享图
- if list[i].ShareImg == "" {
- if list[i].Type == 1 {
- list[i].ShareImg = audioShareMap[list[i].ChartPermissionId]
- } else {
- list[i].ShareImg = videoShareMap[list[i].ChartPermissionId]
- }
- }
- }
- //Type int `description:"类型: 1-音频; 2-活动视频; 3-产业视频"`
- for _, item := range list {
- if item.Type == 1 {
- mapItems[fmt.Sprint("activityvoice", item.Id)].Activityvoice = item
- } else if item.Type == 2 {
- mapItems[fmt.Sprint("activityvideo", item.Id)].Activityvideo = item
- } else if item.Type == 3 {
- mapItems[fmt.Sprint("roadshow", item.Id)].Roadshow = item
- }
- }
- }
- for _, vList := range list {
- for _, v := range mapItems {
- //如果这些类型都为空,那么就不合并
- if v.Article == nil && v.Newchart == nil && v.Roadshow == nil && v.Activity == nil && v.Activityvideo == nil && v.Activityvoice == nil && v.Activityspecial == nil && v.Researchsummary == nil && v.Minutessummary == nil && v.Meetingreviewchapt == nil && v.ProductInterior == nil && v.IndustrialResource == nil {
- continue
- }
- if v.SourceId == vList.SourceId {
- items = append(items, v)
- }
- }
- }
- return
- }
|