http.go 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. package http
  2. import (
  3. "go-common/app/admin/main/vip/conf"
  4. "go-common/app/admin/main/vip/service"
  5. "go-common/library/log"
  6. bm "go-common/library/net/http/blademaster"
  7. "go-common/library/net/http/blademaster/middleware/permit"
  8. )
  9. var (
  10. // depend service
  11. vipSvc *service.Service
  12. authSvc *permit.Permit
  13. cf *conf.Config
  14. )
  15. //Init init http
  16. func Init(c *conf.Config) {
  17. cf = c
  18. initService(c)
  19. // init external router
  20. engine := bm.DefaultServer(c.BM)
  21. initRouter(engine)
  22. // init Outer serve
  23. if err := engine.Start(); err != nil {
  24. log.Error("engine.Start error(%v)", err)
  25. panic(err)
  26. }
  27. }
  28. // initService init services.
  29. func initService(c *conf.Config) {
  30. vipSvc = service.New(c)
  31. authSvc = permit.New(c.Auth)
  32. }
  33. // initRouter init outer router api path.
  34. func initRouter(e *bm.Engine) {
  35. e.Ping(moPing)
  36. group := e.Group("/x/admin/vip", authSvc.Verify())
  37. {
  38. monthGroup := group.Group("/month", authSvc.Permit("VIP_MONTH"))
  39. {
  40. monthGroup.GET("/list", monthList)
  41. monthGroup.POST("/edit", monthEdit)
  42. monthGroup.GET("/price/list", priceList)
  43. monthGroup.POST("/price/add", priceAdd)
  44. monthGroup.POST("/price/edit", priceEdit)
  45. }
  46. poolGroup := group.Group("/pool", authSvc.Permit("VIP_POOL"))
  47. {
  48. poolGroup.GET("/list", queryPool)
  49. poolGroup.GET("/info", getPool)
  50. poolGroup.POST("/save", savePool)
  51. batchGroup := poolGroup.Group("/batch")
  52. {
  53. batchGroup.GET("/list", queryBatch)
  54. batchGroup.GET("/info", getBatch)
  55. batchGroup.POST("/add", addBatch)
  56. batchGroup.POST("/edit", saveBatch)
  57. batchGroup.POST("/consume", grantResouce)
  58. }
  59. }
  60. batchCodeGroup := group.Group("/batchCode", authSvc.Permit("VIP_BATCH_CODE"))
  61. {
  62. batchCodeGroup.GET("/list", batchCodes)
  63. batchCodeGroup.POST("/save", saveBatchCode)
  64. batchCodeGroup.POST("/frozen", frozenBatchCode)
  65. batchCodeGroup.GET("/export", exportCodes)
  66. codeGroup := batchCodeGroup.Group("/code")
  67. {
  68. codeGroup.GET("/list", codes)
  69. codeGroup.POST("/frozen", frozenCode)
  70. }
  71. }
  72. pushGroup := group.Group("/push", authSvc.Permit("VIP_PUSH"))
  73. {
  74. pushGroup.GET("/list", pushs)
  75. pushGroup.POST("/save", savePush)
  76. pushGroup.GET("/info", push)
  77. pushGroup.GET("/del", delPush)
  78. pushGroup.GET("/disable", disablePush)
  79. }
  80. vipGroup := group.Group("/user", authSvc.Permit("VIP_USER"))
  81. {
  82. vipGroup.POST("/drawback", drawback)
  83. vipGroup.GET("/log/list", historyList)
  84. vipGroup.GET("/info", vipInfo)
  85. }
  86. bizGroup := group.Group("/biz", authSvc.Permit("VIP_BIZ"))
  87. {
  88. bizGroup.GET("/list", businessList)
  89. bizGroup.POST("/add", addBusiness)
  90. bizGroup.GET("/info", business)
  91. bizGroup.POST("/edit", updateBusiness)
  92. }
  93. verGroup := group.Group("/version", authSvc.Permit("VIP_VERSION"))
  94. {
  95. verGroup.GET("/list", versions)
  96. verGroup.POST("/edit", updateVersion)
  97. }
  98. tipsGroup := group.Group("/tips", authSvc.Permit("VIP_TIPS"))
  99. {
  100. tipsGroup.GET("/list", tips)
  101. tipsGroup.GET("/info", tipbyid)
  102. tipsGroup.POST("/add", tipadd)
  103. tipsGroup.POST("/edit", tipupdate)
  104. tipsGroup.GET("/delete", tipdelete)
  105. tipsGroup.POST("/expire", tipexpire)
  106. }
  107. panelGroup := group.Group("/panel")
  108. {
  109. panelGroup.GET("/conf/types", authSvc.Permit("VIP_PRICE_PANEL"), vipPanelTypes)
  110. panelGroup.GET("/conf/list", authSvc.Permit("VIP_PRICE_PANEL"), vipPriceConfigs)
  111. panelGroup.GET("/conf/info", authSvc.Permit("VIP_PRICE_PANEL"), vipPriceConfigID)
  112. panelGroup.POST("/conf/add", authSvc.Permit("VIP_PRICE_PANEL_CONTROL"), addVipPriceConfig)
  113. panelGroup.POST("/conf/up", authSvc.Permit("VIP_PRICE_PANEL_CONTROL"), upVipPriceConfig)
  114. panelGroup.POST("/conf/del", authSvc.Permit("VIP_PRICE_PANEL_CONTROL"), delVipPriceConfig)
  115. panelGroup.GET("/conf/dprice/list", authSvc.Permit("VIP_PRICE_PANEL"), vipDPriceConfigs)
  116. panelGroup.GET("/conf/dprice/info", authSvc.Permit("VIP_PRICE_PANEL"), vipDPriceConfigID)
  117. panelGroup.POST("/conf/dprice/add", authSvc.Permit("VIP_PRICE_PANEL_CONTROL"), addVipDPriceConfig)
  118. panelGroup.POST("/conf/dprice/up", authSvc.Permit("VIP_PRICE_PANEL_CONTROL"), upVipDPriceConfig)
  119. panelGroup.POST("/conf/dprice/del", authSvc.Permit("VIP_PRICE_PANEL_CONTROL"), delVipDPriceConfig)
  120. }
  121. pgGroup := group.Group("/privilege", authSvc.Permit("VIP_PRIVILEGE"))
  122. {
  123. pgGroup.GET("/list", privileges)
  124. pgGroup.POST("/update/state", updatePrivilegeState)
  125. pgGroup.POST("/delete", deletePrivilege)
  126. pgGroup.POST("/update/order", updateOrder)
  127. pgGroup.POST("/add", addPrivilege)
  128. pgGroup.POST("/modify", updatePrivilege)
  129. }
  130. jointlyGroup := group.Group("/jointly", authSvc.Permit("VIP_JOINTLY"))
  131. {
  132. jointlyGroup.GET("/list", jointlys)
  133. jointlyGroup.POST("/add", addJointly)
  134. jointlyGroup.POST("/modify", modifyJointly)
  135. jointlyGroup.POST("/delete", deleteJointly)
  136. }
  137. refundGroup := group.Group("/order", authSvc.Permit("VIP_ORDER"))
  138. {
  139. refundGroup.GET("/list", orderList)
  140. refundGroup.POST("/refund", authSvc.Permit("VIP_REFUND"), refund)
  141. }
  142. dialogGroup := group.Group("/dialog", authSvc.Permit("VIP_DIALOG"))
  143. {
  144. dialogGroup.GET("/list", dialogList)
  145. dialogGroup.GET("/info", dialogInfo)
  146. dialogGroup.POST("/save", dialogSave)
  147. dialogGroup.POST("/enable", dialogEnable)
  148. dialogGroup.POST("/del", dialogDel)
  149. }
  150. platformGroup := group.Group("/platform", authSvc.Permit("VIP_PLATFORM"))
  151. {
  152. platformGroup.GET("/list", platformList)
  153. platformGroup.GET("/info", platformInfo)
  154. platformGroup.POST("/save", platformSave)
  155. platformGroup.POST("/del", platformDel)
  156. }
  157. welfareGroup := group.Group("/welfare", authSvc.Permit("VIP_WELFARE"))
  158. {
  159. welfareGroup.POST("/type/save", welfareTypeSave)
  160. welfareGroup.POST("/type/state", welfareTypeState)
  161. welfareGroup.GET("/type/list", welfareTypeList)
  162. welfareGroup.POST("/save", welfareSave)
  163. welfareGroup.POST("/state", welfareState)
  164. welfareGroup.GET("/list", welfareList)
  165. welfareGroup.POST("/batch/upload", welfareBatchUpload)
  166. welfareGroup.GET("/batch/list", welfareBatchList)
  167. welfareGroup.POST("/batch/state", welfareBatchState)
  168. }
  169. }
  170. }
  171. func moPing(c *bm.Context) {
  172. vipSvc.Ping(c)
  173. }