蛋蛋星球 后台端
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

57 rindas
1.7 KiB

  1. package advertising
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. "applet/app/md"
  6. "applet/app/svc"
  7. "applet/app/utils"
  8. "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
  9. "code.fnuoos.com/EggPlanet/egg_models.git/src/model"
  10. "github.com/gin-gonic/gin"
  11. )
  12. func GetBasic(c *gin.Context) {
  13. NewAdvertisingBasicDb := implement.NewAdvertisingBasicDb(db.Db)
  14. data, _ := NewAdvertisingBasicDb.GetAdvertisingBasicDb()
  15. if data == nil {
  16. data = &model.AdvertisingBasic{}
  17. db.Db.Insert(data)
  18. }
  19. selsctData := md.AdvertisingPlatform
  20. AdvertisingBase := md.AdvertisingBase{
  21. AndroidAdIsOpen: utils.IntToStr(data.AndroidAdIsOpen),
  22. IosAdIsOpen: utils.IntToStr(data.IosAdIsOpen),
  23. AndroidOpenAdIsOpen: utils.IntToStr(data.AndroidOpenAdIsOpen),
  24. IosOpenAdIsOpen: utils.IntToStr(data.IosOpenAdIsOpen),
  25. Voice: data.Voice,
  26. VoiceUrl: svc.GetOssUrl(data.Voice),
  27. Info: data.Info,
  28. }
  29. res := md.AdvertisingBaseResp{
  30. SelectData: selsctData,
  31. AdvertisingBase: AdvertisingBase,
  32. }
  33. e.OutSuc(c, res, nil)
  34. return
  35. }
  36. func SetBasic(c *gin.Context) {
  37. var req *md.AdvertisingBase
  38. if err := c.ShouldBindJSON(&req); err != nil {
  39. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  40. return
  41. }
  42. NewAdvertisingBasicDb := implement.NewAdvertisingBasicDb(db.Db)
  43. data, _ := NewAdvertisingBasicDb.GetAdvertisingBasicDb()
  44. data.AndroidAdIsOpen = utils.StrToInt(req.AndroidAdIsOpen)
  45. data.IosAdIsOpen = utils.StrToInt(req.IosAdIsOpen)
  46. data.AndroidOpenAdIsOpen = utils.StrToInt(req.AndroidOpenAdIsOpen)
  47. data.IosOpenAdIsOpen = utils.StrToInt(req.IosOpenAdIsOpen)
  48. data.Voice = req.Voice
  49. data.Info = req.Info
  50. db.Db.Where("id=?", data.Id).AllCols().Update(data)
  51. e.OutSuc(c, "success", nil)
  52. return
  53. }