package User

import (
	"net/http"
	jwtutils "wechat-api/internal/utils/jwt"

	"github.com/zeromicro/go-zero/rest/httpx"

	"wechat-api/internal/logic/User"
	"wechat-api/internal/svc"
)

// swagger:route post /gpts/user/info User GetGptsUserInfo
//
// Get user basic information | 获取用户基本信息
//
// Get user basic information | 获取用户基本信息
//
// Responses:
//  200: BaseDataInfo

func GetGptsUserInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		l := User.NewGetGptsUserInfoLogic(r.Context(), svcCtx)
		tokenStr := jwtutils.StripBearerPrefixFromToken(r.Header.Get("Authorization"))
		resp, err := l.GetGptsUserInfo(tokenStr)
		if err != nil {
			httpx.ErrorCtx(r.Context(), w, err)
		} else {
			httpx.OkJsonCtx(r.Context(), w, resp)
		}
	}
}
