system_api.go 2.1 KB

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