playurl.go 897 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package http
  2. import (
  3. "go-common/app/interface/main/player/model"
  4. "go-common/library/ecode"
  5. "go-common/library/log"
  6. "go-common/library/net/http/blademaster"
  7. )
  8. func playurl(c *blademaster.Context) {
  9. var (
  10. mid int64
  11. err error
  12. )
  13. arg := new(model.PlayurlArg)
  14. if err = c.Bind(arg); err != nil {
  15. return
  16. }
  17. if midInter, ok := c.Get("mid"); ok {
  18. mid = midInter.(int64)
  19. }
  20. if arg.OType == "" {
  21. arg.OType = model.OtypeXML
  22. }
  23. if arg.OType != model.OtypeXML && arg.OType != model.OtypeJSON {
  24. c.JSON(nil, ecode.RequestErr)
  25. return
  26. }
  27. if arg.Player != 0 && arg.Player != 1 {
  28. c.JSON(nil, ecode.RequestErr)
  29. return
  30. }
  31. if arg.Player == 1 && arg.OType == model.OtypeXML {
  32. log.Warn("playurl warn arg(%+v)", arg)
  33. c.JSON(nil, ecode.RequestErr)
  34. return
  35. }
  36. if arg.OType == model.OtypeJSON {
  37. c.JSON(playSvr.Playurl(c, mid, arg))
  38. } else {
  39. c.XML(playSvr.Playurl(c, mid, arg))
  40. }
  41. }