get_gpts_user_info_handler.go 834 B

123456789101112131415161718192021222324252627282930313233
  1. package User
  2. import (
  3. "net/http"
  4. jwtutils "wechat-api/internal/utils/jwt"
  5. "github.com/zeromicro/go-zero/rest/httpx"
  6. "wechat-api/internal/logic/User"
  7. "wechat-api/internal/svc"
  8. )
  9. // swagger:route post /gpts/user/info User GetGptsUserInfo
  10. //
  11. // Get user basic information | 获取用户基本信息
  12. //
  13. // Get user basic information | 获取用户基本信息
  14. //
  15. // Responses:
  16. // 200: BaseDataInfo
  17. func GetGptsUserInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  18. return func(w http.ResponseWriter, r *http.Request) {
  19. l := User.NewGetGptsUserInfoLogic(r.Context(), svcCtx)
  20. tokenStr := jwtutils.StripBearerPrefixFromToken(r.Header.Get("Authorization"))
  21. resp, err := l.GetGptsUserInfo(tokenStr)
  22. if err != nil {
  23. httpx.ErrorCtx(r.Context(), w, err)
  24. } else {
  25. httpx.OkJsonCtx(r.Context(), w, resp)
  26. }
  27. }
  28. }