forked from all_user/stat_center
新增广告V2模块,双端下载落地页调整
- 新增 advitise v2: info/location/bind/click-stat/day-click-stat 模型与 对应的 service、api、router、proto 定义 - models/index.go 注册 5 个新模型的索引初始化 - 鉴权白名单: /rsdownload/ 改为 /download/,放行 advitise v2 的 get/click 接口 - statg/config: proxyUrl 增加 fileRes1 - common/genId: lid 生成逻辑补充 - 新增 91fans / huangguo 的 mobileconfig 描述文件 - 新增 deploy/nginx/cpcdownload.mfcg.me.conf 网关配置 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -150,6 +150,30 @@ func FindAdsById(ctx context.Context, id int64) (data Advertise, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// FindLatestAdsByAppAndLoc 取该应用/位置当前生效的最新一条广告(用于点击回退到最新广告)
|
||||
// locId <= 0 表示不按位置过滤,只在应用维度取最新
|
||||
func FindLatestAdsByAppAndLoc(ctx context.Context, appId, locId int32) (data Advertise, err error) {
|
||||
now := time.Now()
|
||||
filter := bson.M{
|
||||
"appId": appId,
|
||||
"isActive": true,
|
||||
"startTime": bson.M{"$lte": now},
|
||||
"endTime": bson.M{"$gte": now},
|
||||
}
|
||||
if locId > 0 {
|
||||
filter["locId"] = locId
|
||||
}
|
||||
opts := options.FindOne().SetSort(bson.D{
|
||||
{Key: "sort", Value: 1},
|
||||
{Key: "createAt", Value: -1},
|
||||
})
|
||||
if err = db.FindOne(ctx, &data, filter, opts); err != nil {
|
||||
log.Error("advertise FindLatestAdsByAppAndLoc FindOne err", log.E(err))
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 增加广告点击量
|
||||
func IncAdsClickCount(ctx context.Context, id int64) (err error) {
|
||||
filter := bson.M{"_id": id}
|
||||
|
||||
Reference in New Issue
Block a user