package advertising import ( "applet/app/db" "applet/app/e" "applet/app/md" "applet/app/svc" "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" ) func GetBasic(c *gin.Context) { NewAdvertisingBasicDb := implement.NewAdvertisingBasicDb(db.Db) data, _ := NewAdvertisingBasicDb.GetAdvertisingBasicDb() if data == nil { data = &model.AdvertisingBasic{} db.Db.Insert(data) } selsctData := []map[string]string{ {"name": "穿山甲", "value": "chuanshanjia"}, {"name": "广点通", "value": "guangdiantong"}, } 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).Update(data) e.OutSuc(c, "success", nil) return }