bubble.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package http
  2. import (
  3. "time"
  4. "go-common/library/log"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. func syncBubbleMetaTask(c *bm.Context) {
  8. v := new(struct {
  9. Date string `form:"date" validate:"required"`
  10. })
  11. if err := c.Bind(v); err != nil {
  12. return
  13. }
  14. t, err := time.ParseInLocation("2006-01-02", v.Date, time.Local)
  15. if err != nil {
  16. log.Error("syncBubbleMetaTask date error(date:%s)", v.Date)
  17. return
  18. }
  19. err = svr.SyncIncomeBubbleMetaTask(c, t)
  20. if err != nil {
  21. log.Error("svr.SyncIncomeBubbleMetaTask error(%v)", err)
  22. }
  23. c.JSON(nil, err)
  24. }
  25. func syncBubbleMeta(c *bm.Context) {
  26. v := new(struct {
  27. Start string `form:"start" validate:"required"`
  28. End string `form:"end" validate:"required"`
  29. BType int `form:"b_type" validate:"required"`
  30. })
  31. if err := c.Bind(v); err != nil {
  32. return
  33. }
  34. start, err := time.ParseInLocation("2006-01-02", v.Start, time.Local)
  35. if err != nil {
  36. log.Error("syncBubbleMeta date error(date:%s)", v.Start)
  37. return
  38. }
  39. end, err := time.ParseInLocation("2006-01-02", v.End, time.Local)
  40. if err != nil {
  41. log.Error("syncBubbleMeta date error(date:%s)", v.End)
  42. return
  43. }
  44. rows, err := svr.SyncIncomeBubbleMeta(c, start, end, v.BType)
  45. if err != nil {
  46. log.Error("svr.SyncIncomeBubbleMeta arg(%v) error(%v)", v, err)
  47. }
  48. c.JSON(rows, err)
  49. }
  50. func snapshotBubbleTask(c *bm.Context) {
  51. v := new(struct {
  52. Date string `form:"date" validate:"required"`
  53. })
  54. if err := c.Bind(v); err != nil {
  55. return
  56. }
  57. t, err := time.ParseInLocation("2006-01-02", v.Date, time.Local)
  58. if err != nil {
  59. log.Error("snapshotBubbleTask date error(date:%s)", v.Date)
  60. return
  61. }
  62. err = svr.SnapshotBubbleIncomeTask(c, t)
  63. if err != nil {
  64. log.Error("svr.SnapshotBubbleIncomeTask error(%v)", err)
  65. }
  66. c.JSON(nil, err)
  67. }