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

svc_list.go 2.3 KiB

5 days ago
5 days ago
5 days ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 List(c *gin.Context) {
  12. var req *md.AdvertisingListReq
  13. if err := c.ShouldBindJSON(&req); err != nil {
  14. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  15. return
  16. }
  17. var resp md.AdvertisingListResp
  18. noticeList := make([]md.AdvertisingList, 0)
  19. resp.AdvData = []map[string]string{
  20. {"name": "开屏广告", "value": "1"},
  21. {"name": "插屏广告", "value": "2"},
  22. {"name": "激励视频", "value": "3"},
  23. {"name": "信息流广告", "value": "4"},
  24. {"name": "全屏视频", "value": "5"},
  25. }
  26. resp.SelectData = md.AdvertisingPlatform
  27. NewJpushNoticeDb := implement.NewAdvertisingSpaceDb(db.Db)
  28. notice, total, _ := NewJpushNoticeDb.FindUserFeedbackCateAndTotal(req.Page, req.Limit, req.Name, req.Kind)
  29. resp.Total = total
  30. if notice != nil {
  31. for _, v := range *notice {
  32. tmp := md.AdvertisingList{
  33. Id: utils.IntToStr(v.Id),
  34. CountingDown: utils.IntToStr(v.CountingDown),
  35. Kind: utils.IntToStr(v.Kind),
  36. Info: v.Info,
  37. Name: v.Name,
  38. }
  39. noticeList = append(noticeList, tmp)
  40. }
  41. }
  42. resp.List = noticeList
  43. e.OutSuc(c, resp, nil)
  44. return
  45. }
  46. func Del(c *gin.Context) {
  47. var req *md.ArticleCateDelReq
  48. if err := c.ShouldBindJSON(&req); err != nil {
  49. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  50. return
  51. }
  52. db.Db.In("id", req.Id).Delete(&model.AdvertisingSpace{})
  53. e.OutSuc(c, "success", nil)
  54. return
  55. }
  56. func Save(c *gin.Context) {
  57. var req *md.AdvertisingSaveReq
  58. if err := c.ShouldBindJSON(&req); err != nil {
  59. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  60. return
  61. }
  62. var data = new(model.AdvertisingSpace)
  63. if utils.StrToInt(req.Id) > 0 {
  64. NewAdvertisingSpaceDb := implement.NewAdvertisingSpaceDb(db.Db)
  65. space, _ := NewAdvertisingSpaceDb.GetAdvertisingSpace(req.Id)
  66. if space == nil {
  67. e.OutErr(c, 400, e.NewErr(400, "记录不存在"))
  68. return
  69. }
  70. data = space
  71. } else {
  72. db.Db.Insert(data)
  73. }
  74. data.Name = req.Name
  75. data.Info = req.Info
  76. data.Kind = utils.StrToInt(req.Kind)
  77. data.CountingDown = utils.StrToInt(req.CountingDown)
  78. db.Db.Where("id=?", data.Id).Update(data)
  79. e.OutSuc(c, "success", nil)
  80. return
  81. }