蛋蛋星球 后台端
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

svc_function.go 2.8 KiB

pirms 4 nedēļām
pirms 3 nedēļām
pirms 3 nedēļām
pirms 2 nedēļām
pirms 4 nedēļām
pirms 3 nedēļām
pirms 4 nedēļām
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. {"name": "短视频(短视频)", "value": "short_video"},
  27. {"name": "短剧(短剧)", "value": "short_playlet"},
  28. }
  29. NewAdvertisingSpaceDb := implement.NewAdvertisingSpaceDb(db.Db)
  30. adv, _, _ := NewAdvertisingSpaceDb.FindUserFeedbackCateAndTotal("1", "1000", "", "")
  31. advList := make([]map[string]string, 0)
  32. if adv != nil {
  33. for _, v := range *adv {
  34. tmp := map[string]string{
  35. "name": v.Name,
  36. "value": utils.IntToStr(v.Id),
  37. }
  38. advList = append(advList, tmp)
  39. }
  40. }
  41. resp.AdvData = advList
  42. NewJpushNoticeDb := implement.NewAdvertisingFunctionDb(db.Db)
  43. notice, total, _ := NewJpushNoticeDb.FindUserFeedbackFunctionAndTotal(req.Page, req.Limit)
  44. resp.Total = total
  45. if notice != nil {
  46. for _, v := range *notice {
  47. tmp := md.AdvertisingFunctionList{
  48. Id: utils.Int64ToStr(v.Id),
  49. AdId: utils.IntToStr(v.AdId),
  50. Type: v.Type,
  51. }
  52. noticeList = append(noticeList, tmp)
  53. }
  54. }
  55. resp.List = noticeList
  56. e.OutSuc(c, resp, nil)
  57. return
  58. }
  59. func FunctionDel(c *gin.Context) {
  60. var req *md.ArticleCateDelReq
  61. if err := c.ShouldBindJSON(&req); err != nil {
  62. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  63. return
  64. }
  65. db.Db.In("id", req.Id).Delete(&model.AdvertisingFunction{})
  66. e.OutSuc(c, "success", nil)
  67. return
  68. }
  69. func FunctionSave(c *gin.Context) {
  70. var req *md.AdvertisingFunctionList
  71. if err := c.ShouldBindJSON(&req); err != nil {
  72. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  73. return
  74. }
  75. var data = new(model.AdvertisingFunction)
  76. if utils.StrToInt(req.Id) > 0 {
  77. NewAdvertisingSpaceDb := implement.NewAdvertisingFunctionDb(db.Db)
  78. space, _ := NewAdvertisingSpaceDb.GetAdvertisingFunction(req.Id)
  79. if space == nil {
  80. e.OutErr(c, 400, e.NewErr(400, "记录不存在"))
  81. return
  82. }
  83. data = space
  84. } else {
  85. db.Db.Insert(data)
  86. }
  87. data.Type = req.Type
  88. data.AdId = utils.StrToInt(req.AdId)
  89. db.Db.Where("id=?", data.Id).Update(data)
  90. e.OutSuc(c, "success", nil)
  91. return
  92. }