sys_role.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package router
  2. import (
  3. "Medical_OAuth/common/actions"
  4. "Medical_OAuth/common/middleware"
  5. "github.com/gin-gonic/gin"
  6. "Medical_OAuth/app/admin/controller"
  7. jwt "gogs.baozhida.cn/zoie/OAuth-core/pkg/jwtauth"
  8. )
  9. func init() {
  10. routerCheckRole = append(routerCheckRole, registerSysRoleRouter)
  11. }
  12. // 需认证的路由代码
  13. func registerSysRoleRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
  14. cont := controller.SysRoleController{}
  15. r := v1.Group("/role").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()).Use(actions.PermissionAction())
  16. {
  17. r.GET("", cont.GetPage)
  18. r.GET("/:id", cont.Get)
  19. r.POST("", cont.Insert)
  20. r.PUT("/:id", cont.Update)
  21. r.DELETE("", cont.Delete)
  22. }
  23. // 角色关联的api
  24. r1 := v1.Group("/role-api").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
  25. {
  26. r1.GET("/:id", cont.GetRoleApi)
  27. r1.PUT("/:id", cont.UpdateRoleApi)
  28. }
  29. // 角色关联的菜单
  30. r2 := v1.Group("/role-menu").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
  31. {
  32. r2.GET("/:id", cont.GetRoleMenu)
  33. r2.PUT("/:id", cont.UpdateRoleMenu)
  34. }
  35. }