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

пре 2 недеља
пре 2 недеља
пре 2 недеља
пре 2 недеља
пре 2 недеља
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. }