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

package email

import (
	"net/http"

	"github.com/zeromicro/go-zero/rest/httpx"
	"juwan-backend/app/email/api/internal/logic/email"
	"juwan-backend/app/email/api/internal/svc"
	"juwan-backend/app/email/api/internal/types"
)

// 忘记密码-发送验证码
func ForgotPasswordHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		var req types.ForgotPasswordReq
		if err := httpx.Parse(r, &req); err != nil {
			httpx.ErrorCtx(r.Context(), w, err)
			return
		}

		l := email.NewForgotPasswordLogic(r.Context(), svcCtx)
		resp, err := l.ForgotPassword(&req)
		if err != nil {
			httpx.ErrorCtx(r.Context(), w, err)
		} else {
			httpx.OkJsonCtx(r.Context(), w, resp)
		}
	}
}
