feat: 编辑器增加版本状态(预览版/正式版)和未保存提示
This commit is contained in:
@@ -7,6 +7,7 @@ import com.par.core.dto.SiteConfigDTO;
|
||||
import com.par.core.entity.Account;
|
||||
import com.par.core.entity.Psk;
|
||||
import com.par.core.entity.SiteConfig;
|
||||
import com.par.core.entity.SiteSnapshot;
|
||||
import com.par.core.enums.ConfigStatus;
|
||||
import com.par.core.enums.TrustLevel;
|
||||
import com.par.core.event.SnapshotUpdateEvent;
|
||||
@@ -14,6 +15,7 @@ import com.par.core.mapper.AccountMapper;
|
||||
import com.par.core.mapper.ConfigReviewMapper;
|
||||
import com.par.core.mapper.SiteConfigMapper;
|
||||
import com.par.core.mapper.SiteMapper;
|
||||
import com.par.core.mapper.SiteSnapshotMapper;
|
||||
import com.par.core.service.AccountService;
|
||||
import com.par.core.service.ConfigService;
|
||||
import com.par.core.service.PskService;
|
||||
@@ -44,6 +46,7 @@ public class AdminController {
|
||||
private final ConfigReviewMapper configReviewMapper;
|
||||
private final AccountMapper accountMapper;
|
||||
private final SiteMapper siteMapper;
|
||||
private final SiteSnapshotMapper snapshotMapper;
|
||||
private final AccountService accountService;
|
||||
private final PskService pskService;
|
||||
private final ConfigService configService;
|
||||
@@ -418,6 +421,47 @@ public class AdminController {
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询站点快照状态(draft / published 版本信息) */
|
||||
@GetMapping("/sites/{siteId}/snapshot-status")
|
||||
public ApiResponse<Map<String, Object>> getSnapshotStatus(@PathVariable("siteId") String siteId,
|
||||
HttpServletRequest request) {
|
||||
checkAdmin(request);
|
||||
SiteSnapshot draft = snapshotMapper.selectLatestDraft(siteId);
|
||||
SiteSnapshot published = snapshotMapper.selectLatestPublished(siteId);
|
||||
|
||||
Map<String, Object> result = new LinkedHashMap<>();
|
||||
result.put("siteId", siteId);
|
||||
|
||||
Map<String, Object> draftInfo = new LinkedHashMap<>();
|
||||
if (draft != null) {
|
||||
draftInfo.put("exists", true);
|
||||
draftInfo.put("version", draft.getVersion());
|
||||
draftInfo.put("checksum", draft.getChecksum() != null ? draft.getChecksum().substring(0, 8) : null);
|
||||
draftInfo.put("updatedAt", draft.getUpdatedAt() != null ? draft.getUpdatedAt().toString() : null);
|
||||
} else {
|
||||
draftInfo.put("exists", false);
|
||||
}
|
||||
result.put("draft", draftInfo);
|
||||
|
||||
Map<String, Object> pubInfo = new LinkedHashMap<>();
|
||||
if (published != null) {
|
||||
pubInfo.put("exists", true);
|
||||
pubInfo.put("version", published.getVersion());
|
||||
pubInfo.put("checksum", published.getChecksum() != null ? published.getChecksum().substring(0, 8) : null);
|
||||
pubInfo.put("publishedAt", published.getPublishedAt() != null ? published.getPublishedAt().toString() : null);
|
||||
} else {
|
||||
pubInfo.put("exists", false);
|
||||
}
|
||||
result.put("published", pubInfo);
|
||||
|
||||
// 是否有新 draft 待发布(draft 存在且与 published 不同)
|
||||
boolean hasPendingPublish = draft != null && (published == null
|
||||
|| (draft.getChecksum() != null && !draft.getChecksum().equals(published.getChecksum())));
|
||||
result.put("hasPendingPublish", hasPendingPublish);
|
||||
|
||||
return ApiResponse.success(result);
|
||||
}
|
||||
|
||||
@GetMapping("/sites")
|
||||
public ApiResponse<List<com.par.core.dto.SiteDTO>> listAllSites(HttpServletRequest request) {
|
||||
checkAdmin(request);
|
||||
|
||||
Reference in New Issue
Block a user