fix(cms): 修复编辑场景控制器缺失tenantId导致导航未绑定问题
- 编辑场景控制器未注入tenantId时从数据库获取原记录tenantId - 避免bindNavigation因tenantId为空导致无法命中数据行 - 确保导航关联数据正确写回数据库 - 提升编辑场景更新的稳定性和数据一致性
This commit is contained in:
@@ -6,10 +6,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.cms.entity.CmsDesign;
|
||||
import com.gxwebsoft.cms.entity.CmsModel;
|
||||
import com.gxwebsoft.cms.entity.CmsPage;
|
||||
import com.gxwebsoft.cms.mapper.CmsNavigationMapper;
|
||||
import com.gxwebsoft.cms.service.CmsDesignService;
|
||||
import com.gxwebsoft.cms.service.CmsModelService;
|
||||
import com.gxwebsoft.cms.service.CmsNavigationService;
|
||||
import com.gxwebsoft.cms.service.CmsPageService;
|
||||
import com.gxwebsoft.cms.entity.CmsNavigation;
|
||||
import com.gxwebsoft.cms.param.CmsNavigationParam;
|
||||
import com.gxwebsoft.common.core.exception.BusinessException;
|
||||
@@ -38,6 +40,8 @@ public class CmsNavigationServiceImpl extends ServiceImpl<CmsNavigationMapper, C
|
||||
private CmsModelService cmsModelService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private CmsPageService cmsPageService;
|
||||
|
||||
@Override
|
||||
public PageResult<CmsNavigation> pageRel(CmsNavigationParam param) {
|
||||
@@ -88,7 +92,11 @@ public class CmsNavigationServiceImpl extends ServiceImpl<CmsNavigationMapper, C
|
||||
|
||||
/**
|
||||
* 配置路由生成规则
|
||||
* path:/模型/导航ID
|
||||
* path:
|
||||
* 默认:/模型/导航ID(如 /page/1234、/article/1234)
|
||||
* 特例1:model=page + pageId 有值 → /page/{cmsPage.path}(与单页 slug 对齐,前台按 path 取 cms_page 内容)
|
||||
* 特例2:model=index 或 path="/" → 设为 "/"(默认首页)
|
||||
* 特例3:model=links → 保留用户传入的 path(外链原样使用)
|
||||
* component: /pages/模型/index.vue
|
||||
*/
|
||||
@Override
|
||||
@@ -106,6 +114,17 @@ public class CmsNavigationServiceImpl extends ServiceImpl<CmsNavigationMapper, C
|
||||
navigation.setPath(navigation.getPath() + model.getSuffix());
|
||||
}
|
||||
|
||||
// 1.3 特例:model=page 且绑定了 cmsPage 单页 → path 用单页 slug
|
||||
// 否则会生成 /page/{navigationId}(数字 ID),前台按 path 取不到内容。
|
||||
// 兜底:cmsPage 取不到或 path 为空时,沿用默认 /page/{navigationId}。
|
||||
if ("page".equals(navigation.getModel()) && navigation.getPageId() != null) {
|
||||
final CmsPage page = cmsPageService.getOne(
|
||||
new LambdaQueryWrapper<CmsPage>().eq(CmsPage::getPageId, navigation.getPageId()).last("limit 1"));
|
||||
if (ObjectUtil.isNotEmpty(page) && StrUtil.isNotBlank(page.getPath())) {
|
||||
navigation.setPath("/page/" + page.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
// 2.特例:默认首页
|
||||
if (navigation.getPath().equals("/") || navigation.getModel().equals("index")) {
|
||||
final long count = count(new LambdaQueryWrapper<CmsNavigation>().eq(CmsNavigation::getPath, "/").eq(CmsNavigation::getLang,navigation.getLang()));
|
||||
|
||||
Reference in New Issue
Block a user