userInfoHandler.go 655 B

123456789101112131415161718192021222324
  1. // Code scaffolded by goctl. Safe to edit.
  2. // goctl 1.10.0
  3. package auth
  4. import (
  5. "net/http"
  6. "github.com/zeromicro/go-zero/rest/httpx"
  7. "perms-system-server/internal/logic/auth"
  8. "perms-system-server/internal/svc"
  9. )
  10. // UserInfoHandler 获取当前登录用户信息接口。返回用户个人信息、成员类型和权限列表。
  11. func UserInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  12. return func(w http.ResponseWriter, r *http.Request) {
  13. l := auth.NewUserInfoLogic(r.Context(), svcCtx)
  14. resp, err := l.UserInfo()
  15. if err != nil {
  16. httpx.ErrorCtx(r.Context(), w, err)
  17. } else {
  18. httpx.OkJsonCtx(r.Context(), w, resp)
  19. }
  20. }
  21. }