fix: 创建新 draft 前先清理旧 draft,避免旧预览版残留导致版本号显示错误

每次 savePreview/updateSnapshot 插入新 draft 前 deleteBySiteIdAndStatus('draft'),确保每站点最多一个预览版
This commit is contained in:
mediabot-pt
2026-07-07 23:56:46 +08:00
parent b19821bf83
commit 6de1df9acf

View File

@@ -138,6 +138,9 @@ public class SiteSnapshotServiceImpl implements SiteSnapshotService {
int newVersion = snapshotMapper.selectMaxVersion(siteId) + 1;
// 清理旧 draft(确保一个站点最多一个预览版)
snapshotMapper.deleteBySiteIdAndStatus(siteId, "draft");
SiteSnapshot snapshot = new SiteSnapshot();
snapshot.setSiteId(siteId);
snapshot.setVersion(newVersion);
@@ -181,6 +184,9 @@ public class SiteSnapshotServiceImpl implements SiteSnapshotService {
int newVersion = snapshotMapper.selectMaxVersion(siteId) + 1;
// 清理旧 draft(确保一个站点最多一个预览版)
snapshotMapper.deleteBySiteIdAndStatus(siteId, "draft");
SiteSnapshot snapshot = new SiteSnapshot();
snapshot.setSiteId(siteId);
snapshot.setVersion(newVersion);