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

3 weeks ago
1 week ago
3 weeks ago
3 weeks ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. {"name": "短视频", "value": "6"},
  26. {"name": "短剧", "value": "7"},
  27. }
  28. resp.SelectData = md.AdvertisingPlatform
  29. NewJpushNoticeDb := implement.NewAdvertisingSpaceDb(db.Db)
  30. notice, total, _ := NewJpushNoticeDb.FindUserFeedbackCateAndTotal(req.Page, req.Limit, req.Name, req.Kind)
  31. resp.Total = total
  32. if notice != nil {
  33. for _, v := range *notice {
  34. tmp := md.AdvertisingList{
  35. Id: utils.IntToStr(v.Id),
  36. CountingDown: utils.IntToStr(v.CountingDown),
  37. Kind: utils.IntToStr(v.Kind),
  38. Info: v.Info,
  39. Name: v.Name,
  40. }
  41. noticeList = append(noticeList, tmp)
  42. }
  43. }
  44. resp.List = noticeList
  45. e.OutSuc(c, resp, nil)
  46. return
  47. }
  48. func Del(c *gin.Context) {
  49. var req *md.ArticleCateDelReq
  50. if err := c.ShouldBindJSON(&req); err != nil {
  51. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  52. return
  53. }
  54. db.Db.In("id", req.Id).Delete(&model.AdvertisingSpace{})
  55. e.OutSuc(c, "success", nil)
  56. return
  57. }
  58. func Save(c *gin.Context) {
  59. var req *md.AdvertisingSaveReq
  60. if err := c.ShouldBindJSON(&req); err != nil {
  61. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  62. return
  63. }
  64. var data = new(model.AdvertisingSpace)
  65. if utils.StrToInt(req.Id) > 0 {
  66. NewAdvertisingSpaceDb := implement.NewAdvertisingSpaceDb(db.Db)
  67. space, _ := NewAdvertisingSpaceDb.GetAdvertisingSpace(req.Id)
  68. if space == nil {
  69. e.OutErr(c, 400, e.NewErr(400, "记录不存在"))
  70. return
  71. }
  72. data = space
  73. } else {
  74. db.Db.Insert(data)
  75. }
  76. data.Name = req.Name
  77. data.Info = req.Info
  78. data.Kind = utils.StrToInt(req.Kind)
  79. data.CountingDown = utils.StrToInt(req.CountingDown)
  80. db.Db.Where("id=?", data.Id).Update(data)
  81. e.OutSuc(c, "success", nil)
  82. return
  83. }