// Code scaffolded by goctl. Safe to edit.
package auth

import (
	"net/http"

	logicauth "gateway/internal/logic/auth"
	"gateway/internal/response"
	"gateway/internal/svc"
	"gateway/internal/types"

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

func LoginSocialCallbackHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		var req types.LoginSocialCallbackReq
		if err := httpx.Parse(r, &req); err != nil {
			response.Write(r.Context(), w, nil, response.WrapRequestError(err))
			return
		}
		if err := svcCtx.Validator.ValidateAll(&req); err != nil {
			response.Write(r.Context(), w, nil, response.WrapRequestError(err))
			return
		}

		l := logicauth.NewLoginSocialCallbackLogic(HandlerContext(r.Context(), r), svcCtx)
		data, err := l.LoginSocialCallback(&req)
		response.Write(r.Context(), w, data, err)
	}
}
