system_api.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package route
  2. import (
  3. "kpt-pasture/http/handler"
  4. "kpt-pasture/http/handler/system"
  5. "kpt-pasture/http/middleware"
  6. "github.com/gin-gonic/gin"
  7. )
  8. func SystemAPI(opts ...func(engine *gin.Engine)) func(s *gin.Engine) {
  9. return func(s *gin.Engine) {
  10. for _, opt := range opts {
  11. opt(s)
  12. }
  13. // Not Found
  14. s.NoRoute(handler.Handle404)
  15. // Health Check
  16. s.GET("/check", handler.Health)
  17. s.POST("/api/v1/login", system.Login)
  18. // system API 组 系统用户
  19. systemRoute := authRouteGroup(s, "/api/v1/system/")
  20. systemRoute.POST("/user/list", system.SearchSystemUserList)
  21. systemRoute.PUT("/user/is_show/:id", system.IsShowSystemUser)
  22. systemRoute.DELETE("/user/:id", system.DeleteUser)
  23. systemRoute.POST("/user/createOrUpdate", system.UserCreateOrUpdate)
  24. systemRoute.POST("/user/rest/password", system.ResetPasswordSystemUser)
  25. systemRoute.POST("/user_info", system.GetUserInfo)
  26. systemRoute.GET("/user/details/:user_id", system.DetailsSystemUser)
  27. systemRoute.POST("/user/permissions", system.GetSystemUserPermissions)
  28. systemRoute.POST("/user/logout", system.LogoutSystemUser)
  29. // 系统角色
  30. systemRoute.POST("/role/add", system.AddSystemRole)
  31. systemRoute.GET("/role/permissions/:role_id", system.GetRolePermissions)
  32. systemRoute.POST("/role/edit", system.EditSystemRole)
  33. systemRoute.DELETE("/role/:role_id", system.DeleteSystemRole)
  34. systemRoute.POST("/role/list", system.SearchSystemRoleList)
  35. // 系统菜单权限
  36. systemRoute.POST("/menu/add", system.AddSystemMenu)
  37. systemRoute.POST("/menu/edit", system.EditSystemMenu)
  38. systemRoute.POST("/menu/is_show", system.IsShowSystemMenu)
  39. systemRoute.POST("/menu/list", system.SearchSystemMenuList)
  40. systemRoute.DELETE("/menu/:menu_id", system.DeleteSystemMenu)
  41. // 系统部门
  42. systemRoute.POST("/dept/list", system.DeptList)
  43. systemRoute.DELETE("/dept/:id", system.DepIsShow)
  44. systemRoute.POST("/dept/createOrUpdate", system.DepCreateOrUpdate)
  45. }
  46. }
  47. func authRouteGroup(s *gin.Engine, relativePath string) *gin.RouterGroup {
  48. group := s.Group(relativePath)
  49. // 中间件鉴权
  50. group.Use( /*middleware.RequireAdmin(),*/ middleware.GinLogger(), middleware.CORS())
  51. return group
  52. }