|
@@ -1,5 +1,8 @@
|
|
|
package com.charging.chargingparking.modules.mobileController;
|
|
|
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import javax.validation.constraints.NotBlank;
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
import javax.validation.constraints.Pattern;
|
|
|
|
|
@@ -9,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import com.charging.chargingparking.dto.MessageResult;
|
|
|
+import com.charging.chargingparking.modules.mobileservice.MobileAuthService;
|
|
|
import com.charging.chargingparking.utils.RespVO;
|
|
|
import com.charging.chargingparking.utils.RespVOBuilder;
|
|
|
import com.charging.chargingparking.utils.SMSUtil;
|
|
@@ -22,6 +26,9 @@ public class MobileAuthController {
|
|
|
|
|
|
@Autowired
|
|
|
private VerifyCoder verifyCoder;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MobileAuthService service;
|
|
|
|
|
|
/**
|
|
|
* 获取验证码
|
|
@@ -48,16 +55,20 @@ public class MobileAuthController {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping("/checkLogin")
|
|
|
- public RespVO checkLogin(@NotNull(message = "手机号不能为空") @Pattern(regexp = "^1[3-9]\\d{9}", message = "手机号无效") String phoneNum,String verifyCode) {
|
|
|
+ public RespVO checkLogin(@NotNull(message = "手机号不能为空") @Pattern(regexp = "^1[3-9]\\d{9}", message = "手机号无效") String phoneNum,@NotBlank(message = "验证码不能为空") String verifyCode) {
|
|
|
+ Map<String,Object> us=service.getUserByPhone(phoneNum);
|
|
|
+ if(us==null||us.size()==0) {
|
|
|
+ return RespVOBuilder.error("非系统内的用户");
|
|
|
+ }
|
|
|
String refVerifyCode=verifyCoder.getFromSession(phoneNum);
|
|
|
if(refVerifyCode==null) {
|
|
|
- return RespVOBuilder.error("验证码错误或已过期");
|
|
|
+ return RespVOBuilder.error("验证码已失效,请重新获取");
|
|
|
}
|
|
|
if(!verifyCode.equals(refVerifyCode)) {
|
|
|
return RespVOBuilder.error("验证码输入错误");
|
|
|
}
|
|
|
//验证通过后,清除验证码缓存
|
|
|
verifyCoder.clear(phoneNum);
|
|
|
- return RespVOBuilder.ok();
|
|
|
+ return RespVOBuilder.ok("验证通过");
|
|
|
}
|
|
|
}
|