package user

import (
	"github.com/zeromicro/go-zero/rest/httpx"
	"microGame/app/usercenter/cmd/api/internal/logic/user"
	"microGame/app/usercenter/cmd/api/internal/svc"
	"microGame/app/usercenter/cmd/api/internal/types"
	"microGame/pkg/ctxdata"
	"microGame/pkg/result"
	"net/http"
)

// DetailHandler get user info
func DetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		var req types.UserInfoReq
		if err := httpx.Parse(r, &req); err != nil {
			httpx.ErrorCtx(r.Context(), w, err)
			return
		}

		ctx := ctxdata.AddJwtToCtx(r)

		l := user.NewDetailLogic(ctx, svcCtx)
		resp, err := l.Detail(&req)
		//if err != nil {
		//	httpx.ErrorCtx(r.Context(), w, err)
		//} else {
		//	httpx.OkJsonCtx(r.Context(), w, resp)
		//}
		result.HttpResult(r, w, resp, err)
	}
}
