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

93 regels
2.7 KiB

  1. package advertising
  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. "code.fnuoos.com/EggPlanet/egg_models.git/src/model"
  9. "github.com/gin-gonic/gin"
  10. )
  11. func FunctionList(c *gin.Context) {
  12. var req *md.AdvertisingFunctionListReq
  13. if err := c.ShouldBindJSON(&req); err != nil {
  14. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  15. return
  16. }
  17. var resp md.AdvertisingFunctionListResp
  18. noticeList := make([]md.AdvertisingFunctionList, 0)
  19. resp.SelectData = []map[string]string{
  20. {"name": "APP开屏(开屏广告)", "value": "open_advertisement"},
  21. {"name": "首页砸蛋(激励视频)", "value": "incentive_eggSmash"},
  22. {"name": "首页签到(激励视频)", "value": "incentive_eggSign"},
  23. {"name": "提现(激励视频)", "value": "incentive_withdraw"},
  24. {"name": "积分兑换(插屏)", "value": "interstitial_integralExchange"},
  25. {"name": "动态IM(信息流)", "value": "information_im"},
  26. }
  27. NewAdvertisingSpaceDb := implement.NewAdvertisingSpaceDb(db.Db)
  28. adv, _, _ := NewAdvertisingSpaceDb.FindUserFeedbackCateAndTotal("1", "1000", "", "")
  29. advList := make([]map[string]string, 0)
  30. if adv != nil {
  31. for _, v := range *adv {
  32. tmp := map[string]string{
  33. "name": v.Name,
  34. "value": utils.IntToStr(v.Id),
  35. }
  36. advList = append(advList, tmp)
  37. }
  38. }
  39. resp.AdvData = advList
  40. NewJpushNoticeDb := implement.NewAdvertisingFunctionDb(db.Db)
  41. notice, total, _ := NewJpushNoticeDb.FindUserFeedbackFunctionAndTotal(req.Page, req.Limit)
  42. resp.Total = total
  43. if notice != nil {
  44. for _, v := range *notice {
  45. tmp := md.AdvertisingFunctionList{
  46. Id: utils.Int64ToStr(v.Id),
  47. AdId: utils.IntToStr(v.AdId),
  48. Type: v.Type,
  49. }
  50. noticeList = append(noticeList, tmp)
  51. }
  52. }
  53. resp.List = noticeList
  54. e.OutSuc(c, resp, nil)
  55. return
  56. }
  57. func FunctionDel(c *gin.Context) {
  58. var req *md.ArticleCateDelReq
  59. if err := c.ShouldBindJSON(&req); err != nil {
  60. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  61. return
  62. }
  63. db.Db.In("id", req.Id).Delete(&model.AdvertisingFunction{})
  64. e.OutSuc(c, "success", nil)
  65. return
  66. }
  67. func FunctionSave(c *gin.Context) {
  68. var req *md.AdvertisingFunctionList
  69. if err := c.ShouldBindJSON(&req); err != nil {
  70. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  71. return
  72. }
  73. var data = new(model.AdvertisingFunction)
  74. if utils.StrToInt(req.Id) > 0 {
  75. NewAdvertisingSpaceDb := implement.NewAdvertisingFunctionDb(db.Db)
  76. space, _ := NewAdvertisingSpaceDb.GetAdvertisingFunction(req.Id)
  77. if space == nil {
  78. e.OutErr(c, 400, e.NewErr(400, "记录不存在"))
  79. return
  80. }
  81. data = space
  82. } else {
  83. db.Db.Insert(data)
  84. }
  85. data.Type = req.Type
  86. data.AdId = utils.StrToInt(req.AdId)
  87. db.Db.Where("id=?", data.Id).Update(data)
  88. e.OutSuc(c, "success", nil)
  89. return
  90. }