|
|
|
@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import constants.Constants;
|
|
|
|
|
import controller.BaseController;
|
|
|
|
|
|
|
|
|
|
import com.luoo.user.dto.request.SendSmsReq;
|
|
|
|
|
import com.luoo.user.dto.response.CountryCodeDTO;
|
|
|
|
|
import com.luoo.user.dto.response.CreateImageCode;
|
|
|
|
|
import com.luoo.user.pojo.UserInfo;
|
|
|
|
@ -73,30 +74,23 @@ public class LoginController extends BaseController {
|
|
|
|
|
* 发送短信验证码
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation(value = "1.发送短信验证码", notes = "有效期15分钟,一个手机号一天内最多发送50个请求")
|
|
|
|
|
@ApiImplicitParams({ @ApiImplicitParam(name = "mobile", value = "手机号", required = true),
|
|
|
|
|
@ApiImplicitParam(name = "countryCode", value = "国家码,默认为‘+86’", required = false, defaultValue = "+86"),
|
|
|
|
|
@ApiImplicitParam(name = "deviceId", value = "设备id", required = true),
|
|
|
|
|
@ApiImplicitParam(name = "imageCheckCode", value = "图形验证码", required = false) })
|
|
|
|
|
@PostMapping("/sendsms")
|
|
|
|
|
@GlobalInterceptor(frequencyType = RequestFrequencyTypeEnum.DAY, requestFrequencyThreshold = 50)
|
|
|
|
|
public Result<Void> sendSms(@VerifyParam(required = true) @RequestParam("deviceId") String deviceId,
|
|
|
|
|
@RequestParam(name = "countryCode", defaultValue = "+86") String countryCode,
|
|
|
|
|
@VerifyParam(required = true, regex = VerifyRegexEnum.MOBILE) @RequestParam("mobile") String mobile,
|
|
|
|
|
@VerifyParam(required = false) @RequestParam("imageCheckCode") String imageCheckCode) {
|
|
|
|
|
if (!StringTools.isEmpty(imageCheckCode)) {
|
|
|
|
|
public Result<Void> sendSms(@VerifyParam SendSmsReq sendSmsReq) {
|
|
|
|
|
if (!StringTools.isEmpty(sendSmsReq.getImageCheckCode())) {
|
|
|
|
|
// 得到缓存中的验证码
|
|
|
|
|
String redisImageCheckCodeKey = Constants.REDIS_KEY_IMAGE_CHECK_CODE + deviceId;
|
|
|
|
|
String redisImageCheckCodeKey = Constants.REDIS_KEY_IMAGE_CHECK_CODE + sendSmsReq.getDeviceId();
|
|
|
|
|
String redisImageCheckCode = (String) redisTemplate.opsForValue().get(redisImageCheckCodeKey);
|
|
|
|
|
if (StringTools.isEmpty(redisImageCheckCode)) {
|
|
|
|
|
return Result.failed(StatusCode.USER_IMAGE_VERIFICATION_CODE_EXPIRED);
|
|
|
|
|
}
|
|
|
|
|
if (!redisImageCheckCode.equalsIgnoreCase(imageCheckCode)) {
|
|
|
|
|
if (!redisImageCheckCode.equalsIgnoreCase(sendSmsReq.getImageCheckCode())) {
|
|
|
|
|
return Result.failed(StatusCode.USER_IMAGE_VERIFICATION_CODE_MISMATCH);
|
|
|
|
|
}
|
|
|
|
|
redisTemplate.delete(redisImageCheckCodeKey);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
userInfoService.sendSms(deviceId, mobile);
|
|
|
|
|
userInfoService.sendSms(sendSmsReq.getDeviceId(), sendSmsReq.getMobile());
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|