backend/internal/handler/user/submit_verification_code_ha...

42 lines
1.0 KiB
Go
Raw Permalink Normal View History

package user
import (
2025-11-04 09:47:36 +00:00
errs "backend/pkg/library/errors"
"net/http"
"backend/internal/logic/user"
"backend/internal/svc"
"backend/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
// 提交驗證碼以完成驗證
func SubmitVerificationCodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SubmitVerificationCodeReq
if err := httpx.Parse(r, &req); err != nil {
2025-11-04 09:47:36 +00:00
e := errs.InputInvalidFormatError(err.Error())
httpx.WriteJsonCtx(r.Context(), w, e.HTTPStatus(), types.Resp{
Code: e.DisplayCode(),
Message: err.Error(),
})
2025-11-08 06:37:41 +00:00
return
}
l := user.NewSubmitVerificationCodeLogic(r.Context(), svcCtx)
resp, err := l.SubmitVerificationCode(&req)
if err != nil {
2025-11-04 09:47:36 +00:00
e := errs.FromError(err)
httpx.WriteJsonCtx(r.Context(), w, e.HTTPStatus(), types.Resp{
Code: e.DisplayCode(),
Message: e.Error(),
Error: e.Unwrap(),
})
} else {
2025-11-08 06:37:41 +00:00
httpx.WriteJsonCtx(r.Context(), w, http.StatusOK, resp)
}
}
}