system_api.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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/list", system.SearchSystemRoleList)
  31. systemRoute.DELETE("/role/:id", system.DeleteSystemRole)
  32. systemRoute.PUT("/role/is_show/:id", system.IsShowSystemRole)
  33. systemRoute.POST("/role/createOrUpdate", system.RoleCreateOrUpdate)
  34. systemRoute.GET("/role/permissions/:role_id", system.GetRolePermissions)
  35. // 系统菜单权限
  36. systemRoute.POST("/menu/list", system.SearchSystemMenuList)
  37. systemRoute.DELETE("/menu/:id", system.DeleteSystemMenu)
  38. systemRoute.POST("/menu/createOrUpdate", system.CreatedOrUpdateSystemMenu)
  39. // 系统部门
  40. systemRoute.POST("/dept/list", system.DeptList)
  41. systemRoute.DELETE("/dept/:id", system.DepIsShow)
  42. systemRoute.POST("/dept/createOrUpdate", system.DepCreateOrUpdate)
  43. }
  44. }
  45. func authRouteGroup(s *gin.Engine, relativePath string) *gin.RouterGroup {
  46. group := s.Group(relativePath)
  47. // 中间件鉴权
  48. group.Use( /*middleware.RequireAdmin(),*/ middleware.GinLogger(), middleware.CORS())
  49. return group
  50. }