From caa9dfa8f9c417a77d7851285013fba628e250f2 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Mon, 16 Dec 2024 13:47:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E7=99=BB=E9=99=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/hdl/hdl_login.go | 35 +++++++++++++++++++++++++++++++++++ app/router/router.go | 1 + 2 files changed, 36 insertions(+) diff --git a/app/hdl/hdl_login.go b/app/hdl/hdl_login.go index 400c1fa..48051f0 100644 --- a/app/hdl/hdl_login.go +++ b/app/hdl/hdl_login.go @@ -288,6 +288,41 @@ func Register(c *gin.Context) { commReq(c, req) } +// WechatRegister +// @Summary 注册 +// @Tags 登录注册 +// @Description 注册 +// @Accept json +// @Produce json +// @Param req body md.RegisterReq true "注册参数" +// @Success 200 {object} md.LoginResponse "登录成功返回" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/v1/wechatRegister [post] +func WechatRegister(c *gin.Context) { + var req md.RegisterReq + err := c.ShouldBindJSON(&req) + if err != nil { + err = svc.HandleValidateErr(err) + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) + return + } + data := svc.AliyunSmsBase(c, "") + //校验短信 + err = aliyun.AliyunCheckSms(data["aliyun_sms_id"], data["aliyun_sms_secret"], req.Mobile, req.Code) + if cfg.Prd { + if err != nil { + e.OutErr(c, 400, e.NewErr(400, "验证码错误,请重试")) + return + } + } + if req.WechatCode == "" { + e.OutErr(c, 400, "获取微信信息失败") + return + } + commReq(c, req) +} + // Login 登陆 // @Summary 登陆 // @Tags 登录注册 diff --git a/app/router/router.go b/app/router/router.go index 3f7ba91..e4f1980 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -75,6 +75,7 @@ func route(r *gin.RouterGroup) { r.POST("/smsSend", hdl.SmsSend) //发送短信 r.POST("/fastLogin", hdl.FastLogin) //一键登录 r.POST("/wechatLogin", hdl.WechatLogin) //微信登录 + r.POST("/wechatRegister", hdl.WechatRegister) //注册 r.POST("/register", hdl.Register) //注册 r.POST("/login", hdl.Login) //登录 r.POST("/findPassword", hdl.FindPassword) //找回密码