forked from all_user/stat_center
增加双端下载
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
package cpcDownloadCfg
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"stat/common/log"
|
||||
"stat/common/mongos"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
func Init(ctx context.Context) {
|
||||
db = mongos.New(mongos.MgoManager, TN.CpcDownloadCfg)
|
||||
indexes := []mongo.IndexModel{
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.CpcDownloadCfg.AppId, Value: 1},
|
||||
{Key: FN.CpcDownloadCfg.Channel, Value: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
Keys: bson.D{{Key: FN.CpcDownloadCfg.Status, Value: 1}},
|
||||
},
|
||||
}
|
||||
if _, err := db.CreateIndex(ctx, indexes); err != nil {
|
||||
panic(fmt.Sprintf("(cpcDownloadCfg:Init) CreateIndex failed: %+v", err))
|
||||
}
|
||||
}
|
||||
|
||||
func InsertOneCpcDownloadCfg(ctx context.Context, doc *CpcDownloadCfg) error {
|
||||
if _, err := db.InsertOne(ctx, doc); err != nil {
|
||||
log.Warn("cpcDownloadCfg InsertOne failed", log.E(err))
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func FindOneCpcDownloadCfg(ctx context.Context, filter bson.M) (*CpcDownloadCfg, error) {
|
||||
var doc CpcDownloadCfg
|
||||
if err := db.FindOne(ctx, &doc, filter); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &doc, nil
|
||||
}
|
||||
|
||||
func DelOneCpcDownloadCfg(ctx context.Context, filter bson.M) (int64, error) {
|
||||
count, err := db.DeleteOne(ctx, filter)
|
||||
if err != nil {
|
||||
log.Warn("cpcDownloadCfg DeleteOne failed", log.E(err), log.Any("filter", filter))
|
||||
return 0, err
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func UpdateOneCpcDownloadCfg(ctx context.Context, filter bson.M, update bson.M) error {
|
||||
if _, err := db.UpdateOne(ctx, filter, update); err != nil {
|
||||
log.Warn("cpcDownloadCfg UpdateOne failed", log.E(err), log.Any("filter", filter))
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func CountCpcDownloadCfgs(ctx context.Context, filter bson.M) (int64, error) {
|
||||
count, err := db.Count(ctx, filter)
|
||||
if err != nil {
|
||||
log.Warn("cpcDownloadCfg Count failed", log.E(err), log.Any("filter", filter))
|
||||
return 0, err
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func FindManyCpcDownloadCfg(ctx context.Context, filter bson.M, opts ...*options.FindOptions) (CpcDownloadCfgList, error) {
|
||||
list := make(CpcDownloadCfgList, 0)
|
||||
if err := db.Find(ctx, &list, filter, opts...); err != nil {
|
||||
log.Warn("cpcDownloadCfg Find failed", log.E(err), log.Any("filter", filter))
|
||||
return nil, err
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package cpcDownloadCfg
|
||||
|
||||
type TagCpcDownloadCfg struct {
|
||||
Id string
|
||||
AppId string
|
||||
Channel string
|
||||
LandingPage string
|
||||
DownloadUrl string
|
||||
IosDownSuff string
|
||||
Remark string
|
||||
Status string
|
||||
CreatedAt string
|
||||
UpdatedAt string
|
||||
}
|
||||
|
||||
var FN struct {
|
||||
CpcDownloadCfg TagCpcDownloadCfg
|
||||
}
|
||||
|
||||
var TN struct {
|
||||
CpcDownloadCfg string
|
||||
}
|
||||
|
||||
func init() {
|
||||
FN.CpcDownloadCfg.Id = "_id"
|
||||
FN.CpcDownloadCfg.AppId = "appId"
|
||||
FN.CpcDownloadCfg.Channel = "channel"
|
||||
FN.CpcDownloadCfg.LandingPage = "landingPage"
|
||||
FN.CpcDownloadCfg.DownloadUrl = "downloadUrl"
|
||||
FN.CpcDownloadCfg.IosDownSuff = "iosDownSuff"
|
||||
FN.CpcDownloadCfg.Remark = "remark"
|
||||
FN.CpcDownloadCfg.Status = "status"
|
||||
FN.CpcDownloadCfg.CreatedAt = "createdAt"
|
||||
FN.CpcDownloadCfg.UpdatedAt = "updatedAt"
|
||||
TN.CpcDownloadCfg = "cpc_download_cfg"
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cpcDownloadCfg
|
||||
|
||||
import (
|
||||
"stat/common/mongos"
|
||||
"time"
|
||||
)
|
||||
|
||||
var db *mongos.MongoTool
|
||||
|
||||
// CpcDownloadCfg CPC 下载配置: 双端下载落地页 + Android 下载地址 + iOS mobileconfig 文件名
|
||||
// @table:cpcDownloadCfg
|
||||
type CpcDownloadCfg struct {
|
||||
Id int64 `json:"id" bson:"_id"`
|
||||
AppId int32 `json:"appId" bson:"appId"` // appId
|
||||
Channel string `json:"channel" bson:"channel"` // 渠道(json字符串)
|
||||
LandingPage string `json:"landingPage" bson:"landingPage"` // iOS 落地页 URL,优先于 mobileconfig
|
||||
DownloadUrl string `json:"downloadUrl" bson:"downloadUrl"` // Android 下载地址
|
||||
IosDownSuff string `json:"iosDownSuff" bson:"iosDownSuff"` // iOS mobileconfig 文件名(下载后缀)
|
||||
Remark string `json:"remark" bson:"remark"` // 备注
|
||||
Status bool `json:"status" bson:"status"` // 是否启用
|
||||
CreatedAt time.Time `json:"createdAt" bson:"createdAt"` // 创建时间
|
||||
UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"` // 更新时间
|
||||
}
|
||||
|
||||
type CpcDownloadCfgList []*CpcDownloadCfg
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"stat/models/channelmod"
|
||||
"stat/models/channelpackage"
|
||||
"stat/models/channelsettlementrecord"
|
||||
"stat/models/cpcDownloadCfg"
|
||||
"stat/models/dailyhourstatmod"
|
||||
"stat/models/dailystatadvertise"
|
||||
"stat/models/dailystatmod"
|
||||
@@ -107,4 +108,5 @@ func InitIndex() {
|
||||
applicationstat.Init(ctx)
|
||||
applicationLocMod.Init(ctx)
|
||||
channelpackage.Init(ctx)
|
||||
cpcDownloadCfg.Init(ctx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user