🐛 修复登录自动建档把脱敏手机号写入司机档案

This commit is contained in:
2026-10-23 18:05:20 +08:00
parent e54359c113
commit 7fa20747ab
4 changed files with 62 additions and 33 deletions
@@ -134,6 +134,10 @@ public class DriverServiceImpl extends BaseServiceImpl<DriverMapper, Driver> imp
if (mobile == null) {
throw new ServiceException("手机号不能为空");
}
// 脱敏手机号(如 155****2748)不是可用的业务数据:写进档案后按手机号查不到司机
if (mobile.contains("*")) {
throw new ServiceException("手机号无效,不能写入司机档案");
}
// 查找顺序固定为 user_id → phone:user_id 是账号的稳定标识,
// phone 会被运营商二次放号
Driver bound = findDriverByUserId(mpUserId);
@@ -214,6 +214,14 @@ class DriverEnsureProfileTest {
// ------------------------------------------------------------ 入参兜底
@Test
@DisplayName("脱敏手机号:拒绝写库,不新建档案")
void rejectsMaskedMobile() {
assertThrows(ServiceException.class, () -> service.ensureProfile(TENANT_ID, MP_USER_ID, "155****2748"));
verify(driverMapper, never()).insert(any(Driver.class));
verify(driverMapper, never()).updateById(any(Driver.class));
}
@Test
@DisplayName("租户为空且当前上下文也没有租户:拒绝写库")
void rejectsBlankTenant() {