package route import ( "kpt-tmr-group/http/handler" "kpt-tmr-group/http/handler/mobile" "kpt-tmr-group/http/handler/system" "kpt-tmr-group/http/middleware" "github.com/gin-gonic/gin" ) func SystemAPI(opts ...func(engine *gin.Engine)) func(s *gin.Engine) { return func(s *gin.Engine) { for _, opt := range opts { opt(s) } // Not Found s.NoRoute(handler.Handle404) // Health Check s.GET("/check", handler.Health) s.POST("/auth", system.Auth) s.GET("/wx_applet/openid/:js_code", system.GetWxAppletOpenId) // system API 组 // 系统用户 systemRoute := authRouteGroup(s, "/api/v1/system/") systemRoute.POST("/user_info", system.GetUserInfo) systemRoute.POST("/user/add", system.AddSystemUser) systemRoute.GET("/user/details/:user_id", system.DetailsSystemUser) systemRoute.POST("/user/list", system.SearchSystemUserList) systemRoute.POST("/user/edit", system.EditSystemUser) systemRoute.POST("/user/is_show", system.IsShowSystemUser) systemRoute.DELETE("/user/:user_id", system.DeleteUser) systemRoute.POST("/user/permissions", system.GetSystemUserPermissions) systemRoute.POST("/user/rest_password/:user_id", system.ResetPasswordSystemUser) systemRoute.POST("/user/logout", system.LogoutSystemUser) // 系统角色 systemRoute.POST("/role/add", system.AddSystemRole) systemRoute.GET("/role/permissions/:role_id", system.GetRolePermissions) systemRoute.POST("/role/edit", system.EditSystemRole) systemRoute.DELETE("/role/:role_id", system.DeleteSystemRole) systemRoute.POST("/role/list", system.SearchSystemRoleList) // 系统菜单权限 systemRoute.POST("/menu/add", system.AddSystemMenu) systemRoute.POST("/menu/edit", system.EditSystemMenu) systemRoute.POST("/menu/is_show", system.IsShowSystemMenu) systemRoute.POST("/menu/list", system.SearchSystemMenuList) systemRoute.DELETE("/menu/:menu_id", system.DeleteSystemMenu) // 移动端 systemRoute.POST("/mobile/list", mobile.SearchMobileList) } } func authRouteGroup(s *gin.Engine, relativePath string) *gin.RouterGroup { group := s.Group(relativePath) // 中间件鉴权 group.Use(middleware.RequireAdmin(), middleware.CORS()) return group }