蛋蛋星球 后台端

svc_base.go 1.7 KiB

4 週之前
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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).Update(data)
  51. e.OutSuc(c, "success", nil)
  52. return
  53. }