fix(cms): 修复编辑场景控制器缺失tenantId导致导航未绑定问题
- 编辑场景控制器未注入tenantId时从数据库获取原记录tenantId - 避免bindNavigation因tenantId为空导致无法命中数据行 - 确保导航关联数据正确写回数据库 - 提升编辑场景更新的稳定性和数据一致性
This commit is contained in:
@@ -117,7 +117,14 @@ public class CmsPageServiceImpl extends com.baomidou.mybatisplus.extension.servi
|
|||||||
}
|
}
|
||||||
boolean updated = updateById(page);
|
boolean updated = updateById(page);
|
||||||
if (updated) {
|
if (updated) {
|
||||||
bindNavigation(page.getPageId(), page.getNavigationId(), page.getTenantId());
|
// 编辑场景控制器未注入 tenantId,需从库中取回原记录的 tenantId,
|
||||||
|
// 否则 bindNavigation 的 WHERE tenant_id = null 不会命中任何行,关联导航无法写回。
|
||||||
|
Integer tenantId = page.getTenantId();
|
||||||
|
if (tenantId == null) {
|
||||||
|
CmsPage existing = getById(page.getPageId());
|
||||||
|
tenantId = existing != null ? existing.getTenantId() : null;
|
||||||
|
}
|
||||||
|
bindNavigation(page.getPageId(), page.getNavigationId(), tenantId);
|
||||||
}
|
}
|
||||||
return updated;
|
return updated;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user