sys_user.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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, registerSysUserRouter)
  11. }
  12. // 需认证的路由代码
  13. func registerSysUserRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
  14. api := apis.SysUser{}
  15. r := v1.Group("/sys-user").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()).Use(actions.PermissionAction())
  16. {
  17. r.GET("", api.GetPage)
  18. r.GET("/:id", api.Get)
  19. r.POST("", api.Insert)
  20. r.PUT("", api.Update)
  21. r.DELETE("", api.Delete)
  22. }
  23. user := v1.Group("/user").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()).Use(actions.PermissionAction())
  24. {
  25. user.GET("/profile", api.GetProfile)
  26. user.POST("/avatar", api.InsetAvatar)
  27. user.PUT("/pwd/set", api.UpdatePwd)
  28. user.PUT("/pwd/reset", api.ResetPwd)
  29. user.PUT("/status", api.UpdateStatus)
  30. }
  31. v1auth := v1.Group("").Use(authMiddleware.MiddlewareFunc())
  32. {
  33. v1auth.GET("/getinfo", api.GetInfo)
  34. }
  35. }