|
@@ -13,12 +13,11 @@ import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Random;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 短信服务层接口实现
|
|
@@ -46,16 +45,26 @@ public class SmsServiceImpl implements ISmsService {
|
|
|
|
|
|
/**
|
|
|
* 发送短信验证码
|
|
|
- * @param user
|
|
|
* @param type
|
|
|
* @param phone
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public Response sendVerificationCode(SysUser user, String type, String phone) {
|
|
|
+ public Response sendVerificationCode(String type, String phone) {
|
|
|
//字符编码
|
|
|
String charset = "UTF-8";
|
|
|
|
|
|
+ //type验证
|
|
|
+ List<String> collect = Arrays.stream(SmsTemplateConstants.smsTemplateType)
|
|
|
+ .parallel()
|
|
|
+ .filter(str -> str.equals(type))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ System.out.println(collect);
|
|
|
+ if (collect.size()==0){
|
|
|
+ return Response.error(500,"参数{type}类型错误");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//手机号格式验证
|
|
|
if(phone.length() != 11){
|
|
|
return Response.error(500,"手机格式错误");
|
|
@@ -83,9 +92,6 @@ public class SmsServiceImpl implements ISmsService {
|
|
|
smsTemplateStr = SmsTemplateConstants.login;
|
|
|
}
|
|
|
if (type.equals("modify")){
|
|
|
- if (user.getPhonenumber().equals(phone)){
|
|
|
- return Response.error(500,"该手机号与当前绑定的手机号相同");
|
|
|
- }
|
|
|
map.put("keyPrefix",Constants.SMS_MODIFY_CODE);
|
|
|
map.put("verificationCount",Constants.SMS_MODIFY_CODE_COUNT);
|
|
|
smsTemplateStr = SmsTemplateConstants.modify;
|