router.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package routers
  2. import (
  3. "eta/eta_mini_crm/controllers"
  4. beego "github.com/beego/beego/v2/server/web"
  5. "github.com/beego/beego/v2/server/web/filter/cors"
  6. )
  7. func init() {
  8. beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
  9. AllowAllOrigins: true,
  10. AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
  11. AllowHeaders: []string{"Origin", "Authorization", "Uuid", "Accesstoken", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
  12. ExposeHeaders: []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
  13. AllowCredentials: true,
  14. }))
  15. ns := beego.NewNamespace("/adminapi",
  16. beego.NSNamespace("/sys_user",
  17. beego.NSInclude(
  18. &controllers.UserLoginController{},
  19. &controllers.SysUserController{},
  20. ),
  21. ),
  22. beego.NSNamespace("/department",
  23. beego.NSInclude(
  24. &controllers.SysDepartmentController{},
  25. ),
  26. ),
  27. beego.NSNamespace("/role",
  28. beego.NSInclude(
  29. &controllers.SysRoleController{},
  30. ),
  31. ),
  32. beego.NSNamespace("/chart_permission",
  33. beego.NSInclude(
  34. &controllers.ChartPermissionController{},
  35. ),
  36. ),
  37. beego.NSNamespace("/user",
  38. beego.NSInclude(
  39. &controllers.UserController{},
  40. ),
  41. ),
  42. beego.NSNamespace("/sys_message",
  43. beego.NSInclude(
  44. &controllers.SysMessageReportController{},
  45. ),
  46. ),
  47. beego.NSNamespace("/seller",
  48. beego.NSInclude(
  49. &controllers.SellerController{},
  50. ),
  51. ),
  52. beego.NSNamespace("/classify",
  53. beego.NSInclude(
  54. &controllers.ClassifyController{},
  55. ),
  56. ),
  57. beego.NSNamespace("/read",
  58. beego.NSInclude(
  59. &controllers.UserReadRecordController{},
  60. ),
  61. ),
  62. beego.NSNamespace("/report_pdf",
  63. beego.NSInclude(
  64. &controllers.ReportPdfController{},
  65. ),
  66. ),
  67. beego.NSNamespace("/report_push",
  68. beego.NSInclude(
  69. &controllers.ReportPushStatusController{},
  70. ),
  71. ),
  72. )
  73. beego.AddNamespace(ns)
  74. }