platform.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 platformList(c *bm.Context) {
  8. arg := new(struct {
  9. Order string `form:"order" default:"desc"`
  10. // PN int `form:"pn" default:"1"`
  11. // PS int `form:"ps" default:"20"`
  12. })
  13. if err := c.Bind(arg); err != nil {
  14. return
  15. }
  16. c.JSON(vipSvc.PlatformAll(c, arg.Order))
  17. }
  18. func platformInfo(c *bm.Context) {
  19. arg := new(model.ArgID)
  20. if err := c.Bind(arg); err != nil {
  21. return
  22. }
  23. c.JSON(vipSvc.PlatformByID(c, arg))
  24. }
  25. func platformSave(c *bm.Context) {
  26. arg := new(model.ConfPlatform)
  27. if err := c.Bind(arg); err != nil {
  28. return
  29. }
  30. username, ok := c.Get("username")
  31. if !ok {
  32. c.JSON(nil, ecode.AccessDenied)
  33. return
  34. }
  35. // platform:必填,可选项为:android、ios、web、public
  36. if _, ok := model.PlatformMap[arg.Platform]; !ok {
  37. c.JSON(nil, ecode.RequestErr)
  38. return
  39. }
  40. arg.Operator = username.(string)
  41. c.JSON(vipSvc.PlatformSave(c, arg))
  42. }
  43. func platformDel(c *bm.Context) {
  44. arg := new(model.ArgID)
  45. if err := c.Bind(arg); err != nil {
  46. return
  47. }
  48. username, ok := c.Get("username")
  49. if !ok {
  50. c.JSON(nil, ecode.AccessDenied)
  51. return
  52. }
  53. c.JSON(vipSvc.PlatformDel(c, arg, username.(string)))
  54. }