fix: 允许给已批准配置绑定脚本,DTO加scriptStoragePath,无脚本时显示编辑按钮
This commit is contained in:
@@ -256,16 +256,16 @@ public class AdminController {
|
||||
checkAdmin(request);
|
||||
SiteConfig config = siteConfigMapper.selectById(configId);
|
||||
if (config == null) return ApiResponse.error(404, "Config not found");
|
||||
if (config.getStatus() != ConfigStatus.PENDING) {
|
||||
return ApiResponse.error(400, "只能编辑待审核的配置");
|
||||
}
|
||||
|
||||
String script = payload.get("script");
|
||||
if (script == null) return ApiResponse.error(400, "script is required");
|
||||
|
||||
String scriptPath = config.getScriptStoragePath();
|
||||
if (scriptPath == null || scriptPath.isBlank()) {
|
||||
scriptPath = String.format("configs/%s/pending/%s.groovy", config.getSiteId(), config.getConfigHash().substring(0, 8));
|
||||
String hash = config.getConfigHash() != null ? config.getConfigHash().substring(0, 8)
|
||||
: Long.toHexString(System.currentTimeMillis());
|
||||
scriptPath = String.format("configs/%s/%s/%s.groovy", config.getSiteId(),
|
||||
config.getStatus() == ConfigStatus.PENDING ? "pending" : "approved", hash);
|
||||
config.setScriptStoragePath(scriptPath);
|
||||
}
|
||||
storageService.store(scriptPath, script);
|
||||
|
||||
Reference in New Issue
Block a user