package advertising import ( "applet/app/db" "applet/app/e" "applet/app/md" "applet/app/svc" "applet/app/svc/sys_cfg" "applet/app/utils" "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" "code.fnuoos.com/EggPlanet/egg_models.git/src/model" "github.com/gin-gonic/gin" "github.com/tidwall/gjson" ) func GetBasic(c *gin.Context) { NewAdvertisingBasicDb := implement.NewAdvertisingBasicDb(db.Db) data, _ := NewAdvertisingBasicDb.GetAdvertisingBasicDb() if data == nil { data = &model.AdvertisingBasic{} db.Db.Insert(data) } selsctData := md.AdvertisingPlatform AdvertisingBase := md.AdvertisingBase{ AndroidAdIsOpen: utils.IntToStr(data.AndroidAdIsOpen), IosAdIsOpen: utils.IntToStr(data.IosAdIsOpen), AndroidOpenAdIsOpen: utils.IntToStr(data.AndroidOpenAdIsOpen), IosOpenAdIsOpen: utils.IntToStr(data.IosOpenAdIsOpen), Voice: data.Voice, VoiceUrl: svc.GetOssUrl(data.Voice), Info: data.Info, } res := md.AdvertisingBaseResp{ SelectData: selsctData, AdvertisingBase: AdvertisingBase, } e.OutSuc(c, res, nil) return } func SetBasic(c *gin.Context) { var req *md.AdvertisingBase if err := c.ShouldBindJSON(&req); err != nil { e.OutErr(c, e.ERR_INVALID_ARGS, err) return } NewAdvertisingBasicDb := implement.NewAdvertisingBasicDb(db.Db) data, _ := NewAdvertisingBasicDb.GetAdvertisingBasicDb() data.AndroidAdIsOpen = utils.StrToInt(req.AndroidAdIsOpen) data.IosAdIsOpen = utils.StrToInt(req.IosAdIsOpen) data.AndroidOpenAdIsOpen = utils.StrToInt(req.AndroidOpenAdIsOpen) data.IosOpenAdIsOpen = utils.StrToInt(req.IosOpenAdIsOpen) data.Voice = req.Voice data.Info = req.Info db.Db.Where("id=?", data.Id).AllCols().Update(data) e.OutSuc(c, "success", nil) return } func GetPlayletBasic(c *gin.Context) { playletBase := svc.GetSysCfgStr("playlet_incentive_base") var res = md.PlayletIncentiveBaseData{ AndroidAdvId: gjson.Get(playletBase, "android_adv_id").String(), AndroidAdvSecret: gjson.Get(playletBase, "android_adv_secret").String(), IosAdvId: gjson.Get(playletBase, "ios_adv_id").String(), IosAdvSecret: gjson.Get(playletBase, "ios_adv_secret").String(), } e.OutSuc(c, res, nil) return } func SetPlayletBasic(c *gin.Context) { var req md.PlayletIncentiveBaseData err := c.ShouldBindJSON(&req) if err != nil { err = svc.HandleValidateErr(err) err1 := err.(e.E) e.OutErr(c, err1.Code, err1.Error()) return } sysCfgDb := sys_cfg.NewSysCfgDb(db.Db) sysCfgDb.SysCfgUpdate("playlet_incentive_base", utils.SerializeStr(req)) e.OutSuc(c, "success", nil) return }