video.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package http
  2. import (
  3. "encoding/json"
  4. "go-common/app/interface/main/creative/model/app"
  5. "go-common/library/ecode"
  6. "go-common/library/log"
  7. bm "go-common/library/net/http/blademaster"
  8. "go-common/library/net/metadata"
  9. "io/ioutil"
  10. "strconv"
  11. "strings"
  12. )
  13. func coverList(c *bm.Context) {
  14. params := c.Request.Form
  15. fnsStr := params.Get("fns")
  16. midI, ok := c.Get("mid")
  17. if !ok {
  18. c.JSON(nil, ecode.NoLogin)
  19. return
  20. }
  21. mid, _ := midI.(int64)
  22. cvs, err := dataSvc.Covers(c, mid, strings.Split(fnsStr, ","), metadata.String(c, metadata.RemoteIP))
  23. if err != nil {
  24. log.Error(" arcSvc.CoverList fnsStr(%s), mid(%d), ip(%s) error(%v)", fnsStr, mid, metadata.String(c, metadata.RemoteIP), err)
  25. c.JSON(nil, ecode.RequestErr)
  26. return
  27. }
  28. c.JSON(cvs, nil)
  29. }
  30. func uploadMaterial(c *bm.Context) {
  31. req := c.Request
  32. params := req.Form
  33. var (
  34. err error
  35. aid int64
  36. bs []byte
  37. )
  38. aidStr := params.Get("aid")
  39. if aid, err = strconv.ParseInt(aidStr, 10, 64); err != nil {
  40. log.Error("strconv.ParseInt(%s) error(%v)", aidStr, err)
  41. c.JSON(nil, ecode.RequestErr)
  42. return
  43. }
  44. if bs, err = ioutil.ReadAll(req.Body); err != nil {
  45. log.Error("ioutil.ReadAll() error(%v)", err)
  46. c.JSON(nil, ecode.RequestErr)
  47. return
  48. }
  49. req.Body.Close()
  50. var editors = &[]*app.Editor{}
  51. if err = json.Unmarshal(bs, editors); err != nil {
  52. log.Error("uploadMaterial json.Unmarshal(%s) error(%v)", string(bs), err)
  53. c.JSON(nil, ecode.RequestErr)
  54. return
  55. }
  56. c.JSON(appSvc.UploadMaterial(c, aid, *editors), nil)
  57. }