http.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package http
  2. import (
  3. "net/http"
  4. "go-common/app/admin/main/mcn/conf"
  5. "go-common/app/admin/main/mcn/service"
  6. "go-common/library/log"
  7. bm "go-common/library/net/http/blademaster"
  8. "go-common/library/net/http/blademaster/middleware/permit"
  9. )
  10. var (
  11. srv *service.Service
  12. authSvc *permit.Permit
  13. )
  14. // Init init
  15. func Init(c *conf.Config) {
  16. initService(c)
  17. engine := bm.DefaultServer(c.BM)
  18. route(engine)
  19. if err := engine.Start(); err != nil {
  20. log.Error("bm Start error(%v)", err)
  21. panic(err)
  22. }
  23. }
  24. // initService init service
  25. func initService(c *conf.Config) {
  26. srv = service.New(c)
  27. authSvc = permit.New(c.Auth)
  28. }
  29. func route(e *bm.Engine) {
  30. e.Ping(ping)
  31. e.Register(register)
  32. g := e.Group("/allowance/api/x/admin/mcn") // authSvc.Verify() manager use
  33. {
  34. // mcn account .
  35. g.POST("/sign/upload", upload)
  36. g.POST("/sign/entry", mcnSignEntry)
  37. g.GET("/sign/list", mcnSignList)
  38. g.POST("/sign/op", mcnSignOP)
  39. g.GET("/sign/up/list", mcnUPReviewList)
  40. g.POST("/sign/up/op", mcnUPOP)
  41. g.POST("/sign/permit/op", mcnPermitOP)
  42. g.GET("/sign/up/permit/list", mcnUPPermitList)
  43. g.POST("/sign/up/permit/op", mcnUPPermitOP)
  44. // mcn list.
  45. g.GET("/list", mcnList)
  46. // g.POST("/pay/add", mcnPayAdd)
  47. g.POST("/pay/edit", mcnPayEdit)
  48. g.POST("/pay/state/edit", mcnPayStateEdit)
  49. g.POST("/state/edit", mcnStateEdit)
  50. g.POST("/renewal", mcnRenewal)
  51. // up list
  52. g.GET("/info", mcnInfo)
  53. g.GET("/up/list", mcnUPList)
  54. g.POST("/up/state/edit", mcnUPStatEdit)
  55. // 二期
  56. g.GET("/cheat/list", mcnCheatList)
  57. g.GET("/cheat/up/list", mcnCheatUPList)
  58. g.GET("/import/up/info", mcnImportUPInfo)
  59. g.POST("/import/up/reward/sign", mcnImportUPRewardSign)
  60. g.GET("/increase/list", mcnIncreaseList)
  61. // up fans rank
  62. g.GET("/rank/archive/likes", arcTopDataStatistics)
  63. // up fans analyze
  64. g.GET("/up/fans/analyze", mcnFansAnalyze)
  65. // mcn total statistics
  66. g.GET("/total/statistics", mcnsTotalDatas)
  67. // up recommend
  68. g.GET("/recommend/list", recommendList)
  69. g.POST("/recommend/op", recommendOP)
  70. g.POST("/recommend/add", recommendAdd)
  71. }
  72. }
  73. func ping(c *bm.Context) {
  74. if err := srv.Ping(c); err != nil {
  75. log.Error("ping error(%v)", err)
  76. c.AbortWithStatus(http.StatusServiceUnavailable)
  77. }
  78. }
  79. func register(c *bm.Context) {
  80. c.JSON(map[string]interface{}{}, nil)
  81. }