蛋蛋星球-客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

104 lines
3.4 KiB

  1. package svc
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. "applet/app/md"
  6. "applet/app/utils"
  7. "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
  8. "encoding/json"
  9. "github.com/gin-gonic/gin"
  10. )
  11. func Advertising(c *gin.Context) {
  12. eg := db.Db
  13. var res = md.AdvertisingResp{}
  14. NewAdvertisingBasicDb := implement.NewAdvertisingBasicDb(eg)
  15. NewAdvertisingBasic, _ := NewAdvertisingBasicDb.GetAdvertisingBasicDb()
  16. if NewAdvertisingBasic != nil {
  17. var info = make(map[string]interface{})
  18. json.Unmarshal([]byte(NewAdvertisingBasic.Info), &info)
  19. res.Basic = md.AdvertisingBasic{
  20. Info: info,
  21. AndroidAdIsOpen: utils.IntToStr(NewAdvertisingBasic.AndroidOpenAdIsOpen),
  22. IosAdIsOpen: utils.IntToStr(NewAdvertisingBasic.IosAdIsOpen),
  23. AndroidOpenAdIsOpen: utils.IntToStr(NewAdvertisingBasic.AndroidOpenAdIsOpen),
  24. IosOpenAdIsOpen: utils.IntToStr(NewAdvertisingBasic.IosOpenAdIsOpen),
  25. Voice: GetOssUrl(NewAdvertisingBasic.Voice),
  26. }
  27. }
  28. NewAdvertisingLimitDb := implement.NewAdvertisingLimitDb(eg)
  29. NewAdvertisingLimit, _ := NewAdvertisingLimitDb.GetAdvertisingLimit()
  30. if NewAdvertisingLimit != nil {
  31. res.Pop = md.AdvertisingLimit{
  32. PublicImg: GetOssUrl(NewAdvertisingLimit.PublicImg),
  33. PublicStr: NewAdvertisingLimit.PublicStr,
  34. WithdrawImg: GetOssUrl(NewAdvertisingLimit.WithdrawImg),
  35. WithdrawStr: NewAdvertisingLimit.WithdrawStr,
  36. }
  37. }
  38. NewAdvertisingFunctionDb := implement.NewAdvertisingFunctionDb(eg)
  39. NewAdvertisingFunction, _ := NewAdvertisingFunctionDb.AdvertisingFunctionAll()
  40. AdvertisingFunctionTmp := make([]md.AdvertisingFunction, 0)
  41. if NewAdvertisingFunction != nil {
  42. for _, v := range *NewAdvertisingFunction {
  43. tmp := md.AdvertisingFunction{
  44. Name: v.Name,
  45. Type: v.Type,
  46. AdId: utils.IntToStr(v.AdId),
  47. }
  48. AdvertisingFunctionTmp = append(AdvertisingFunctionTmp, tmp)
  49. }
  50. }
  51. res.Function = AdvertisingFunctionTmp
  52. NewAdvertisingSpaceDb := implement.NewAdvertisingSpaceDb(eg)
  53. NewAdvertisingSpace, _ := NewAdvertisingSpaceDb.AdvertisingSpaceAll()
  54. NewAdvertisingSpaceTmp := make([]md.AdvertisingSpace, 0)
  55. if NewAdvertisingSpace != nil {
  56. for _, v := range *NewAdvertisingSpace {
  57. var info = make(map[string]interface{})
  58. json.Unmarshal([]byte(v.Info), &info)
  59. tmp := md.AdvertisingSpace{
  60. Id: utils.IntToStr(v.Id),
  61. Name: v.Name,
  62. Kind: utils.IntToStr(v.Kind),
  63. Info: info,
  64. CountingDown: utils.IntToStr(v.CountingDown),
  65. }
  66. NewAdvertisingSpaceTmp = append(NewAdvertisingSpaceTmp, tmp)
  67. }
  68. }
  69. res.Space = NewAdvertisingSpaceTmp
  70. e.OutSuc(c, res, nil)
  71. return
  72. }
  73. func AdvertisingDetail(c *gin.Context) {
  74. eg := db.Db
  75. var req md.AdvertisingReq
  76. err := c.ShouldBindJSON(&req)
  77. if err != nil {
  78. err = HandleValidateErr(err)
  79. err1 := err.(e.E)
  80. e.OutErr(c, err1.Code, err1.Error())
  81. return
  82. }
  83. var res = md.AdvertisingSpace{}
  84. NewAdvertisingSpaceDb := implement.NewAdvertisingSpaceDb(eg)
  85. NewAdvertisingSpace, _ := NewAdvertisingSpaceDb.GetAdvertisingSpace(req.Id)
  86. if NewAdvertisingSpace != nil {
  87. var info = make(map[string]interface{})
  88. json.Unmarshal([]byte(NewAdvertisingSpace.Info), &info)
  89. tmp := md.AdvertisingSpace{
  90. Id: utils.IntToStr(NewAdvertisingSpace.Id),
  91. Name: NewAdvertisingSpace.Name,
  92. Kind: utils.IntToStr(NewAdvertisingSpace.Kind),
  93. Info: info,
  94. CountingDown: utils.IntToStr(NewAdvertisingSpace.CountingDown),
  95. }
  96. res = tmp
  97. }
  98. e.OutSuc(c, res, nil)
  99. return
  100. }