router.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // @APIVersion 1.0.0
  2. // @Title 弘则手机端管理后台接口
  3. // @Description 这是弘则手机端管理后台接口api文档,统一出、入参;出参格式:{"code":200,"data":{},"msg":"操作成功","errMsg":"开发人员查看的错误信息"},code是业务响应码,200 代表正常返回;400 代表业务处理失败,前端同学需要做额外逻辑处理;401 代表token异常,用户需要重新静默授权,获取最新的token;403代表用户需要进行绑定操作,需要跳转到输入账号密码绑定页面。同时如果出现其他返回值(没有在约定范围内),那么及时联系后端同事;msg是用来提示前端同学,一般只在code为 400 的情况下才会展示给用户去看;data是业务返回数据,给前端做逻辑处理。
  4. // 除了微信静默授权接口,其他所有接口请求都必须在header中携带token
  5. // @Contact astaxie@gmail.com
  6. // @TermsOfServiceUrl http://beego.me/
  7. // @License Apache 2.0
  8. // @LicenseUrl http://www.apache.org/licenses/LICENSE-2.0.html
  9. package routers
  10. import (
  11. "github.com/beego/beego/v2/server/web/filter/cors"
  12. "hongze/hongze_mobile_admin/controllers"
  13. "hongze/hongze_mobile_admin/controllers/business_trip"
  14. "hongze/hongze_mobile_admin/controllers/roadshow"
  15. "hongze/hongze_mobile_admin/controllers/yb"
  16. "github.com/beego/beego/v2/server/web"
  17. )
  18. func init() {
  19. //解决跨域问题
  20. web.InsertFilter("*", web.BeforeRouter, cors.Allow(&cors.Options{
  21. AllowAllOrigins: true,
  22. AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
  23. AllowHeaders: []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
  24. ExposeHeaders: []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
  25. AllowCredentials: true,
  26. }))
  27. ns := web.NewNamespace("/h5adminapi",
  28. web.NSNamespace("/wechat",
  29. web.NSInclude(
  30. &controllers.WeChatCommon{},
  31. ),
  32. ),
  33. web.NSNamespace("/admin",
  34. web.NSInclude(
  35. &controllers.AdminCommon{},
  36. ),
  37. ),
  38. web.NSNamespace("/admin_wx",
  39. web.NSInclude(
  40. &controllers.AdminWxController{},
  41. ),
  42. ),
  43. web.NSNamespace("/approval",
  44. web.NSInclude(
  45. &controllers.ApprovalCommon{},
  46. ),
  47. ),
  48. web.NSNamespace("/message",
  49. web.NSInclude(
  50. &controllers.MessageCommon{},
  51. ),
  52. ),
  53. web.NSNamespace("/company_contract",
  54. web.NSInclude(
  55. &controllers.CompanyContractCommon{},
  56. ),
  57. ),
  58. web.NSNamespace("/contract",
  59. web.NSInclude(
  60. &controllers.ContractCommon{},
  61. ),
  62. ),
  63. web.NSNamespace("/contract_approval",
  64. web.NSInclude(
  65. &controllers.ContractApprovalCommon{},
  66. ),
  67. ),
  68. web.NSNamespace("/seal",
  69. web.NSInclude(
  70. &controllers.SealCommon{},
  71. ),
  72. ),
  73. web.NSNamespace("/seal_approval",
  74. web.NSInclude(
  75. &controllers.SealApprovalCommon{},
  76. ),
  77. ),
  78. web.NSNamespace("/resource",
  79. web.NSInclude(
  80. &controllers.ResourceCommon{},
  81. ),
  82. ),
  83. web.NSNamespace("/roadshow",
  84. web.NSInclude(
  85. &roadshow.CalendarController{},
  86. ),
  87. ),
  88. web.NSNamespace("/yb",
  89. web.NSInclude(
  90. &yb.CommunityQuestionController{},
  91. &yb.CommunityQuestionCommentController{},
  92. ),
  93. ),
  94. web.NSNamespace("/taglib",
  95. web.NSInclude(
  96. &controllers.VarietyTagController{},
  97. ),
  98. ),
  99. web.NSNamespace("/business_trip",
  100. web.NSInclude(
  101. &business_trip.BusinessTrip{},
  102. ),
  103. ),
  104. web.NSNamespace("/system",
  105. web.NSInclude(
  106. &controllers.SystemCommon{},
  107. ),
  108. ),
  109. web.NSNamespace("/custom",
  110. web.NSInclude(
  111. &controllers.CompanySellerController{},
  112. ),
  113. ),
  114. )
  115. web.AddNamespace(ns)
  116. }