refactor(cms): 优化网站创建时的数据复制逻辑
- 仅在templateId存在且大于0时执行数据复制操作 - 添加无效模板ID时的日志警告提示-保持原有国际化、参数、模型、广告、链接及栏目文章的复制逻辑- 修复可能因templateId为null导致的潜在空指针异常
This commit is contained in:
@@ -173,9 +173,10 @@ public class CmsWebsiteServiceImpl extends ServiceImpl<CmsWebsiteMapper, CmsWebs
|
|||||||
// cmsWebsiteSettingService.save(setting);
|
// cmsWebsiteSettingService.save(setting);
|
||||||
|
|
||||||
// 将网站创建者的userId做为查询条件 10257(4716),10324(6978),10398(26564)
|
// 将网站创建者的userId做为查询条件 10257(4716),10324(6978),10398(26564)
|
||||||
Integer websiteUserId = website.getTemplateId() != null ? website.getTemplateId() : 0;
|
Integer websiteUserId = website.getTemplateId();
|
||||||
|
|
||||||
|
|
||||||
|
// 只有当templateId存在时才执行复制操作
|
||||||
|
if (websiteUserId != null && websiteUserId > 0) {
|
||||||
// TODO 国际化
|
// TODO 国际化
|
||||||
final CmsLangLogParam cmsLangLogParam = new CmsLangLogParam();
|
final CmsLangLogParam cmsLangLogParam = new CmsLangLogParam();
|
||||||
cmsLangLogParam.setWebsiteUserId(websiteUserId);
|
cmsLangLogParam.setWebsiteUserId(websiteUserId);
|
||||||
@@ -224,17 +225,6 @@ public class CmsWebsiteServiceImpl extends ServiceImpl<CmsWebsiteMapper, CmsWebs
|
|||||||
});
|
});
|
||||||
cmsLinkService.saveBatch(links);
|
cmsLinkService.saveBatch(links);
|
||||||
|
|
||||||
// TODO 复制订单
|
|
||||||
// CmsOrderParam cmsOrderParam = new CmsOrderParam();
|
|
||||||
// cmsOrderParam.setWebsiteUserId(websiteUserId);
|
|
||||||
// final List<CmsOrder> orders = cmsOrderMapper.selectListAllRel(cmsOrderParam);
|
|
||||||
// orders.forEach(d -> {
|
|
||||||
// d.setUserId(loginUser.getUserId());
|
|
||||||
// d.setTenantId(loginUser.getTenantId());
|
|
||||||
// });
|
|
||||||
// cmsOrderService.saveBatch(orders);
|
|
||||||
|
|
||||||
|
|
||||||
// TODO 复制栏目和文章、文章内容
|
// TODO 复制栏目和文章、文章内容
|
||||||
CmsNavigationParam cmsNavigationParam = new CmsNavigationParam();
|
CmsNavigationParam cmsNavigationParam = new CmsNavigationParam();
|
||||||
cmsNavigationParam.setWebsiteUserId(websiteUserId);
|
cmsNavigationParam.setWebsiteUserId(websiteUserId);
|
||||||
@@ -290,6 +280,9 @@ public class CmsWebsiteServiceImpl extends ServiceImpl<CmsWebsiteMapper, CmsWebs
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
log.warn("没有有效的模板ID,跳过复制操作");
|
||||||
|
}
|
||||||
|
|
||||||
// 新增项目
|
// 新增项目
|
||||||
final Project project = new Project();
|
final Project project = new Project();
|
||||||
|
|||||||
Reference in New Issue
Block a user