routes.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * @description: 路由配置
  3. * @Author: CP
  4. * @Date: 2020-08-23 21:32:54
  5. * @FilePath: \construction_management\web\routes\routes.go
  6. */
  7. package routes
  8. import (
  9. "github.com/kataras/iris/v12/mvc"
  10. "go.mod/bootstrap"
  11. "go.mod/services"
  12. "go.mod/web/api"
  13. "go.mod/web/controllers"
  14. "go.mod/web/middleware"
  15. )
  16. func Configure(b *bootstrap.Bootstrapper) {
  17. //service加载
  18. ProjectAccountService := services.NewProjectAccountService()
  19. LoginService := services.NewLoginService()
  20. ProjectService := services.NewProjectService()
  21. TreeService := services.NewTreeService()
  22. BidsectionService := services.NewBidsectionService()
  23. //CSRF相关
  24. b.Use(middleware.SetCsrf)
  25. //b.Party("/", protect)
  26. //protect := NewCsrf()
  27. //登录相关
  28. //login := mvc.New(b.Party("/", protect))
  29. login := mvc.New(b.Party("/"))
  30. login.Register(ProjectAccountService)
  31. login.Register(LoginService)
  32. login.Handle(new(controllers.LoginController))
  33. // todolist相关
  34. todo := mvc.New(b.Party("/todolist"))
  35. todo.Router.Use(middleware.SessionsAuth)
  36. todo.Handle(new(controllers.TodoController))
  37. // 合同管理
  38. contract := mvc.New(b.Party("/contract"))
  39. contract.Router.Use(middleware.SessionsAuth)
  40. contract.Handle(new(controllers.ContractController))
  41. // 安全巡检
  42. //用户相关
  43. account := mvc.New(b.Party("/account"))
  44. account.Register(ProjectAccountService)
  45. account.Router.Use(middleware.SessionsAuth)
  46. account.Handle(new(controllers.AccountController))
  47. // 项目相关
  48. project := mvc.New(b.Party("/project"))
  49. project.Router.Use(middleware.SessionsAuth)
  50. project.Register(TreeService)
  51. project.Register(ProjectService)
  52. project.Handle(new(controllers.ProjectController))
  53. //标段相关
  54. bidsection := mvc.New(b.Party("/bidsection"))
  55. bidsection.Register(ProjectService)
  56. bidsection.Router.Use(middleware.SessionsAuth)
  57. bidsection.Handle(new(controllers.BidsectionController))
  58. // 接口相关
  59. // 登陆接口
  60. apiLogin := mvc.New(b.Party("/api/login"))
  61. apiLogin.Register(ProjectAccountService)
  62. apiLogin.Register(LoginService)
  63. apiLogin.Register(ProjectService)
  64. apiLogin.Handle(new(api.LoginApi))
  65. // TreeNode相关接口
  66. // apiTree.Router.Use(middleware.JwtAuth().Serve)
  67. apiTree := mvc.New(b.Party("/api/tree"))
  68. apiTree.Register(TreeService)
  69. apiTree.Router.Use(middleware.SessionsAuth)
  70. apiTree.Router.Use(middleware.AccessAuth)
  71. apiTree.Handle(new(api.TreeApi))
  72. // 项目相关接口
  73. apiProject := mvc.New(b.Party("/api/project"))
  74. apiProject.Register(ProjectService)
  75. apiProject.Router.Use(middleware.SessionsAuth)
  76. apiProject.Router.Use(middleware.AccessAuth)
  77. apiProject.Handle(new(api.ProjectApi))
  78. // 项目账号相关接口
  79. apiProjectAccount := mvc.New(b.Party("/api/projectAccount"))
  80. apiProjectAccount.Register(ProjectAccountService)
  81. apiProjectAccount.Router.Use(middleware.SessionsAuth)
  82. apiProjectAccount.Router.Use(middleware.AccessAuth)
  83. apiProjectAccount.Handle(new(api.ProjectAccountApi))
  84. // 标段相关接口
  85. apiBidsection := mvc.New(b.Party("/api/bidsection"))
  86. apiBidsection.Register(BidsectionService)
  87. apiBidsection.Router.Use(middleware.SessionsAuth)
  88. apiBidsection.Router.Use(middleware.AccessAuth)
  89. apiBidsection.Handle(new(api.BidsectionApi))
  90. // 项目设置接口
  91. apiSetting := mvc.New(b.Party("/api/projectSetting"))
  92. apiSetting.Register(ProjectAccountService)
  93. apiProject.Register(ProjectService)
  94. apiSetting.Router.Use(middleware.SessionsAuth)
  95. apiSetting.Router.Use(middleware.AccessAuth)
  96. apiSetting.Handle(new(api.ProjectSettingApi))
  97. }