archive.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package http
  2. import (
  3. "time"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. //moveType get archive move type stats api
  8. func moveType(c *bm.Context) {
  9. req := c.Request
  10. param := req.Form
  11. stimeStr := param.Get("stime")
  12. etimeStr := param.Get("etime")
  13. if stimeStr == "" {
  14. stimeStr = time.Now().Format("2006-01-02") + " 00:00:00"
  15. }
  16. if etimeStr == "" {
  17. etimeStr = time.Now().Format("2006-01-02") + " 00:00:00"
  18. }
  19. local, _ := time.LoadLocation("Local")
  20. stime, err := time.ParseInLocation("2006-01-02 15:04:05", stimeStr, local)
  21. if stime.Unix() < 1 || err != nil {
  22. c.JSON(nil, ecode.RequestErr)
  23. return
  24. }
  25. etime, err := time.ParseInLocation("2006-01-02 15:04:05", etimeStr, local)
  26. if etime.Unix() < 1 || err != nil {
  27. c.JSONMap(map[string]interface{}{"message": err.Error()}, ecode.RequestErr)
  28. return
  29. }
  30. c.JSON(vdaSvc.MoveType(c, stime, etime))
  31. }
  32. // roundFlow get archive round flow stats api
  33. func roundFlow(c *bm.Context) {
  34. req := c.Request
  35. param := req.Form
  36. stimeStr := param.Get("stime")
  37. etimeStr := param.Get("etime")
  38. if stimeStr == "" {
  39. stimeStr = time.Now().Format("2006-01-02") + " 00:00:00"
  40. }
  41. if etimeStr == "" {
  42. etimeStr = time.Now().Format("2006-01-02") + " 00:00:00"
  43. }
  44. local, _ := time.LoadLocation("Local")
  45. stime, err := time.ParseInLocation("2006-01-02 15:04:05", stimeStr, local)
  46. if stime.Unix() < 1 || err != nil {
  47. c.JSON(nil, ecode.RequestErr)
  48. return
  49. }
  50. etime, err := time.ParseInLocation("2006-01-02 15:04:05", etimeStr, local)
  51. if etime.Unix() < 1 || err != nil {
  52. c.JSONMap(map[string]interface{}{"message": err.Error()}, ecode.RequestErr)
  53. return
  54. }
  55. c.JSON(vdaSvc.RoundFlow(c, stime, etime))
  56. }