ot_plugins.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package router
  2. import (
  3. "github.com/gin-gonic/gin"
  4. jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth"
  5. "go-admin/app/admin/apis"
  6. "go-admin/common/actions"
  7. "go-admin/common/middleware"
  8. )
  9. func init() {
  10. routerCheckRole = append(routerCheckRole, registerOtPluginsRouter)
  11. routerNoCheckRole = append(routerNoCheckRole, registerOtPluginsRouterTest)
  12. }
  13. // registerOtPluginsRouter
  14. func registerOtPluginsRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
  15. api := apis.OtPlugins{}
  16. r := v1.Group("/ot-plugins").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
  17. {
  18. r.GET("", actions.PermissionAction(), api.GetPage)
  19. r.GET("/:id", actions.PermissionAction(), api.Get)
  20. r.GET("/withrole", actions.PermissionAction(), api.GetPluginsWithRole)
  21. r.POST("", api.Insert)
  22. r.PUT("/:id", actions.PermissionAction(), api.Update)
  23. r.DELETE("", api.Delete)
  24. }
  25. }
  26. func registerOtPluginsRouterTest(v1 *gin.RouterGroup) {
  27. api := apis.OtPlugins{}
  28. r := v1.Group("/ot-plugins/test")
  29. {
  30. r.GET("", api.GetPage)
  31. r.GET("/:id", api.Get)
  32. r.POST("", api.Insert)
  33. r.PUT("/:id", api.Update)
  34. r.DELETE("", api.Delete)
  35. }
  36. }