|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- 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 := 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
- }
|