|
@@ -7,6 +7,7 @@ import (
|
|
"github.com/gogf/gf/v2/container/gvar"
|
|
"github.com/gogf/gf/v2/container/gvar"
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
|
|
+ "jyseo/internal/consts"
|
|
"jyseo/utility"
|
|
"jyseo/utility"
|
|
)
|
|
)
|
|
|
|
|
|
@@ -37,19 +38,6 @@ type (
|
|
}
|
|
}
|
|
)
|
|
)
|
|
|
|
|
|
-var (
|
|
|
|
- SettingPageSize = g.Cfg().MustGet(context.Background(), "listPageSetting.pageSize").Int()
|
|
|
|
- KeyWordsListMaxTotal = g.Cfg().MustGet(context.Background(), "listPageSetting.keywordSize", 200).Int()
|
|
|
|
- BiddingListMaxTotal = g.Cfg().MustGet(context.Background(), "listPageSetting.maxBidSize", 5000).Int()
|
|
|
|
- SettingBidCacheTime = g.Cfg().MustGet(context.Background(), "listPageSetting.cacheTime").Int64()
|
|
|
|
- topTypeMap = map[string]string{
|
|
|
|
- "招标预告": "预告",
|
|
|
|
- "招标公告": "招标",
|
|
|
|
- "招标结果": "结果",
|
|
|
|
- "招标信用信息": "其它",
|
|
|
|
- }
|
|
|
|
-)
|
|
|
|
-
|
|
|
|
func NewBiddingQuery() *SeoBiddingQuery {
|
|
func NewBiddingQuery() *SeoBiddingQuery {
|
|
return &SeoBiddingQuery{}
|
|
return &SeoBiddingQuery{}
|
|
}
|
|
}
|
|
@@ -97,7 +85,7 @@ func (query *SeoBiddingQuery) getResult(ctx context.Context, total int) (int, []
|
|
}
|
|
}
|
|
|
|
|
|
if query.topType != "" {
|
|
if query.topType != "" {
|
|
- if val, _ := topTypeMap[query.topType]; val != "" {
|
|
|
|
|
|
+ if val, _ := consts.TopTypeMap[query.topType]; val != "" {
|
|
sql += " AND b.toptype=? "
|
|
sql += " AND b.toptype=? "
|
|
values = append(values, val)
|
|
values = append(values, val)
|
|
} else {
|
|
} else {
|
|
@@ -176,7 +164,7 @@ func (query *SeoBiddingQuery) dataFormat(data []map[string]interface{}) (bList [
|
|
|
|
|
|
// getBidListCacheKey 获取列表缓存
|
|
// getBidListCacheKey 获取列表缓存
|
|
func (query *SeoBiddingQuery) getBidListCacheKey(pageNum, maxTotal int) string {
|
|
func (query *SeoBiddingQuery) getBidListCacheKey(pageNum, maxTotal int) string {
|
|
- return fmt.Sprintf("JySeoListCache_%d_%d/%d_%s_%s_%s_%s_%s", SettingPageSize, pageNum, maxTotal, query.keys, query.area, query.city, query.topType, query.subType)
|
|
|
|
|
|
+ return fmt.Sprintf("JySeoListCache_%d_%d/%d_%s_%s_%s_%s_%s", consts.SettingPageSize, pageNum, maxTotal, query.keys, query.area, query.city, query.topType, query.subType)
|
|
}
|
|
}
|
|
|
|
|
|
// GetBidListList 列表页查询
|
|
// GetBidListList 列表页查询
|
|
@@ -199,12 +187,12 @@ func (query *SeoBiddingQuery) GetBidListList(ctx context.Context, pageNum, maxTo
|
|
count = maxTotal
|
|
count = maxTotal
|
|
}
|
|
}
|
|
if data != nil && len(data) > 0 && gconv.Int(count) == len(data) {
|
|
if data != nil && len(data) > 0 && gconv.Int(count) == len(data) {
|
|
- totalPage, formatData := count/SettingPageSize, query.dataFormat(data)
|
|
|
|
- if count%SettingPageSize != 0 {
|
|
|
|
|
|
+ totalPage, formatData := count/consts.SettingPageSize, query.dataFormat(data)
|
|
|
|
+ if count%consts.SettingPageSize != 0 {
|
|
totalPage++
|
|
totalPage++
|
|
}
|
|
}
|
|
for i := 1; i <= gconv.Int(totalPage); i++ {
|
|
for i := 1; i <= gconv.Int(totalPage); i++ {
|
|
- start, end := (i-1)*SettingPageSize, (i)*SettingPageSize
|
|
|
|
|
|
+ start, end := (i-1)*consts.SettingPageSize, (i)*consts.SettingPageSize
|
|
if end > count {
|
|
if end > count {
|
|
end = count
|
|
end = count
|
|
}
|
|
}
|
|
@@ -215,7 +203,7 @@ func (query *SeoBiddingQuery) GetBidListList(ctx context.Context, pageNum, maxTo
|
|
if i == pageNum {
|
|
if i == pageNum {
|
|
res = pageTmp
|
|
res = pageTmp
|
|
}
|
|
}
|
|
- if err := g.Redis().SetEX(ctx, query.getBidListCacheKey(i, maxTotal), pageTmp, SettingBidCacheTime); err != nil {
|
|
|
|
|
|
+ if err := g.Redis().SetEX(ctx, query.getBidListCacheKey(i, maxTotal), pageTmp, consts.SettingBidCacheTime); err != nil {
|
|
g.Log().Errorf(ctx, "第%d页数据 存储redis err:%v", err)
|
|
g.Log().Errorf(ctx, "第%d页数据 存储redis err:%v", err)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -248,7 +236,7 @@ func (query *SeoBiddingQuery) GetTabData(ctx context.Context, total int) (res []
|
|
if data != nil && len(data) > 0 {
|
|
if data != nil && len(data) > 0 {
|
|
res = query.dataFormat(data)
|
|
res = query.dataFormat(data)
|
|
}
|
|
}
|
|
- if err := g.Redis().SetEX(ctx, cacheKey, res, SettingBidCacheTime); err != nil {
|
|
|
|
|
|
+ if err := g.Redis().SetEX(ctx, cacheKey, res, consts.SettingBidCacheTime); err != nil {
|
|
g.Log().Errorf(ctx, "GetTabData 存储redis err:%v", err)
|
|
g.Log().Errorf(ctx, "GetTabData 存储redis err:%v", err)
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|