router_check_role.go.template 675 B

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