auth.go 893 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package http
  2. import (
  3. bm "go-common/library/net/http/blademaster"
  4. )
  5. func loadEP(c *bm.Context) {
  6. // bind
  7. v := new(struct {
  8. EPID int64 `form:"epid" validate:"required,min=1"`
  9. Build int64 `form:"build"`
  10. })
  11. if err := c.Bind(v); err != nil {
  12. return
  13. }
  14. // take cache and distinguish the error msg
  15. if isok, errMsg, err := tvSvc.EpMsg(v.EPID, v.Build); err != nil {
  16. c.JSON(nil, err)
  17. } else {
  18. c.JSONMap(map[string]interface{}{
  19. "data": isok,
  20. "message": errMsg,
  21. }, nil)
  22. }
  23. }
  24. func loadVideo(c *bm.Context) {
  25. // bind
  26. v := new(struct {
  27. CID int64 `form:"cid" validate:"required,min=1"`
  28. })
  29. if err := c.Bind(v); err != nil {
  30. return
  31. }
  32. // take cache and distinguish the error msg
  33. if isok, errMsg, err := viewSvc.VideoMsg(c, v.CID); err != nil {
  34. c.JSON(nil, err)
  35. } else {
  36. c.JSONMap(map[string]interface{}{
  37. "data": isok,
  38. "message": errMsg,
  39. }, nil)
  40. }
  41. }