up_stat.go 989 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package http
  2. import (
  3. "fmt"
  4. "go-common/app/service/main/up/service"
  5. "go-common/library/ecode"
  6. "go-common/library/log"
  7. bm "go-common/library/net/http/blademaster"
  8. )
  9. func baseStat(c *bm.Context) {
  10. var arg = new(struct {
  11. Mid int64 `form:"mid" validate:"required"`
  12. Date string `form:"date" validate:"required"`
  13. })
  14. var res interface{}
  15. var err error
  16. var errMsg string
  17. switch {
  18. default:
  19. if err = c.Bind(arg); err != nil {
  20. log.Error("request argument bind fail, err=%v", err)
  21. errMsg = fmt.Sprintf("wrong argument, %s", err.Error())
  22. err = ecode.RequestErr
  23. break
  24. }
  25. var date = arg.Date
  26. var mid = arg.Mid
  27. var d, e = Svc.Data.BaseUpStat(c, mid, date)
  28. err = e
  29. if err != nil {
  30. log.Error("get hbase fail, mid=%d, err=%v", mid, err)
  31. return
  32. }
  33. log.Info("get from hbase ok, mid=%d, stat=%+v", mid, d)
  34. res = map[string]interface{}{
  35. "stat": d,
  36. }
  37. }
  38. if err != nil {
  39. service.BmHTTPErrorWithMsg(c, err, errMsg)
  40. } else {
  41. c.JSON(res, err)
  42. }
  43. }