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

package member

import (
	"net/http"

	"gateway/internal/logic/member"
	"gateway/internal/response"
	"gateway/internal/svc"
	"gateway/internal/types"

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

// 開始業務 phone 驗證
func StartPhoneVerificationHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		var req types.VerificationStartReq
		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 := member.NewStartPhoneVerificationLogic(actorContext(r.Context(), r), svcCtx)
		data, err := l.StartPhoneVerification(&req)
		response.Write(r.Context(), w, data, err)
	}
}
