report.go 946 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package http
  2. import (
  3. "time"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. func memberStats(c *bm.Context) {
  8. c.JSON(srv.GetStats(c))
  9. }
  10. func taskTooks(c *bm.Context) {
  11. req := c.Request
  12. params := req.Form
  13. stimeStr := params.Get("stime")
  14. etimeStr := params.Get("etime")
  15. if stimeStr == "" {
  16. stimeStr = time.Now().Format("2006-01-02") + " 00:00:00"
  17. }
  18. if etimeStr == "" {
  19. etimeStr = time.Now().Format("2006-01-02 15:04:05")
  20. }
  21. local, _ := time.LoadLocation("Local")
  22. stime, err := time.ParseInLocation("2006-01-02 15:04:05", stimeStr, local)
  23. if stime.Unix() < 1 || err != nil {
  24. c.JSON(nil, ecode.RequestErr)
  25. return
  26. }
  27. etime, err := time.ParseInLocation("2006-01-02 15:04:05", etimeStr, local)
  28. if etime.Unix() < 1 || err != nil {
  29. c.JSON(nil, ecode.RequestErr)
  30. return
  31. }
  32. tooks, err := srv.TaskTooksByHalfHour(c, stime, etime)
  33. if err != nil {
  34. c.JSON(nil, err)
  35. return
  36. }
  37. c.JSON(tooks, nil)
  38. }