新增广告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:
@@ -0,0 +1,92 @@
|
||||
package advitiseV2Ser
|
||||
|
||||
import (
|
||||
"context"
|
||||
"stat/api/proto"
|
||||
"stat/common/genId"
|
||||
"stat/models/advitiseBindMod"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
func BindList(ctx context.Context, req *proto.AdvitiseBindListReq) (*proto.AdvitiseBindListResp, error) {
|
||||
resp := &proto.AdvitiseBindListResp{
|
||||
Total: 0,
|
||||
List: make(advitiseBindMod.AdvitiseBindList, 0),
|
||||
}
|
||||
filter := bson.M{}
|
||||
if req.AppId != nil {
|
||||
filter[advitiseBindMod.FN.AdvitiseBind.AppId] = *req.AppId
|
||||
}
|
||||
if req.AdvitiseId != nil {
|
||||
filter[advitiseBindMod.FN.AdvitiseBind.AdvitiseId] = *req.AdvitiseId
|
||||
}
|
||||
if req.LocationId != nil {
|
||||
filter[advitiseBindMod.FN.AdvitiseBind.LocationId] = *req.LocationId
|
||||
}
|
||||
total, err := advitiseBindMod.CountAdvitiseBinds(ctx, filter)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
opt := &options.FindOptions{}
|
||||
opt.SetSort(bson.D{
|
||||
{Key: advitiseBindMod.FN.AdvitiseBind.Sort, Value: -1},
|
||||
{Key: advitiseBindMod.FN.AdvitiseBind.CreatedAt, Value: -1},
|
||||
})
|
||||
opt.SetSkip((req.PageNum - 1) * req.PageSize)
|
||||
opt.SetLimit(req.PageSize)
|
||||
list, err := advitiseBindMod.FindManyAdvitiseBinds(ctx, filter, opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp.Total = total
|
||||
resp.List = list
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func BindAdd(ctx context.Context, req *proto.AddAdvitiseBindReq) error {
|
||||
now := time.Now()
|
||||
locs := req.LocationId
|
||||
if locs == nil {
|
||||
locs = []int32{}
|
||||
}
|
||||
doc := &advitiseBindMod.AdvitiseBind{
|
||||
Id: genId.GetAdvitiseBindId(),
|
||||
AppId: req.AppId,
|
||||
AdvitiseId: req.AdvitiseId,
|
||||
LocationId: locs,
|
||||
Sort: req.Sort,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
return advitiseBindMod.InsertOneAdvitiseBind(ctx, doc)
|
||||
}
|
||||
|
||||
func BindUpdate(ctx context.Context, req *proto.UpdateAdvitiseBindReq) error {
|
||||
set := bson.M{
|
||||
advitiseBindMod.FN.AdvitiseBind.UpdatedAt: time.Now(),
|
||||
}
|
||||
if req.AppId != nil {
|
||||
set[advitiseBindMod.FN.AdvitiseBind.AppId] = *req.AppId
|
||||
}
|
||||
if req.AdvitiseId != nil {
|
||||
set[advitiseBindMod.FN.AdvitiseBind.AdvitiseId] = *req.AdvitiseId
|
||||
}
|
||||
if req.LocationId != nil {
|
||||
set[advitiseBindMod.FN.AdvitiseBind.LocationId] = *req.LocationId
|
||||
}
|
||||
if req.Sort != nil {
|
||||
set[advitiseBindMod.FN.AdvitiseBind.Sort] = *req.Sort
|
||||
}
|
||||
return advitiseBindMod.UpdateOneAdvitiseBind(ctx,
|
||||
bson.M{advitiseBindMod.FN.AdvitiseBind.Id: req.Id},
|
||||
bson.M{"$set": set},
|
||||
)
|
||||
}
|
||||
|
||||
func BindDel(ctx context.Context, id int64) error {
|
||||
_, err := advitiseBindMod.DelOneAdvitiseBind(ctx, bson.M{advitiseBindMod.FN.AdvitiseBind.Id: id})
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user