http.go 5.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package http
  2. import (
  3. "net/http"
  4. "go-common/app/admin/main/usersuit/conf"
  5. "go-common/app/admin/main/usersuit/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. svc *service.Service
  12. authSvc *permit.Permit
  13. )
  14. // Init fot init open service
  15. func Init(c *conf.Config, s *service.Service) {
  16. svc = s
  17. authSvc = permit.New(c.Auth)
  18. engine := bm.DefaultServer(c.BM)
  19. innerRouter(engine)
  20. // init internal server
  21. if err := engine.Start(); err != nil {
  22. log.Error("engine.Start error(%v)", err)
  23. panic(err)
  24. }
  25. }
  26. // innerRouter
  27. func innerRouter(e *bm.Engine) {
  28. // ping monitor
  29. e.Ping(ping)
  30. // internal api
  31. bg := e.Group("/x/admin/usersuit")
  32. {
  33. // invite
  34. bg.POST("/invite/generate", authSvc.Permit("INVITE_INFO_ADMIN"), generate)
  35. bg.GET("/invite/list", authSvc.Permit("INVITE_INFO_SEARCH"), list)
  36. // new pendant
  37. bg.GET("/pendant/info/list", authSvc.Permit("PENDANT_INFO_LIST"), pendantInfoList) // 挂件列表(带分页)
  38. bg.GET("/pendant/info/id", authSvc.Permit("PENDANT_INFO_ID"), pendantInfoID) // 挂件详情
  39. bg.GET("/pendant/group/id", authSvc.Permit("PENDANT_GROUP_ID"), pendantGroupID) // 挂件分组详情
  40. bg.GET("/pendant/group/list", authSvc.Permit("PENDANT_GROUP_LIST"), pendantGroupList) // 挂件分组列表(带分页)
  41. bg.GET("/pendant/group/all", authSvc.Permit("PENDANT_GROUP_ALL"), pendantGroupAll) // 挂件分组列表(不带分页) 这个筛选列表可不加权限
  42. bg.GET("/pendant/info/all/no/page", authSvc.Permit("PENDANT_INFO_ALL_NO_PAGE"), pendantInfoAllNoPage) // 在售挂件(不带分页) 这个筛选列表可不加权限
  43. bg.POST("/pendant/add/info", authSvc.Permit("PENDANT_ADD_INFO"), addPendantInfo) // 添加挂件
  44. bg.POST("/pendant/up/info", authSvc.Permit("PENDANT_UP_INFO"), upPendantInfo) // 更新挂件
  45. bg.POST("/pendant/up/group/status", authSvc.Permit("PENDANT_UP_GROUP_STATUS"), upPendantGroupStatus) // 更新挂件分组状态
  46. bg.POST("/pendant/up/info/status", authSvc.Permit("PENDANT_UP_INFO_STATUS"), upPendantInfoStatus) // 更新挂件状态
  47. bg.POST("/pendant/add/group", authSvc.Permit("PENDANT_ADD_GROUP"), addPendantGroup) // 添加挂件分组
  48. bg.POST("/pendant/up/group", authSvc.Permit("PENDANT_UP_GROUP"), upPendantGroup) // 更新挂件分组
  49. bg.GET("/pendant/orders", authSvc.Permit("PENDANT_ORDERS"), pendantOrders) // 挂件订单列表
  50. bg.POST("/pendant/equip", authSvc.Permit("PENDANT_EQUIP"), equipPendant) // 装备挂件
  51. bg.GET("/user/pendant/pkg", authSvc.Permit("USER_PENDANT_PKG"), userPendantPKG) // 用户可用挂件背包列表
  52. bg.GET("/user/pkg/details", authSvc.Permit("USER_PKG_DETAILS"), userPKGDetails) // 用户所属挂件详情
  53. bg.POST("/pendant/up/pkg", authSvc.Permit("PENDANT_UP_PKG"), upPendantPKG) // 更新或激活用户挂件
  54. bg.POST("/pendant/mutli/send", authSvc.Permit("PENDANT_MUTLI_SEND"), mutliSend) // 多用户发送挂件
  55. bg.GET("/pendant/oper/log", authSvc.Permit("PENDANT_OPER_LOG"), pendantOperlog) // 发放挂件操作日志
  56. bg.POST("/face/upload", upload) // 上传图片
  57. //medal
  58. bg.GET("/medal", authSvc.Permit("MEDAL_INFO_LIST"), medalList) // 勋章列表
  59. bg.GET("/medal/id", authSvc.Permit("MEDAL_INFO_ID"), medalView) // 勋章查看
  60. bg.POST("/medal/add", authSvc.Permit("MEDAL_INFO_ADD"), medalAdd) // 勋章添加
  61. bg.POST("/medal/edit", authSvc.Permit("MEDAL_INFO_EDIT"), medalEdit) // 勋章编辑
  62. bg.GET("/medal/group", authSvc.Permit("MEDAL_GROUP_LIST"), medalGroup) // 勋章分组列表
  63. bg.GET("/medal/group/view", authSvc.Permit("MEDAL_GROUP_VIEW"), medalGroupView) // 勋章分组查看单个
  64. bg.GET("/medal/group/parent", authSvc.Permit("MEDAL_GROUP_PARENT"), medalGroupParent) // 勋章父辈分组列表
  65. bg.POST("/medal/group/add", authSvc.Permit("MEDAL_GROUP_ADD"), medalGroupAdd) // 勋章分组添加
  66. bg.POST("/medal/group/edit", authSvc.Permit("MEDAL_GROUP_EDIT"), medalGroupEdit) // 勋章分组编辑
  67. bg.GET("/medal/member/mid", authSvc.Permit("MEDAL_MEMBER_MID"), medalMemberMID) // 勋章会员管理
  68. bg.POST("/medal/member/edit", authSvc.Permit("MEDAL_MEMBER_EDIT"), medalOwnerUpActivated) // 勋章会员编辑激活
  69. bg.GET("/medal/member/add/list", authSvc.Permit("MEDAL_MEMBER_ADD_LIST"), medalMemberAddList) // 勋章会员可添加列表
  70. bg.POST("/medal/member/add", authSvc.Permit("MEDAL_MEMBER_ADD"), medalMemberAdd) // 勋章会员添加
  71. bg.POST("/medal/member/del", authSvc.Permit("MEDAL_MEMBER_DEL"), medalMemberDel) // 勋章会员删除
  72. bg.POST("/medal/batch/add", authSvc.Permit("MEDAL_BATCH_ADD"), medalBatchAdd) // 勋章批量添加
  73. bg.GET("/medal/oper/log", authSvc.Permit("MEDAL_OPER_LOG"), medalOperlog) // 勋章操作日志
  74. }
  75. }
  76. // ping check server ok.
  77. func ping(c *bm.Context) {
  78. err := svc.Ping(c)
  79. if err != nil {
  80. log.Error("usersuit admin ping error")
  81. c.AbortWithStatus(http.StatusServiceUnavailable)
  82. }
  83. }