sys_router.go 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. package system
  2. import (
  3. "go_server/service"
  4. "github.com/gin-gonic/gin"
  5. )
  6. //------------------------------------------自动化代码路由------------------------------------------//
  7. type AutoRouter struct {
  8. }
  9. func (AutoRouter) Route() string {
  10. return "/auto"
  11. }
  12. // 控制层与实现层 合二为一 让同一个业务 尽量在一个文件中实现与暴露
  13. var autoService = service.RealizationLayer.SystemServiceGroup.AutoService
  14. func (h AutoRouter) Register(group *gin.RouterGroup) {
  15. group.POST("server/code", autoService.ServerCode)
  16. group.POST("server/rollback", autoService.Rollback)
  17. group.POST("model/auto", autoService.ModelAuto)
  18. }
  19. //------------------------------------------数据库信息查看路由------------------------------------------//
  20. type DbRouter struct {
  21. }
  22. func (DbRouter) Route() string {
  23. return "/db"
  24. }
  25. // 控制层与实现层 合二为一 让同一个业务 尽量在一个文件中实现与暴露
  26. var sysDbService = service.RealizationLayer.SystemServiceGroup.DBService
  27. func (h DbRouter) Register(group *gin.RouterGroup) {
  28. group.GET("dbs", sysDbService.Dbs)
  29. group.GET("tbs", sysDbService.Tbs)
  30. group.GET("cols", sysDbService.Cols)
  31. }
  32. //------------------------------------------用户管理路由------------------------------------------//
  33. type UserRouter struct {
  34. }
  35. func (UserRouter) Route() string {
  36. return "/user"
  37. }
  38. // 控制层与实现层 合二为一 让同一个业务 尽量在一个文件中实现与暴露
  39. var sysUserService = service.RealizationLayer.SystemServiceGroup.UserService
  40. func (h UserRouter) Register(group *gin.RouterGroup) {
  41. // 设置本人信息
  42. group.GET("info", sysUserService.Info)
  43. group.POST("set", sysUserService.Set)
  44. group.GET("getGoogleKey", sysUserService.GetGoogleKey)
  45. group.POST("cancelGoogleKey", sysUserService.CancelGoogleKey)
  46. group.POST("replaceGoogleKey", sysUserService.ReplaceGoogleKey)
  47. // 管理
  48. group.GET("get", sysUserService.Get) // 获取用户详情
  49. group.GET("find", sysUserService.Find) // 用户列表
  50. group.POST("setUser", sysUserService.SetUser) // 设置用户信息
  51. group.POST("create", sysUserService.Create) // 创建用户
  52. group.GET("delete", sysUserService.Del) // 删除用户
  53. group.GET("logs", sysUserService.Logs) // 操作日志
  54. }
  55. //------------------------------------------角色管理路由------------------------------------------//
  56. type RoleRouter struct {
  57. }
  58. func (RoleRouter) Route() string {
  59. return "/role"
  60. }
  61. var roleService = service.RealizationLayer.SystemServiceGroup.RoleService
  62. func (h RoleRouter) Register(group *gin.RouterGroup) {
  63. group.GET("get", roleService.Get)
  64. group.GET("find", roleService.Find)
  65. group.POST("set", roleService.Set)
  66. group.POST("create", roleService.Create)
  67. group.GET("delete", roleService.Del)
  68. }
  69. //------------------------------------------菜单管理路由------------------------------------------//
  70. type MenuRouter struct {
  71. }
  72. func (MenuRouter) Route() string {
  73. return "/menu"
  74. }
  75. var menuService = service.RealizationLayer.SystemServiceGroup.MenuService
  76. func (h MenuRouter) Register(group *gin.RouterGroup) {
  77. group.GET("tree", menuService.Tree)
  78. group.POST("get", menuService.Get)
  79. group.POST("set", menuService.Set)
  80. group.POST("find", menuService.Find)
  81. group.POST("create", menuService.Create)
  82. group.GET("delete", menuService.Del)
  83. }
  84. //------------------------------------------apis管理路由------------------------------------------//
  85. type ApisRouter struct {
  86. }
  87. func (ApisRouter) Route() string {
  88. return "/apis"
  89. }
  90. var apisService = service.RealizationLayer.SystemServiceGroup.ApisService
  91. func (h ApisRouter) Register(group *gin.RouterGroup) {
  92. group.GET("tree", apisService.Tree)
  93. group.GET("get", apisService.Get)
  94. group.GET("find", apisService.Find)
  95. group.POST("set", apisService.Set)
  96. group.POST("create", apisService.Create)
  97. group.GET("delete", apisService.Del)
  98. }
  99. type DictionaryRouter struct {
  100. }
  101. func (DictionaryRouter) Route() string {
  102. return "/dictionary"
  103. }
  104. var dictionaryService = service.RealizationLayer.SystemServiceGroup.DictionaryService
  105. func (h DictionaryRouter) Register(group *gin.RouterGroup) {
  106. group.GET("tree", dictionaryService.DictionariesTree)
  107. group.POST("find", dictionaryService.FindDictionaries)
  108. group.POST("create", dictionaryService.CreateDictionary)
  109. group.POST("set", dictionaryService.UpdateDictionary)
  110. group.POST("delete", dictionaryService.DelDictionary)
  111. group.POST("detail/find", dictionaryService.FindDictionaryDetail)
  112. group.POST("detail/create", dictionaryService.CreateDictionaryDetail)
  113. group.POST("detail/set", dictionaryService.UpdateDictionaryDetail)
  114. group.POST("detail/delete", dictionaryService.DelDictionaryDetail)
  115. }
  116. type FileRouter struct {
  117. }
  118. func (FileRouter) Route() string {
  119. return "/file"
  120. }
  121. var fileRouter = service.RealizationLayer.SystemServiceGroup.FileService
  122. func (h FileRouter) Register(group *gin.RouterGroup) {
  123. group.POST("/upload", fileRouter.UploadFile)
  124. group.GET("/delete", fileRouter.DeleteFile)
  125. group.GET("/oss/auth", fileRouter.OssAuth)
  126. }
  127. type SignRouter struct {
  128. }
  129. func (SignRouter) Route() string {
  130. return "/sign"
  131. }
  132. var signRouter = service.RealizationLayer.SystemServiceGroup.SignService
  133. func (h SignRouter) Register(group *gin.RouterGroup) {
  134. group.POST("/set", signRouter.Set)
  135. group.GET("/find", signRouter.Find)
  136. }