From 5777a02823a7a8394c0b954fce5019cf1a7e47ea Mon Sep 17 00:00:00 2001 From: mediabot-pt <295750538+mediabot-pt@users.noreply.github.com> Date: Tue, 7 Jul 2026 13:24:03 +0800 Subject: [PATCH] =?UTF-8?q?revert:=20=E5=9B=9E=E9=80=80=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A7=E5=BF=AB=E7=85=A7=E7=9A=84=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E4=BF=9D=E7=95=99=E5=AE=8C=E6=95=B4=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E7=89=88=E6=9C=AC=E4=BE=9B=E4=BA=BA=E5=B7=A5=E6=81=A2?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/SiteSnapshotServiceImpl.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/par-core/src/main/java/com/par/core/service/impl/SiteSnapshotServiceImpl.java b/par-core/src/main/java/com/par/core/service/impl/SiteSnapshotServiceImpl.java index 26076ee..0596067 100644 --- a/par-core/src/main/java/com/par/core/service/impl/SiteSnapshotServiceImpl.java +++ b/par-core/src/main/java/com/par/core/service/impl/SiteSnapshotServiceImpl.java @@ -134,12 +134,11 @@ public class SiteSnapshotServiceImpl implements SiteSnapshotService { return null; } - // 删除旧 draft,保证最新只有一条 - snapshotMapper.deleteBySiteIdAndStatus(siteId, "draft"); + int newVersion = (latestDraft != null) ? latestDraft.getVersion() + 1 : 1; SiteSnapshot snapshot = new SiteSnapshot(); snapshot.setSiteId(siteId); - snapshot.setVersion((latestDraft != null) ? latestDraft.getVersion() + 1 : 1); + snapshot.setVersion(newVersion); populateSnapshotFields(snapshot, data); snapshot.setChecksum(checksum); snapshot.setStatus("draft"); @@ -150,7 +149,7 @@ public class SiteSnapshotServiceImpl implements SiteSnapshotService { String bundleJson = toBundleJson(snapshot); jsonCache.put(draftKey(siteId), bundleJson); - log.info("快照已更新: siteId={}, version={}, checksum={}", siteId, snapshot.getVersion(), checksum.substring(0, 8)); + log.info("快照已更新: siteId={}, version={}, checksum={}", siteId, newVersion, checksum.substring(0, 8)); return snapshot; } catch (Exception e) { log.error("更新快照失败 siteId={}", siteId, e); @@ -178,12 +177,11 @@ public class SiteSnapshotServiceImpl implements SiteSnapshotService { return latestDraft; } - // 删除旧 draft,保证最新只有一条 - snapshotMapper.deleteBySiteIdAndStatus(siteId, "draft"); + int newVersion = (latestDraft != null) ? latestDraft.getVersion() + 1 : 1; SiteSnapshot snapshot = new SiteSnapshot(); snapshot.setSiteId(siteId); - snapshot.setVersion((latestDraft != null) ? latestDraft.getVersion() + 1 : 1); + snapshot.setVersion(newVersion); populateSnapshotFields(snapshot, data); snapshot.setChecksum(checksum); snapshot.setStatus("draft"); @@ -194,7 +192,7 @@ public class SiteSnapshotServiceImpl implements SiteSnapshotService { String bundleJson = toBundleJson(snapshot); jsonCache.put(draftKey(siteId), bundleJson); - log.info("预览版已保存: siteId={}, version={}, checksum={}", siteId, snapshot.getVersion(), checksum.substring(0, 8)); + log.info("预览版已保存: siteId={}, version={}, checksum={}", siteId, newVersion, checksum.substring(0, 8)); return snapshot; } catch (Exception e) { log.error("保存预览版失败 siteId={}", siteId, e); @@ -236,8 +234,7 @@ public class SiteSnapshotServiceImpl implements SiteSnapshotService { return current; } - // 先删旧 published,再改当前 draft 为 published(事务保证原子性) - snapshotMapper.deleteBySiteIdAndStatus(siteId, "published"); + // 更新状态为 published draft.setStatus("published"); draft.setPublishedAt(LocalDateTime.now()); snapshotMapper.updateById(draft);