routes.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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/controllers"
  13. "go.mod/web/middleware"
  14. )
  15. func Configure(b *bootstrap.Bootstrapper) {
  16. //service加载
  17. ProjectAccountService := services.NewProjectAccountService()
  18. LoginService := services.NewLoginService()
  19. ProjectService := services.NewProjectService()
  20. FolderService := services.NewFoldertService()
  21. //CSRF相关
  22. b.Use(middleware.SetCsrf)
  23. //b.Party("/", protect)
  24. //protect := NewCsrf()
  25. //登录相关
  26. //login := mvc.New(b.Party("/", protect))
  27. login := mvc.New(b.Party("/"))
  28. login.Register(ProjectAccountService)
  29. login.Register(LoginService)
  30. login.Handle(new(controllers.LoginController))
  31. // todolist相关
  32. todo := mvc.New(b.Party("/todolist"))
  33. todo.Router.Use(middleware.SessionsAuth)
  34. todo.Handle(new(controllers.TodoController))
  35. // 合同管理
  36. contract := mvc.New(b.Party("/contract"))
  37. contract.Router.Use(middleware.SessionsAuth)
  38. contract.Handle(new(controllers.ContractController))
  39. // 安全巡检
  40. //用户相关
  41. account := mvc.New(b.Party("/account"))
  42. account.Register(ProjectAccountService)
  43. account.Router.Use(middleware.SessionsAuth)
  44. account.Handle(new(controllers.AccountController))
  45. // 项目相关
  46. project := mvc.New(b.Party("/project"))
  47. project.Router.Use(middleware.SessionsAuth)
  48. project.Register(FolderService)
  49. project.Register(ProjectService)
  50. project.Handle(new(controllers.ProjectController))
  51. //标段相关
  52. bidsection := mvc.New(b.Party("/bidsection"))
  53. bidsection.Register(ProjectService)
  54. bidsection.Router.Use(middleware.SessionsAuth)
  55. bidsection.Handle(new(controllers.BidsectionController))
  56. }