Browse Source

微信登陆

master
huangjiajun 6 days ago
parent
commit
caa9dfa8f9
2 changed files with 36 additions and 0 deletions
  1. +35
    -0
      app/hdl/hdl_login.go
  2. +1
    -0
      app/router/router.go

+ 35
- 0
app/hdl/hdl_login.go View File

@@ -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 登录注册


+ 1
- 0
app/router/router.go View File

@@ -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) //找回密码


Loading…
Cancel
Save