|
@@ -202,8 +202,10 @@ func (query *SeoBiddingQuery) GetOnceData(ctx context.Context, total int, flag s
|
|
|
if data != nil && len(data) > 0 {
|
|
|
res = query.dataFormat(data)
|
|
|
}
|
|
|
- if err := g.Redis().SetEX(ctx, cacheKey, res, consts.SettingBidCacheTime); err != nil {
|
|
|
- g.Log().Errorf(ctx, "GetOnceData 存储redis err:%v", err)
|
|
|
+ if res != nil && len(res) > 0 {
|
|
|
+ if err := g.Redis().SetEX(ctx, cacheKey, res, consts.SettingBidCacheTime); err != nil {
|
|
|
+ g.Log().Errorf(ctx, "GetOnceData 存储redis err:%v", err)
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
err = vars.Struct(&res)
|
|
@@ -212,20 +214,41 @@ func (query *SeoBiddingQuery) GetOnceData(ctx context.Context, total int, flag s
|
|
|
}
|
|
|
|
|
|
func FillingBiddingBaseFields(ctx context.Context, res []map[string]interface{}) []map[string]interface{} {
|
|
|
- bidIdStrings := make([]string, 0, len(res))
|
|
|
+ var batchSize = g.Cfg().MustGet(context.Background(), "listPageSetting.batchSize", 200).Int()
|
|
|
+ var (
|
|
|
+ queryIdBatch = [][]string{}
|
|
|
+ tmpArr = make([]string, 0, batchSize)
|
|
|
+ total = len(res)
|
|
|
+ index = 0
|
|
|
+ )
|
|
|
+
|
|
|
for _, m := range res {
|
|
|
- if bidId := gconv.String(m["bid_id"]); bidId != "" {
|
|
|
- bidIdStrings = append(bidIdStrings, bidId)
|
|
|
+ bidId := gconv.String(m["bid_id"])
|
|
|
+ if bidId == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ tmpArr = append(tmpArr, bidId)
|
|
|
+ if len(tmpArr) == batchSize {
|
|
|
+ queryIdBatch = append(queryIdBatch, tmpArr)
|
|
|
+ tmpArr = make([]string, 0, batchSize)
|
|
|
+ }
|
|
|
+ index++
|
|
|
+ if index == total {
|
|
|
+ queryIdBatch = append(queryIdBatch, tmpArr)
|
|
|
}
|
|
|
}
|
|
|
- bidRes, _ := g.DB().Query(ctx, fmt.Sprintf(`SELECT * FROM jyseo.new_bidList WHERE bid_id IN ('%s')`, strings.Join(bidIdStrings, "','")))
|
|
|
- if bidRes.IsEmpty() {
|
|
|
- return nil
|
|
|
- }
|
|
|
- bidMap := map[string]map[string]interface{}{}
|
|
|
- for _, m := range bidRes.List() {
|
|
|
- if bidIdStr := gconv.String(m["bid_id"]); bidIdStr != "" {
|
|
|
- bidMap[bidIdStr] = m
|
|
|
+ var (
|
|
|
+ bidMap = map[string]map[string]interface{}{}
|
|
|
+ )
|
|
|
+ for _, ids := range queryIdBatch {
|
|
|
+ bidRes, _ := g.DB().Query(ctx, fmt.Sprintf(`SELECT * FROM new_bidList WHERE bid_id IN ('%s')`, strings.Join(ids, "','")))
|
|
|
+ if bidRes.IsEmpty() {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ for _, m := range bidRes.List() {
|
|
|
+ if bidIdStr := gconv.String(m["bid_id"]); bidIdStr != "" {
|
|
|
+ bidMap[bidIdStr] = m
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|