fixbug手机号校验
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.sv.api.service.impl;
|
||||
|
||||
import com.common.utils.VenueValidateUtils;
|
||||
import com.enums.MemberAuthTypeEnum;
|
||||
import com.enums.MemberStatusEnum;
|
||||
import com.sv.api.context.PlatformContext;
|
||||
@@ -66,7 +67,7 @@ public class LoginRegisterServiceImpl extends BaseServiceImpl {
|
||||
@Transactional
|
||||
public MemberTokenDTO registerByMobile(String mobile,String captcha,String name,Integer sex,Integer age,String address){
|
||||
ValidationUtils.assertNotBlank(mobile, "请输入手机号码");
|
||||
ValidationUtils.assertMobile(mobile);
|
||||
VenueValidateUtils.assertMobile(mobile);
|
||||
ValidationUtils.assertNotNull(captcha);
|
||||
|
||||
// 校验验证码是否正确
|
||||
@@ -102,7 +103,7 @@ public class LoginRegisterServiceImpl extends BaseServiceImpl {
|
||||
public MemberTokenDTO loginByMobile(String mobile, String captcha){
|
||||
// 参数校验
|
||||
ValidationUtils.assertNotBlank(mobile, "请输入手机号码");
|
||||
ValidationUtils.assertMobile(mobile);
|
||||
VenueValidateUtils.assertMobile(mobile);
|
||||
ValidationUtils.assertNotBlank(captcha, "请输入验证码");
|
||||
// 校验验证码是否正确
|
||||
captchaCacheService.assertCaptcha(mobile, ApiConstants.LOGIN_SMS_CAPTCHA_PREFIX, captcha);
|
||||
@@ -218,7 +219,7 @@ public class LoginRegisterServiceImpl extends BaseServiceImpl {
|
||||
public MemberTokenDTO bildMobile(BindMobileDTO bindMobileDTO){
|
||||
// 参数校验
|
||||
ValidationUtils.assertNotBlank(bindMobileDTO.getMobile(), "请输入手机号码");
|
||||
ValidationUtils.assertMobile(bindMobileDTO.getMobile());
|
||||
VenueValidateUtils.assertMobile(bindMobileDTO.getMobile());
|
||||
ValidationUtils.assertNotNull(bindMobileDTO.getNickname());
|
||||
ValidationUtils.assertNotNull(bindMobileDTO.getAvatar());
|
||||
ValidationUtils.assertNotNull(bindMobileDTO.getOpenId());
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.common.utils;
|
||||
|
||||
import com.ydd.framework.core.exception.ExceptionCodeTemplate;
|
||||
import com.ydd.framework.core.exception.ServiceException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* replace jar Validate
|
||||
*/
|
||||
public class VenueValidateUtils {
|
||||
public static boolean isMobile(String mobile) {
|
||||
if (StringUtils.isNotBlank(mobile)) {
|
||||
Pattern pattern = Pattern.compile("^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$");
|
||||
return pattern.matcher(mobile).matches();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static void assertMobile(String mobile) {
|
||||
if (!StringUtils.isBlank(mobile) && !isMobile(mobile)) {
|
||||
throw new ServiceException(ExceptionCodeTemplate.INVALID_MOBILE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,7 +129,9 @@
|
||||
<div class="dialog_div">
|
||||
<span>选择复制起期:</span>
|
||||
<el-date-picker
|
||||
class="filter-item" v-model="copyParam.leftDate" type="date" placeholder="选择复制起期"
|
||||
class="filter-item"
|
||||
@change="onCopyStartTimeChange"
|
||||
v-model="copyParam.leftDate" type="date" placeholder="选择复制起期"
|
||||
:picker-options="startDatePicker"
|
||||
value-format="yyyy-MM-dd" format="yyyy-MM-dd">
|
||||
</el-date-picker>
|
||||
@@ -137,7 +139,9 @@
|
||||
<div class="dialog_div">
|
||||
<span>选择复制止期:</span>
|
||||
<el-date-picker
|
||||
class="filter-item" v-model="copyParam.rightDate" type="date" placeholder="选择复制止期"
|
||||
class="filter-item"
|
||||
@change="onCopyEndTimeChange"
|
||||
v-model="copyParam.rightDate" type="date" placeholder="选择复制止期"
|
||||
:picker-options="endDatePicker"
|
||||
value-format="yyyy-MM-dd" format="yyyy-MM-dd">
|
||||
</el-date-picker>
|
||||
@@ -274,7 +278,7 @@ export default {
|
||||
return {
|
||||
disabledDate(time) {
|
||||
if (self.copyParam.rightDate && time.getTime() > Date.now()) {
|
||||
return new Date(self.form.rightDate).getTime() < time.getTime()
|
||||
return new Date(self.copyParam.rightDate).getTime() < new Date(time).getTime()
|
||||
} else {
|
||||
return time.getTime() < Date.now()
|
||||
}
|
||||
@@ -286,7 +290,10 @@ export default {
|
||||
return {
|
||||
disabledDate(time) {
|
||||
if (self.copyParam.leftDate) {
|
||||
return new Date(self.copyParam.leftDate).getTime() > time.getTime()
|
||||
if (new Date(self.copyParam.leftDate).getDate() === new Date(time).getDate()) {
|
||||
return false
|
||||
}
|
||||
return new Date(self.copyParam.leftDate).getTime() > new Date(time).getTime()
|
||||
} else {
|
||||
return time.getTime() < Date.now()
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.sv.service.api;
|
||||
|
||||
import com.common.utils.VenueValidateUtils;
|
||||
import com.enums.MemberStatusEnum;
|
||||
import com.enums.MoneyLogEnum;
|
||||
import com.enums.PayTypeEnum;
|
||||
@@ -214,7 +215,7 @@ public class MemberService extends BaseServiceImpl {
|
||||
public Member createByMobile(String mobile, String name, Integer sex, Integer age, String address, Integer platformId) {
|
||||
// 参数校验
|
||||
ValidationUtils.assertNotNull(mobile);
|
||||
ValidationUtils.assertMobile(mobile);
|
||||
VenueValidateUtils.assertMobile(mobile);
|
||||
|
||||
// 验证手机号码是否存在
|
||||
assertMobileNotUsed(mobile, null);
|
||||
@@ -433,7 +434,7 @@ public class MemberService extends BaseServiceImpl {
|
||||
}
|
||||
|
||||
if (informationDTO.getMobile() != null) {
|
||||
ValidationUtils.assertMobile(informationDTO.getMobile()); // 校验手机号码格式
|
||||
VenueValidateUtils.assertMobile(informationDTO.getMobile()); // 校验手机号码格式
|
||||
ValidationUtils.assertNotNull(informationDTO.getCaptcha()); // 验证码不能为空
|
||||
// 校验验证码是否正确
|
||||
captchaCacheService.assertCaptcha(informationDTO.getMobile(), ApiConstants.UPDATE_PHONE_SMS_CAPTCHA_PREFIX, informationDTO.getCaptcha());
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.sv.service.common;
|
||||
|
||||
import com.common.Sms;
|
||||
import com.common.utils.VenueValidateUtils;
|
||||
import com.enums.SmsEnum;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.sv.exception.api.ExceptionCodeTemplate;
|
||||
@@ -69,7 +70,7 @@ public class SmsService extends BaseServiceImpl {
|
||||
@Transactional
|
||||
public void sendRegisterCaptcha(String mobile, Integer type) {
|
||||
ValidationUtils.assertNotBlank(mobile, "请输入手机号码");
|
||||
ValidationUtils.assertMobile(mobile);
|
||||
VenueValidateUtils.assertMobile(mobile);
|
||||
|
||||
// 验证码手机号码是否存在
|
||||
String prefix = ApiConstants.REGISTER_SMS_CAPTCHA_PREFIX;
|
||||
@@ -105,7 +106,7 @@ public class SmsService extends BaseServiceImpl {
|
||||
@Transactional
|
||||
public void sendLoginCaptcha(String mobile) {
|
||||
ValidationUtils.assertNotBlank(mobile, "请输入手机号码");
|
||||
ValidationUtils.assertMobile(mobile);
|
||||
VenueValidateUtils.assertMobile(mobile);
|
||||
|
||||
if (!memberService.isMobileExists(mobile, null)) {
|
||||
// 手机号码不存在
|
||||
@@ -130,7 +131,7 @@ public class SmsService extends BaseServiceImpl {
|
||||
@Transactional
|
||||
public void sendUpdatePhoneCaptcha(String mobile) {
|
||||
ValidationUtils.assertNotBlank(mobile, "请输入手机号码");
|
||||
ValidationUtils.assertMobile(mobile);
|
||||
VenueValidateUtils.assertMobile(mobile);
|
||||
|
||||
if (memberService.isMobileExists(mobile, null)) {
|
||||
// 手机号码已存在
|
||||
@@ -267,7 +268,7 @@ public class SmsService extends BaseServiceImpl {
|
||||
@Transactional
|
||||
public void record(String mobile, String content, SmsTypeEnum type, SmsStatusEnum status, SmsEnum platform) {
|
||||
ValidationUtils.assertNotNull(mobile, content, type, status, platform);
|
||||
ValidationUtils.assertMobile(mobile);
|
||||
VenueValidateUtils.assertMobile(mobile);
|
||||
|
||||
// 保存短信内容
|
||||
Sms sms = new Sms();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package com.sv.service.oms;
|
||||
import com.common.utils.VenueValidateUtils;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.sv.dto.api.MemberTokenDTO;
|
||||
import com.sv.entity.MemberAuth;
|
||||
@@ -154,7 +155,7 @@ public class MemberService extends MemberCardCommonService {
|
||||
*/
|
||||
public void saveMember(Member member){
|
||||
ValidationUtils.assertNotBlank(member.getMobile(), "请输入手机号码");
|
||||
ValidationUtils.assertMobile(member.getMobile());
|
||||
VenueValidateUtils.assertMobile(member.getMobile());
|
||||
|
||||
synchronized (member.getMobile()){
|
||||
// 根据手机号码创建新用户
|
||||
@@ -171,7 +172,7 @@ public class MemberService extends MemberCardCommonService {
|
||||
public Member createByMobile(Member member) {
|
||||
// 参数校验
|
||||
ValidationUtils.assertNotNull(member.getMobile());
|
||||
ValidationUtils.assertMobile(member.getMobile());
|
||||
VenueValidateUtils.assertMobile(member.getMobile());
|
||||
|
||||
// 创建用户
|
||||
String regEx = "[ _`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]|\n|\r|\t";
|
||||
|
||||
Reference in New Issue
Block a user