refactor: 文件路径按pending/approved区分,去掉版本号
- submit: configs/{siteId}/pending/{hash}.json
- approve: 文件移到 configs/{siteId}/approved/{hash}.json
This commit is contained in:
@@ -13,6 +13,7 @@ import com.par.core.mapper.SiteMapper;
|
||||
import com.par.core.entity.Psk;
|
||||
import com.par.core.service.AccountService;
|
||||
import com.par.core.service.PskService;
|
||||
import com.par.core.storage.CachedStorageService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -38,6 +39,7 @@ public class AdminController {
|
||||
private final SiteMapper siteMapper;
|
||||
private final AccountService accountService;
|
||||
private final PskService pskService;
|
||||
private final CachedStorageService storageService;
|
||||
|
||||
/**
|
||||
* 获取所有用户列表
|
||||
@@ -84,6 +86,14 @@ public class AdminController {
|
||||
}
|
||||
config.setVersion(String.valueOf(nextVersion));
|
||||
|
||||
// 文件从 pending 移到 approved 路径
|
||||
String approvedPath = config.getStoragePath().replace("/pending/", "/approved/");
|
||||
String content = storageService.read(config.getStoragePath());
|
||||
if (content != null) {
|
||||
storageService.store(approvedPath, content);
|
||||
config.setStoragePath(approvedPath);
|
||||
}
|
||||
|
||||
config.setStatus(ConfigStatus.APPROVED);
|
||||
config.setReviewerId(reviewerId);
|
||||
config.setReviewedAt(LocalDateTime.now());
|
||||
|
||||
@@ -57,7 +57,7 @@ public class ConfigServiceImpl implements ConfigService {
|
||||
public SiteConfig submitConfig(String siteId, String version, String configJson,
|
||||
String schemaVersion, Long submitterId) {
|
||||
String configHash = HmacUtil.sha256(configJson);
|
||||
String storagePath = String.format("configs/%s/%s/%s.json", siteId, version, configHash.substring(0, 8));
|
||||
String storagePath = String.format("configs/%s/pending/%s.json", siteId, configHash.substring(0, 8));
|
||||
|
||||
// 相同 hash 的提交 → 真正重复,跳过
|
||||
SiteConfig sameHash = siteConfigMapper.selectOne(
|
||||
|
||||
Reference in New Issue
Block a user