校验上传文件中的手机号
This commit is contained in:
parent
2c78ee9ff7
commit
2e3a03a0ca
|
|
@ -80,6 +80,20 @@ public class WorkerServiceImpl implements WorkerService {
|
||||||
return workerMapper.updateWorker(workerVo);
|
return workerMapper.updateWorker(workerVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验手机号格式
|
||||||
|
* @param phone 手机号
|
||||||
|
* @return true-合法 false-不合法
|
||||||
|
*/
|
||||||
|
private boolean isValidPhone(String phone) {
|
||||||
|
if (StringUtils.isEmpty(phone)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 中国大陆手机号正则表达式:1开头,第二位为3-9,后面9位数字
|
||||||
|
String regex = "^1[3-9]\\d{9}$";
|
||||||
|
return phone.matches(regex);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入人员
|
* 导入人员
|
||||||
*/
|
*/
|
||||||
|
|
@ -96,6 +110,10 @@ public class WorkerServiceImpl implements WorkerService {
|
||||||
){
|
){
|
||||||
return "缺少必填项";
|
return "缺少必填项";
|
||||||
}
|
}
|
||||||
|
//校验手机号格式
|
||||||
|
if (!isValidPhone(workerVo.getPhone())) {
|
||||||
|
return "手机号格式不正确";
|
||||||
|
}
|
||||||
|
|
||||||
SysDept sysDept = workerMapper.getDeptById(workerVo);
|
SysDept sysDept = workerMapper.getDeptById(workerVo);
|
||||||
if (sysDept != null){
|
if (sysDept != null){
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue