mingyang-admin-iot-app/api/internal/handler/user_public/get_verify_code_handler.go

46 lines
1.0 KiB
Go

package user_public
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"mingyang-admin-app-api/internal/logic/user_public"
"mingyang-admin-app-api/internal/svc"
"mingyang-admin-app-api/internal/types"
)
// swagger:route post /get/verifyCode user_public GetVerifyCode
//
// GetVerifyCode | 获取验证码
//
// GetVerifyCode | 获取验证码
//
// Parameters:
// + name: body
// require: true
// in: body
// type: VerifyCodeReq
//
// Responses:
// 200: VerifyCodeResp
func GetVerifyCodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.VerifyCodeReq
if err := httpx.Parse(r, &req, true); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := user_public.NewGetVerifyCodeLogic(r.Context(), svcCtx)
resp, err := l.GetVerifyCode(&req)
if err != nil {
err = svcCtx.Trans.TransError(r.Context(), err)
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}