upload.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package http
  2. import (
  3. "go-common/app/interface/bbq/app-bbq/api/http/v1"
  4. "go-common/library/ecode"
  5. "go-common/library/log"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. func upload(c *bm.Context) {
  9. mid, exists := c.Get("mid")
  10. if !exists {
  11. c.JSON(nil, ecode.NoLogin)
  12. return
  13. }
  14. arg := new(v1.ImgUploadRequest)
  15. if err := c.Bind(arg); err != nil {
  16. c.JSON(nil, ecode.ReqParamErr)
  17. return
  18. }
  19. c.JSON(srv.Upload(c, mid.(int64), arg.Type))
  20. }
  21. func perUpload(c *bm.Context) {
  22. mid, exists := c.Get("mid")
  23. if !exists {
  24. c.JSON(nil, ecode.NoLogin)
  25. return
  26. }
  27. req := new(v1.PreUploadRequest)
  28. if err := c.Bind(req); err != nil {
  29. log.Errorw(c, "event", "bind param err")
  30. return
  31. }
  32. c.JSON(srv.PreUpload(c, req, mid.(int64)))
  33. }
  34. func callBack(c *bm.Context) {
  35. mid, exists := c.Get("mid")
  36. if !exists {
  37. c.JSON(nil, ecode.NoLogin)
  38. return
  39. }
  40. req := new(v1.CallBackRequest)
  41. if err := c.Bind(req); err != nil {
  42. log.Errorw(c, "event", "bind param err", err, "err")
  43. return
  44. }
  45. c.JSON(srv.CallBack(c, req, mid.(int64)))
  46. }
  47. func uploadCheck(c *bm.Context) {
  48. tmp, exists := c.Get("mid")
  49. if !exists || tmp.(int64) == 0 {
  50. c.JSON(nil, ecode.NoLogin)
  51. return
  52. }
  53. c.JSON(srv.VideoUploadCheck(c, tmp.(int64)))
  54. }
  55. func homeimg(c *bm.Context) {
  56. mid, exists := c.Get("mid")
  57. if !exists {
  58. c.JSON(nil, ecode.NoLogin)
  59. return
  60. }
  61. req := new(v1.HomeImgRequest)
  62. if err := c.Bind(req); err != nil {
  63. log.Errorw(c, "event", "bind param err", err, "err")
  64. return
  65. }
  66. c.JSON(srv.HomeImg(c, req, mid.(int64)))
  67. }