// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.2

package user

import (
	"net/http"

	"juwan-backend/app/users/api/internal/logic/user"
	"juwan-backend/app/users/api/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
	"github.com/zeromicro/go-zero/rest/httpx"
)

// 获取当前登录用户信息
func GetMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		l := user.NewGetMeLogic(r.Context(), svcCtx)
		resp, err := l.GetMe()
		logx.Infof("getMe requestId=%s userId=%s", r.Header.Get("x-request-id"), r.Header.Get("x-auth-user-id"))
		if err != nil {
			httpx.ErrorCtx(r.Context(), w, err)
		} else {
			httpx.OkJsonCtx(r.Context(), w, resp)
		}
	}
}
