SendSMS 发送短信验证码
(ctx *gin.Context)
| 155 | |
| 156 | // SendSMS 发送短信验证码 |
| 157 | func (uh *UserHandler) SendSMS(ctx *gin.Context) { |
| 158 | var req req.SMSReq |
| 159 | if err := ctx.ShouldBindJSON(&req); err != nil { |
| 160 | apiresponse.ErrorWithMessage(ctx, "无效的请求参数") |
| 161 | return |
| 162 | } |
| 163 | |
| 164 | if !utils.IsValidNumber(req.Number) { |
| 165 | apiresponse.ErrorWithMessage(ctx, "无效的手机号码") |
| 166 | return |
| 167 | } |
| 168 | |
| 169 | if err := uh.smsProducer.ProduceSMSCode(ctx, sms.SMSCodeEvent{Number: req.Number}); err != nil { |
| 170 | apiresponse.ErrorWithMessage(ctx, "发送短信验证码失败") |
| 171 | return |
| 172 | } |
| 173 | |
| 174 | apiresponse.Success(ctx) |
| 175 | } |
| 176 | |
| 177 | // ChangePassword 修改密码 |
| 178 | func (uh *UserHandler) ChangePassword(ctx *gin.Context) { |
nothing calls this directly
no test coverage detected