蛋蛋星球 后台端
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.
 
 
 
 
 

59 rindas
1.8 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 := []map[string]string{
  20. {"name": "穿山甲", "value": "chuanshanjia"},
  21. {"name": "广点通", "value": "guangdiantong"},
  22. }
  23. AdvertisingBase := md.AdvertisingBase{
  24. AndroidAdIsOpen: utils.IntToStr(data.AndroidAdIsOpen),
  25. IosAdIsOpen: utils.IntToStr(data.IosAdIsOpen),
  26. AndroidOpenAdIsOpen: utils.IntToStr(data.AndroidOpenAdIsOpen),
  27. IosOpenAdIsOpen: utils.IntToStr(data.IosOpenAdIsOpen),
  28. Voice: data.Voice,
  29. VoiceUrl: svc.GetOssUrl(data.Voice),
  30. Info: data.Info,
  31. }
  32. res := md.AdvertisingBaseResp{
  33. SelectData: selsctData,
  34. AdvertisingBase: AdvertisingBase,
  35. }
  36. e.OutSuc(c, res, nil)
  37. return
  38. }
  39. func SetBasic(c *gin.Context) {
  40. var req *md.AdvertisingBase
  41. if err := c.ShouldBindJSON(&req); err != nil {
  42. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  43. return
  44. }
  45. NewAdvertisingBasicDb := implement.NewAdvertisingBasicDb(db.Db)
  46. data, _ := NewAdvertisingBasicDb.GetAdvertisingBasicDb()
  47. data.AndroidAdIsOpen = utils.StrToInt(req.AndroidAdIsOpen)
  48. data.IosAdIsOpen = utils.StrToInt(req.IosAdIsOpen)
  49. data.AndroidOpenAdIsOpen = utils.StrToInt(req.AndroidOpenAdIsOpen)
  50. data.IosOpenAdIsOpen = utils.StrToInt(req.IosOpenAdIsOpen)
  51. data.Voice = req.Voice
  52. data.Info = req.Info
  53. db.Db.Where("id=?", data.Id).Update(data)
  54. e.OutSuc(c, "success", nil)
  55. return
  56. }