publish.go 807 B

1234567891011121314151617181920212223242526272829303132333435
  1. package http
  2. import (
  3. "encoding/json"
  4. "io/ioutil"
  5. "go-common/app/admin/main/macross/model/publish"
  6. "go-common/library/ecode"
  7. "go-common/library/log"
  8. bm "go-common/library/net/http/blademaster"
  9. )
  10. // dashboard get user.
  11. func dashboard(c *bm.Context) {
  12. req := c.Request
  13. bs, err := ioutil.ReadAll(req.Body)
  14. if err != nil {
  15. log.Error("ioutil.ReadAll() error(%v)", err)
  16. c.JSON(nil, ecode.RequestErr)
  17. return
  18. }
  19. req.Body.Close()
  20. // params
  21. var d = &publish.Dashboard{}
  22. if err = json.Unmarshal(bs, d); err != nil {
  23. log.Error("http dashboard() json.Unmarshal(%s) error(%v)", string(bs), err)
  24. c.JSON(nil, ecode.RequestErr)
  25. return
  26. }
  27. if d.Name == "" || d.Label == "" || d.Commit == "" || d.TextSizeArm64 == 0 {
  28. c.JSON(nil, ecode.RequestErr)
  29. return
  30. }
  31. c.JSON(nil, svr.Dashborad(c, d))
  32. }