From 2e3a03a0cad89d076a58a3bb68bba29f8ce064d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E4=B8=89=E7=82=AE?= <15856818120@163.com> Date: Tue, 3 Feb 2026 09:21:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E4=B8=8A=E4=BC=A0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=AD=E7=9A=84=E6=89=8B=E6=9C=BA=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/WorkerServiceImpl.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/bonus-business/src/main/java/com/bonus/message/service/impl/WorkerServiceImpl.java b/bonus-business/src/main/java/com/bonus/message/service/impl/WorkerServiceImpl.java index a7f2f7d..c908ce0 100644 --- a/bonus-business/src/main/java/com/bonus/message/service/impl/WorkerServiceImpl.java +++ b/bonus-business/src/main/java/com/bonus/message/service/impl/WorkerServiceImpl.java @@ -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){