🐛 空组织司机保存时不再发起组织反查

This commit is contained in:
2026-10-25 20:20:59 +08:00
parent f5f09fd2f0
commit 5bcb908cbd
2 changed files with 49 additions and 34 deletions
@@ -474,12 +474,15 @@ public class DriverServiceImpl extends BaseServiceImpl<DriverMapper, Driver> imp
// 按「组织名称」反查组织树 id:组织改名后这里必然落空——不报错、不掉数据,
// 只是该司机账号的权限不再随组织变化(新建账号落空时数据权限为空集,管理端看不到)。
// 组织为空同样落空,此时 deptId 传 null 而不是空串:updateUser 的 updateById 忽略 null,
// 账号原有的组织与数据权限得以保留;写成空串会把它们覆盖掉。
// 组织为空时不做反查:DeptServiceImpl 会把空名称拆成空集合,MyBatis-Plus 的 inExpression
// 对空集合拼出 dept_name IN () 非法子句。此时 deptId 保持 null 而不是空串:updateUser 的
// updateById 忽略 null,账号原有的组织与数据权限得以保留;写成空串会把它们覆盖掉。
String deptId = null;
R<String> deptResult = sysClient.getDeptIds(tenantId, driver.getOrganizationName());
if (deptResult != null && R.isSuccess(deptResult) && Func.isNotEmpty(deptResult.getData())) {
deptId = deptResult.getData();
if (Func.isNotEmpty(driver.getOrganizationName())) {
R<String> deptResult = sysClient.getDeptIds(tenantId, driver.getOrganizationName());
if (deptResult != null && R.isSuccess(deptResult) && Func.isNotEmpty(deptResult.getData())) {
deptId = deptResult.getData();
}
}
MpUser existing = findExistingMpUser(driver, tenantId, mobile);