|
@@ -5,6 +5,7 @@ import com.wf.captcha.utils.CaptchaUtil;
|
|
|
import com.ym.mec.biz.dal.enums.MessageTypeEnum;
|
|
|
import com.ym.mec.biz.service.SmsCodeService;
|
|
|
import com.ym.mec.common.controller.BaseController;
|
|
|
+import com.ym.mec.common.entity.HttpResponseResult;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.security.SecurityConstants;
|
|
|
import io.swagger.annotations.Api;
|
|
@@ -41,6 +42,25 @@ public class SmsCodeController extends BaseController {
|
|
|
return succeed();
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "发送登录短信验证码")
|
|
|
+ @ApiImplicitParams({ @ApiImplicitParam(name = "phone", value = "手机号", required = true, dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "code", value = "验证码", required = true, dataType = "String") })
|
|
|
+ @PostMapping(value = "/sendSmsCode")
|
|
|
+ public HttpResponseResult<Object> sendLoginVerifyCode1(String mobile, String code) throws Exception {
|
|
|
+ if(StringUtils.isEmpty(mobile) || StringUtils.isEmpty(code)){
|
|
|
+ return failed(SecurityConstants.PARAM_VERIFY_EXCEPTION);
|
|
|
+ }
|
|
|
+ String redisKey = MessageTypeEnum.KAPTCHA_SESSION_KEY + mobile;
|
|
|
+ RBucket<String> bucket = redissonClient.getBucket(redisKey);
|
|
|
+ if(bucket.isExists()){
|
|
|
+ if(StringUtils.equalsIgnoreCase(bucket.get(),code)){
|
|
|
+ smsCodeService.sendValidCode(mobile);
|
|
|
+ return succeed();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return failed(SecurityConstants.VERIFY_FAILURE);
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value = "校验短信验证码")
|
|
|
@ApiImplicitParams({ @ApiImplicitParam(name = "phone", value = "手机号", required = true, dataType = "String"),
|
|
|
@ApiImplicitParam(name = "code", value = "短信验证码", required = true, dataType = "String") })
|