package configser import ( "context" "videoweb/app/api/proto" "videoweb/app/appg" "videoweb/pub/adcenter" "videoweb/pub/common/log" "videoweb/pub/models/videoinformationmod" "videoweb/pub/pubdef" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo/options" ) func UpdateAnnouncementData(ctx context.Context) { config := GetConfigInfo() resp := proto.AnnouncementInfo{ VideoInfo: make([]proto.VideoInfoData, 0), PdfAddr: config.PdfAddr, NewUrlAddr: config.DHNewUrlAddr1, NewUrlAddr1: config.DHNewUrlAddr2, NewUrlAddr2: config.DHNewUrlAddr3, ForeverUrlAddr: config.ForeverUrlAddr, AppAddr: config.AppAddr, TranslationAddr: config.TranslationAddr, } videoFilter := bson.M{ videoinformationmod.FN.VideoInformation.Status: pubdef.InformationStatusVerifyOK, videoinformationmod.FN.VideoInformation.IsHot: true, } videoOpt := &options.FindOptions{} videoOpt.SetSort(bson.M{videoinformationmod.FN.VideoInformation.Sort: -1}) videoOpt.SetLimit(2) videoList, serr := videoinformationmod.FindManyVideoInformations(ctx, videoFilter, videoOpt) if serr != nil { log.Error("VideoCategoryData", log.Any("videoFilter", videoFilter), log.E(serr)) return } // 查询视频 for _, videoInfo := range videoList { v := proto.VideoInfoToData(videoInfo, config.ImgCdn, GetCreateInfo(videoInfo.CreatorId, config.ImgCdn)) for _, tagId := range videoInfo.Tags { tagInfo := GetVideoTag(tagId) if tagInfo != nil { v.Tags = append(v.Tags, proto.TagsInfoData{ Id: tagInfo.Id, Name: tagInfo.Name, Slug: tagInfo.Slug, }) } } resp.VideoInfo = append(resp.VideoInfo, v) } CacheMgr.Lock.Lock() defer CacheMgr.Lock.Unlock() CacheMgr.Announcement = resp } // UpdateAdvitiseDataFromJt 从广告中心拉取福利页广告 func UpdateAdvitiseDataFromJt() { //config := GetConfigInfo() var resp proto.AdvitiseData jtAds, err := adcenter.JtAdvertiseThreeServer(appg.Conf.AdCenter.ApiDomain, appg.Conf.AdCenter.MerchantCode, appg.Conf.AdCenter.AppCode, appg.Conf.AdCenter.AesKey) if err != nil { log.Error("JtAdvertiseThreeServer error occur", log.E(err)) return } for _, _ = range jtAds { //pos, err := strconv.Atoi(loc.AdvertiseLocationCode) //if err != nil { // log.Error("广告位置代码错误,必须为数字", log.Any("code", loc.AdvertiseLocationCode)) // continue //} ////if pos < 100001 { //// continue ////} //ads := make([]proxy.AdvitiseInfo, 0) //for _, ad := range loc.AdDetailInfoList { // //extra := ad.GetExtraData() // ads = append(ads, proxy.AdvitiseInfo{ // Id: ad.AdvertiseCode, // Location: int64(pos), // Title: ad.AdvertiseName, // Images: netutil.MergeURL(config.ImgCdn, ad.GetCoverLsj()), // Link: ad.GetRealLink(), // }) //} // //switch pos { //case 1: // resp.HomeList = ads //case 2: // resp.DetailTopList = ads //case 3: // resp.NineGridList = ads //case 4: // resp.DetailbannerList = ads //case 5: // resp.LaunchScreenList = ads //case 6: // resp.MustAppList = ads //case 7: // resp.TitleAppList = ads //case 8: // resp.FriendList = ads //case 9: // resp.DialogList = ads //case 10: // resp.PostList = ads //case 11: // resp.FloatingList = ads //case 12: // resp.AList = ads //case 13: // resp.BList = ads //case 14: // resp.VideoList = ads //} } CacheMgr.Lock.Lock() defer CacheMgr.Lock.Unlock() CacheMgr.Advitise = resp }