router_check_role.go.template 786 B

123456789101112131415161718192021222324252627
  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/{{.PackageName}}/apis"
  6. "go-admin/common/middleware"
  7. "go-admin/common/actions"
  8. )
  9. func init() {
  10. routerCheckRole = append(routerCheckRole, register{{.ClassName}}Router)
  11. }
  12. // register{{.ClassName}}Router
  13. func register{{.ClassName}}Router(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
  14. api := apis.{{.ClassName}}{}
  15. r := v1.Group("/{{.ModuleName}}").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
  16. {
  17. r.GET("", actions.PermissionAction(), api.GetPage)
  18. r.GET("/:id", actions.PermissionAction(), api.Get)
  19. r.POST("", api.Insert)
  20. r.PUT("/:id", actions.PermissionAction(), api.Update)
  21. r.DELETE("", api.Delete)
  22. }
  23. }