http.go 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. package http
  2. import (
  3. "go-common/app/admin/main/member/conf"
  4. "go-common/app/admin/main/member/http/block"
  5. "go-common/app/admin/main/member/service"
  6. "go-common/library/ecode"
  7. "go-common/library/log"
  8. bm "go-common/library/net/http/blademaster"
  9. "go-common/library/net/http/blademaster/middleware/permit"
  10. "go-common/library/net/http/blademaster/middleware/verify"
  11. )
  12. var (
  13. authSvc *permit.Permit
  14. vfySvc *verify.Verify
  15. svc *service.Service
  16. )
  17. // Init init
  18. func Init(c *conf.Config) {
  19. initService(c)
  20. // init router
  21. engine := bm.DefaultServer(c.BM)
  22. initRouter(engine)
  23. block.Setup(svc.BlockImpl(), engine, authSvc)
  24. if err := engine.Start(); err != nil {
  25. log.Error("engine.Start error(%v)", err)
  26. panic(err)
  27. }
  28. }
  29. // initService init services.
  30. func initService(c *conf.Config) {
  31. authSvc = permit.New(c.Auth)
  32. vfySvc = verify.New(nil)
  33. svc = service.New(c)
  34. }
  35. // outerRouter init outer router api path.
  36. func initRouter(e *bm.Engine) {
  37. // init api
  38. e.Ping(ping)
  39. e.Register(register)
  40. mg := e.Group("/x/admin/member")
  41. {
  42. mg.GET("/list", authSvc.Permit("ACCOUNT_REVIEW"), members)
  43. mg.POST("/exp/set", authSvc.Permit("ACCOUNT_REVIEW_SET_EXP"), expSet)
  44. mg.POST("/moral/set", authSvc.Permit("ACCOUNT_REVIEW"), moralSet)
  45. mg.POST("/rank/set", authSvc.Permit("ACCOUNT_REVIEW_SET_RANK"), rankSet)
  46. mg.POST("/coin/set", authSvc.Permit("ACCOUNT_REVIEW"), coinSet)
  47. mg.POST("/addit/remark/set", authSvc.Permit("ACCOUNT_REVIEW"), additRemarkSet)
  48. mg.GET("/profile", authSvc.Permit("ACCOUNT_REVIEW"), memberProfile)
  49. mg.GET("/exp/log", authSvc.Permit("ACCOUNT_EXP_LOG"), expLog)
  50. mg.GET("/face/history", authSvc.Permit("ACCOUNT_FACE_HISTORY"), faceHistory)
  51. mg.POST("/batch/formal", authSvc.Permit("ACCOUNT_BATCH_FORMAL"), batchFormal)
  52. mg.GET("/moral/log", moralLog)
  53. mg.POST("/sign/del", delSign)
  54. mg.POST("/pub/exp/msg", authSvc.Permit("ACCOUNT_PUB_EXP_MSG"), pubExpMsg)
  55. //个人信息审核
  56. mg.GET("/base/review", authSvc.Permit("ACCOUNT_REVIEW_AUDIT"), baseReview)
  57. mg.POST("/face/clear", authSvc.Permit("ACCOUNT_REVIEW_AUDIT"), clearFace)
  58. mg.POST("/sign/clear", authSvc.Permit("ACCOUNT_REVIEW_AUDIT"), clearSign)
  59. mg.POST("/name/clear", authSvc.Permit("ACCOUNT_REVIEW_AUDIT"), clearName)
  60. og := mg.Group("/official")
  61. {
  62. og.GET("/list", authSvc.Permit("OFFICIAL_VIEW"), officials)
  63. og.GET("/list/excel", authSvc.Permit("OFFICIAL_VIEW"), officialsExcel)
  64. og.GET("/doc", authSvc.Permit("OFFICIAL_VIEW"), officialDoc)
  65. og.GET("/docs", authSvc.Permit("OFFICIAL_VIEW"), officialDocs)
  66. og.GET("/docs/excel", authSvc.Permit("OFFICIAL_VIEW"), officialDocsExcel)
  67. og.GET("/doc/audit", authSvc.Permit("OFFICIAL_AUDIT"), officialDocAudit)
  68. og.GET("/doc/edit", authSvc.Permit("OFFICIAL_MNG"), officialDocEdit)
  69. ex := og.Group("/internal")
  70. ex.GET("/doc", vfySvc.Verify, officialDoc)
  71. ex.POST("/doc/audit", vfySvc.Verify, officialDocAudit)
  72. ex.POST("/doc/submit", vfySvc.Verify, officialDocSubmit)
  73. }
  74. rw := mg.Group("/review")
  75. {
  76. rw.GET("", authSvc.Permit("ACCOUNT_PROPERTY_REVIEW_AUDIT"), review)
  77. rw.GET("/list", authSvc.Permit("ACCOUNT_PROPERTY_REVIEW_AUDIT"), reviewList)
  78. rw.POST("/audit", authSvc.Permit("ACCOUNT_PROPERTY_REVIEW_AUDIT"), reviewAudit)
  79. rw.GET("/face/list", authSvc.Permit("ACCOUNT_PROPERTY_REVIEW_FACE_AUDIT"), reviewFaceList)
  80. rw.POST("/face/audit", authSvc.Permit("ACCOUNT_PROPERTY_REVIEW_FACE_AUDIT"), reviewAudit)
  81. }
  82. mn := mg.Group("/monitor")
  83. {
  84. mn.GET("/list", authSvc.Permit("ACCOUNT_MONITOR_REVIEW"), monitors)
  85. mn.POST("/add", authSvc.Permit("ACCOUNT_MONITOR_MNG"), addMonitor)
  86. mn.POST("/del", authSvc.Permit("ACCOUNT_MONITOR_MNG"), delMonitor)
  87. }
  88. rn := mg.Group("/realname")
  89. {
  90. rn.GET("/list", authSvc.Permit("REALNAME_QUERY"), realnameList)
  91. rn.GET("/list/pending", authSvc.Permit("REALNAME_AUDIT"), realnamePendingList)
  92. rn.GET("/image", authSvc.Permit("REALNAME_AUDIT"), realnameImage)
  93. rn.GET("/image/preview", realnameImagePreview)
  94. rn.POST("/apply/audit", authSvc.Permit("REALNAME_AUDIT"), realnameAuditApply)
  95. rn.GET("/reason", authSvc.Permit("REALNAME_AUDIT"), realnameReasonList)
  96. rn.POST("/reason/set", authSvc.Permit("REALNAME_SET_REASON"), realnameSetReason)
  97. rn.POST("/search/card", vfySvc.Verify, realnameSearchCard)
  98. rn.POST("/unbind", authSvc.Permit("ACCOUNT_REVIEW"), realnameUnbind)
  99. rn.GET("/excel", authSvc.Permit("REALNAME_EXPORT"), realnameExport)
  100. rn.POST("/file/upload", authSvc.Permit("REALNAME_SUBMIT"), realnameFileUpload)
  101. rn.POST("/submit", authSvc.Permit("REALNAME_SUBMIT"), realnameSubmit)
  102. ex := rn.Group("/internal", vfySvc.Verify)
  103. ex.GET("/list", realnameList)
  104. ex.GET("/list/pending", realnamePendingList)
  105. ex.GET("/image", realnameImage)
  106. ex.GET("/image/preview", realnameImagePreview)
  107. ex.POST("/apply/audit", realnameAuditApply)
  108. ex.GET("/reason", realnameReasonList)
  109. ex.POST("/reason/set", realnameSetReason)
  110. ex.POST("/search/card", realnameSearchCard)
  111. ex.POST("/unbind", realnameUnbind)
  112. ex.GET("/excel", realnameExport)
  113. ex.POST("/file/upload", realnameFileUpload)
  114. ex.POST("/submit", realnameSubmit)
  115. }
  116. }
  117. }
  118. // ping check server ok.
  119. func ping(c *bm.Context) {
  120. if err := svc.Ping(c); err != nil {
  121. log.Error("Failed to ping service: %+v", err)
  122. c.AbortWithStatus(ecode.Cause(err).Code())
  123. return
  124. }
  125. c.AbortWithStatus(200)
  126. }
  127. func register(c *bm.Context) {
  128. c.JSON(nil, nil)
  129. }