http.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. package http
  2. import (
  3. "net/http"
  4. "go-common/app/job/main/growup/conf"
  5. "go-common/app/job/main/growup/service"
  6. "go-common/app/job/main/growup/service/charge"
  7. "go-common/app/job/main/growup/service/ctrl"
  8. "go-common/app/job/main/growup/service/income"
  9. "go-common/app/job/main/growup/service/tag"
  10. "go-common/library/log"
  11. bm "go-common/library/net/http/blademaster"
  12. )
  13. var (
  14. executor *ctrl.UnboundedExecutor
  15. svr *service.Service
  16. tagSvr *tag.Service
  17. incomeSrv *income.Service
  18. chargeSrv *charge.Service
  19. )
  20. // Init init
  21. func Init(c *conf.Config) {
  22. // service
  23. executor = ctrl.NewUnboundedExecutor()
  24. svr = service.New(c, executor)
  25. tagSvr = tag.New(c, executor)
  26. incomeSrv = income.New(c, executor)
  27. chargeSrv = charge.New(c, executor)
  28. // bm
  29. engine := bm.DefaultServer(c.BM)
  30. initRouter(engine)
  31. if err := engine.Start(); err != nil {
  32. log.Error("engine.Start error(%v)", err)
  33. panic(err)
  34. }
  35. }
  36. // Close close service
  37. func Close() {
  38. svr.Close()
  39. tagSvr.Close()
  40. }
  41. func initRouter(e *bm.Engine) {
  42. e.Ping(ping)
  43. mr := e.Group("/x/internal/job/growup")
  44. tag := mr.Group("tag")
  45. {
  46. tag.POST("/income", tagIncome)
  47. tag.POST("/archive/ratio", tagRatio)
  48. tag.POST("/ups", tagUps)
  49. tag.POST("/extra", tagExtraIncome)
  50. }
  51. mr.GET("/email/combine", combineMails)
  52. mr.GET("/email/tagincome", sendTagIncome)
  53. mr.POST("/blacklist/init/mid", initBlacklistMID)
  54. mr.POST("/blacklist/update", updateBlacklist)
  55. mr.POST("/data/update/withdraw", updateWithdraw)
  56. mr.GET("/data/up/income/statis", getUpIncomeStatis)
  57. mr.GET("/data/av/income/statis", getAvIncomeStatis)
  58. mr.GET("/cheat", updateCheat)
  59. mr.POST("/data/fix/tag", updateTagIncome)
  60. mr.POST("/data/fix/upincome", fixUpIncome)
  61. mr.POST("/data/fix/up/av/statis", fixUpAvStatis)
  62. mr.POST("/data/fix/tag/adjust", fixTagAdjust)
  63. mr.POST("/data/fix/income", fixIncome)
  64. mr.POST("/data/fix/account/type", fixAccountType)
  65. mr.POST("/data/fix/upaccount", fixUpAccount)
  66. mr.POST("/data/fix/baseincome", fixBaseIncome)
  67. mr.POST("/data/fix/av/breach", fixAvBreach)
  68. mr.POST("/data/fix/up/totalincome", fixUpTotalIncome)
  69. mr.POST("/data/fix/up/business", updateBusinessIncome)
  70. mr.POST("/data/up/sync/pgc", syncUpPGC)
  71. mr.POST("/data/up/sync/avbaseincome", syncAvBaseIncome)
  72. mr.POST("/data/column/tag", updateColumnTag)
  73. mr.POST("/data/del", delDataLimit)
  74. creative := mr.Group("/creative")
  75. {
  76. creative.POST("/income", creativeIncome)
  77. creative.POST("/charge", creativeCharge)
  78. creative.POST("/statis", creativeStatis)
  79. creative.POST("/bill", creativeBill)
  80. creative.POST("/budget", creativeBudget)
  81. creative.POST("/activity", creativeActivity)
  82. }
  83. mr.POST("/up/info/update", updateUpInfoVideo)
  84. mr.POST("/credit/sync", syncCreditScore)
  85. mr.POST("/bgm/sync", syncBGM)
  86. mr.POST("/bgm/statis", calBgmStatis)
  87. mr.POST("/bgm/base", calBgmBaseIncome)
  88. mr.POST("/sync/account", syncUpAccount)
  89. auto := mr.Group("/auto")
  90. {
  91. auto.POST("/archive/breach", autoBreach)
  92. auto.POST("/up/punish", autoPunish)
  93. auto.POST("/up/examination", autoExamination)
  94. }
  95. taskStatus := mr.Group("/task")
  96. {
  97. taskStatus.POST("/status", updateTaskStatus)
  98. taskStatus.POST("/column", checkTaskColumn)
  99. }
  100. incomeAdjust := mr.Group("/income_bubble")
  101. {
  102. incomeAdjust.POST("/meta/sync", syncBubbleMeta)
  103. incomeAdjust.POST("/task/meta", syncBubbleMetaTask)
  104. incomeAdjust.POST("/task/snapshot", snapshotBubbleTask)
  105. }
  106. // delete
  107. mr.GET("/avratio", execAvRatio)
  108. mr.GET("/income", execIncome)
  109. }
  110. // ping check server ok.
  111. func ping(c *bm.Context) {
  112. if err := svr.Ping(c); err != nil {
  113. log.Error("service ping error(%v)", err)
  114. c.AbortWithStatus(http.StatusServiceUnavailable)
  115. }
  116. }