http.go 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package http
  2. import (
  3. "go-common/app/service/openplatform/anti-fraud/conf"
  4. "go-common/app/service/openplatform/anti-fraud/service"
  5. "go-common/library/log"
  6. bm "go-common/library/net/http/blademaster"
  7. "go-common/library/net/http/blademaster/middleware/verify"
  8. "net/http"
  9. )
  10. var (
  11. vfySvc *verify.Verify
  12. svc *service.Service
  13. )
  14. // Init init
  15. func Init(c *conf.Config) {
  16. initService(c)
  17. // init router
  18. engine := bm.DefaultServer(nil)
  19. innerRouter(engine)
  20. if err := engine.Start(); err != nil {
  21. log.Error("engine.Start error(%v)", err)
  22. panic(err)
  23. }
  24. }
  25. // initService init services.
  26. func initService(c *conf.Config) {
  27. vfySvc = verify.New(nil)
  28. svc = service.New(c)
  29. }
  30. // innerRouter init inner router api path.
  31. func innerRouter(e *bm.Engine) {
  32. e.Ping(ping)
  33. //group := e.Group("/openplatform/internal/anti/fraud",idfSvc.Verify)
  34. group := e.Group("/openplatform/internal/antifraud")
  35. {
  36. group.GET("/qusb/info", qusBankInfo) //题库单条信息
  37. group.GET("/qusb/list", qusBankList) //题库列表
  38. group.POST("/qusb/add", qusBankAdd) //题库添加
  39. group.POST("/qusb/del", qusBankDel) //题库删除
  40. group.POST("/qusb/update", qusBankEdit) //题库修改
  41. group.POST("/qusb/check", qusBankCheck) // 答题
  42. group.GET("/qs/info", qusInfo) //题目信息
  43. group.GET("/qs/list", qusList) //题目列表
  44. group.POST("/qs/add", qusAdd) //题目添加
  45. group.POST("/qs/update", qusUpdate) //题目更新
  46. group.POST("/qs/del", qusDel) //题目删除
  47. group.GET("/qs/get", getQuestion) //题目获取
  48. group.POST("/qs/answer", answerQuestion) // 答题
  49. group.POST("/bind", questionBankBind) // 绑定题库
  50. group.POST("/unbind", questionBankUnbind) // 解绑题库
  51. group.POST("/bind/bank", getBankBind) // 查询已绑定的题库
  52. group.GET("/bind/items", getBindItems) // 查询绑定到题库的 items
  53. group.GET("/risk/check", riskCheck) //风险检验
  54. group.POST("/risk/check/v2", riskCheckV2) //风险检验v2
  55. group.GET("/graph/prepare", graphPrepare) //拉起图形验证
  56. group.POST("/graph/check", graphCheck) //图形验证
  57. }
  58. group2 := e.Group("/openplatform/admin/antifraud/shield")
  59. {
  60. group2.GET("/risk/ip/list", ipList) //ip列表
  61. group2.GET("/risk/ip/detail", ipDetail) //ip详情列表
  62. group2.GET("/risk/uid/list", uidList) //uid列表
  63. group2.GET("/risk/uid/detail", uidDetail) //uid详情列表
  64. group2.POST("/risk/ip/black", ipBlack) //设置ip黑名单
  65. group2.POST("/risk/uid/black", uidBlack) //设置uid黑名单
  66. }
  67. }
  68. // outerRouter init outer router.
  69. //func outerRouter(e *bm.Engine) {
  70. //}
  71. // ping check server ok.
  72. func ping(c *bm.Context) {
  73. if err := svc.Ping(c); err != nil {
  74. log.Error("open-abtest http service ping error(%v)", err)
  75. c.AbortWithStatus(http.StatusServiceUnavailable)
  76. }
  77. }