校验上传文件中的手机号

This commit is contained in:
马三炮 2026-02-03 09:21:45 +08:00
parent 2c78ee9ff7
commit 2e3a03a0ca
1 changed files with 18 additions and 0 deletions

View File

@ -80,6 +80,20 @@ public class WorkerServiceImpl implements WorkerService {
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 "缺少必填项";
}
//校验手机号格式
if (!isValidPhone(workerVo.getPhone())) {
return "手机号格式不正确";
}
SysDept sysDept = workerMapper.getDeptById(workerVo);
if (sysDept != null){