diff --git a/luoo_user/src/main/java/com/luoo/user/controller/LoginController.java b/luoo_user/src/main/java/com/luoo/user/controller/LoginController.java index 926b4e2..4c14efa 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/LoginController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/LoginController.java @@ -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 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 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(); } diff --git a/luoo_user/src/main/java/com/luoo/user/dto/request/SendSmsReq.java b/luoo_user/src/main/java/com/luoo/user/dto/request/SendSmsReq.java new file mode 100644 index 0000000..86e6883 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/dto/request/SendSmsReq.java @@ -0,0 +1,33 @@ +package com.luoo.user.dto.request; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import java.io.Serializable; + +import annotation.VerifyParam; +import enums.VerifyRegexEnum; + +/** + * 期刊查询参数 + */ +@Getter +@Setter +@ApiModel +public class SendSmsReq implements Serializable { + private static final long serialVersionUID = 1L; + @ApiModelProperty(name = "mobile", value = "手机号", required = true) + @VerifyParam(required = true, regex = VerifyRegexEnum.MOBILE) + private String mobile; + + @ApiModelProperty(name = "deviceId", value = "设备id", required = true) + @VerifyParam(required = true) + private String deviceId; + + @ApiModelProperty(name = "countryCode", value = "国家码,默认为‘+86’", required = false, example="+86") + private String countryCode = "+86"; + + @ApiModelProperty(name = "imageCheckCode", value = "图形验证码", required = false) + private String imageCheckCode; +}