蛋蛋星球 后台端
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 

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