push.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package http
  2. import (
  3. "go-common/app/admin/main/vip/model"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. func pushs(c *bm.Context) {
  8. arg := new(model.ArgPushData)
  9. if err := c.Bind(arg); err != nil {
  10. return
  11. }
  12. res, count, err := vipSvc.PushDatas(c, arg)
  13. result := make(map[string]interface{})
  14. result["data"] = res
  15. result["total"] = count
  16. c.JSON(result, err)
  17. }
  18. func push(c *bm.Context) {
  19. arg := new(model.ArgID)
  20. if err := c.Bind(arg); err != nil {
  21. return
  22. }
  23. c.JSON(vipSvc.GetPushData(c, arg.ID))
  24. }
  25. func disablePush(c *bm.Context) {
  26. arg := new(model.ArgID)
  27. if err := c.Bind(arg); err != nil {
  28. return
  29. }
  30. c.JSON(nil, vipSvc.DisablePushData(c, arg.ID))
  31. }
  32. func delPush(c *bm.Context) {
  33. arg := new(model.ArgID)
  34. if err := c.Bind(arg); err != nil {
  35. return
  36. }
  37. c.JSON(nil, vipSvc.DelPushData(c, arg.ID))
  38. }
  39. func savePush(c *bm.Context) {
  40. arg := new(model.VipPushData)
  41. username, ok := c.Get("username")
  42. if !ok {
  43. c.JSON(nil, ecode.AccessDenied)
  44. return
  45. }
  46. if err := c.Bind(arg); err != nil {
  47. return
  48. }
  49. arg.Operator = username.(string)
  50. c.JSON(nil, vipSvc.SavePushData(c, arg))
  51. }