http.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. package http
  2. import (
  3. "go-common/app/admin/main/activity/conf"
  4. "go-common/app/admin/main/activity/service"
  5. "go-common/app/admin/main/activity/service/kfc"
  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. actSrv *service.Service
  12. authSrv *permit.Permit
  13. kfcSrv *kfc.Service
  14. )
  15. // Init init http sever instance.
  16. func Init(c *conf.Config, s *service.Service) {
  17. actSrv = s
  18. kfcSrv = kfc.New(c)
  19. authSrv = permit.New(c.Auth)
  20. engine := bm.DefaultServer(c.HTTPServer)
  21. route(engine)
  22. if err := engine.Start(); err != nil {
  23. log.Error("httpx.Serve error(%v)", err)
  24. panic(err)
  25. }
  26. }
  27. func route(e *bm.Engine) {
  28. e.Ping(ping)
  29. g := e.Group("/x/admin/activity")
  30. {
  31. g.GET("/arcs", archives)
  32. gapp := g.Group("/matchs", authSrv.Permit("ACT_MATCHS_MGT_TEST"))
  33. {
  34. gapp.POST("/add", addMatch)
  35. gapp.POST("/save", saveMatch)
  36. gapp.GET("/info", matchInfo)
  37. gapp.GET("/list", matchList)
  38. }
  39. gappO := g.Group("/matchs/object", authSrv.Permit("ACT_MATCHS_MGT_TEST"))
  40. {
  41. gappO.POST("/add", addMatchObject)
  42. gappO.POST("/save", saveMatchObject)
  43. gappO.GET("/info", matchObjectInfo)
  44. gappO.GET("/list", matchObjectList)
  45. }
  46. gappSuject := g.Group("/subject")
  47. {
  48. gappSuject.GET("/list", listInfosAll)
  49. gappSuject.GET("/videos", videoList)
  50. gappSuject.POST("/add", addActSubject)
  51. gappSuject.POST("/up", updateInfoAll)
  52. gappSuject.GET("/protocol", subPro)
  53. gappSuject.GET("/conf", timeConf)
  54. gappSuject.GET("/articles", article)
  55. }
  56. gappLikes := g.Group("/likes")
  57. {
  58. gappLikes.GET("/list", likesList)
  59. gappLikes.GET("/lids", likes)
  60. gappLikes.POST("/add", addLike)
  61. gappLikes.POST("/up", upLike)
  62. gappLikes.POST("/up/reply", upListContent)
  63. gappLikes.POST("/up/wid", upWid)
  64. gappLikes.POST("/add/pic", addPic)
  65. gappLikes.POST("/batch/wid", batchLikes)
  66. }
  67. gappKfc := g.Group("kfc")
  68. {
  69. gappKfc.GET("/list", kfcList)
  70. }
  71. gappBws := g.Group("/bws")
  72. {
  73. gappBws.POST("/add", addBws)
  74. gappBws.POST("/save", saveBws)
  75. gappBws.GET("/info", bwsInfo)
  76. gappBws.GET("/list", bwsList)
  77. gappAchievement := gappBws.Group("/achievement")
  78. {
  79. gappAchievement.POST("/add", addBwsAchievement)
  80. gappAchievement.POST("/save", saveBwsAchievement)
  81. gappAchievement.GET("/info", bwsAchievement)
  82. gappAchievement.GET("/list", bwsAchievements)
  83. }
  84. gappField := gappBws.Group("/field")
  85. {
  86. gappField.POST("/add", addBwsField)
  87. gappField.POST("/save", saveBwsField)
  88. gappField.GET("/info", bwsField)
  89. gappField.GET("/list", bwsFields)
  90. }
  91. gappPoint := gappBws.Group("/point")
  92. {
  93. gappPoint.POST("/add", addBwsPoint)
  94. gappPoint.POST("/save", saveBwsPoint)
  95. gappPoint.GET("/info", bwsPoint)
  96. gappPoint.GET("/list", bwsPoints)
  97. }
  98. gappUser := gappBws.Group("/user")
  99. {
  100. gappUser.POST("/add", addBwsUser)
  101. gappUser.POST("/save", saveBwsUser)
  102. gappUser.GET("/info", bwsUser)
  103. gappUser.GET("/list", bwsUsers)
  104. gappUserAchievement := gappUser.Group("/achievement")
  105. {
  106. gappUserAchievement.POST("/add", addBwsUserAchievement)
  107. gappUserAchievement.POST("/save", saveBwsUserAchievement)
  108. gappUserAchievement.GET("/info", bwsUserAchievement)
  109. gappUserAchievement.GET("/list", bwsUserAchievements)
  110. }
  111. gappUserPoint := gappUser.Group("/point")
  112. {
  113. gappUserPoint.POST("/add", addBwsUserPoint)
  114. gappUserPoint.POST("/save", saveBwsUserPoint)
  115. gappUserPoint.GET("/info", bwsUserPoint)
  116. gappUserPoint.GET("/list", bwsUserPoints)
  117. }
  118. }
  119. }
  120. }
  121. }
  122. func ping(c *bm.Context) {
  123. if err := actSrv.Ping(c); err != nil {
  124. c.Error = err
  125. c.AbortWithStatus(503)
  126. }
  127. }