routes.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. //CSRF相关
  23. b.Use(middleware.SetCsrf)
  24. //b.Party("/", protect)
  25. //protect := NewCsrf()
  26. //登录相关
  27. //login := mvc.New(b.Party("/", protect))
  28. login := mvc.New(b.Party("/"))
  29. login.Register(ProjectAccountService)
  30. login.Register(LoginService)
  31. login.Handle(new(controllers.LoginController))
  32. // todolist相关
  33. todo := mvc.New(b.Party("/todolist"))
  34. todo.Router.Use(middleware.SessionsAuth)
  35. todo.Handle(new(controllers.TodoController))
  36. // 合同管理
  37. contract := mvc.New(b.Party("/contract"))
  38. contract.Router.Use(middleware.SessionsAuth)
  39. contract.Handle(new(controllers.ContractController))
  40. // 安全巡检
  41. //用户相关
  42. account := mvc.New(b.Party("/account"))
  43. account.Register(ProjectAccountService)
  44. account.Router.Use(middleware.SessionsAuth)
  45. account.Handle(new(controllers.AccountController))
  46. // 项目相关
  47. project := mvc.New(b.Party("/project"))
  48. project.Router.Use(middleware.SessionsAuth)
  49. project.Register(TreeService)
  50. project.Register(ProjectService)
  51. project.Handle(new(controllers.ProjectController))
  52. //标段相关
  53. bidsection := mvc.New(b.Party("/bidsection"))
  54. bidsection.Register(ProjectService)
  55. bidsection.Router.Use(middleware.SessionsAuth)
  56. bidsection.Handle(new(controllers.BidsectionController))
  57. // 接口相关
  58. // 登陆接口
  59. apiLogin := mvc.New(b.Party("/api/login"))
  60. apiLogin.Register(ProjectAccountService)
  61. apiLogin.Register(LoginService)
  62. //apiLogin.Router.Use(middleware.JwtAuth().Serve)
  63. apiLogin.Handle(new(api.LoginApi))
  64. // TreeNode相关接口
  65. apiTree := mvc.New(b.Party("/api/tree"))
  66. apiTree.Register(TreeService)
  67. apiTree.Register(ProjectService)
  68. apiTree.Router.Use(middleware.JwtAuth().Serve)
  69. apiTree.Handle(new(api.TreeApi))
  70. // 项目相关接口
  71. apiProject := mvc.New(b.Party("/api/project"))
  72. apiProject.Register(ProjectService)
  73. apiProject.Router.Use(middleware.JwtAuth().Serve)
  74. apiProject.Handle(new(api.ProjectApi))
  75. }