fix: PUT/POST新接口加入鉴权拦截器+uploadScript版本号自增

This commit is contained in:
mediabot-pt
2026-07-04 23:39:45 +08:00
parent 2ced6f5dcb
commit 31800b9643
2 changed files with 11 additions and 2 deletions

View File

@@ -74,9 +74,15 @@ public class ScriptController {
if (script == null || script.isBlank()) {
return ApiResponse.error(400, "script body is required");
}
// 版本号由服务端管理
// 版本号递增
SiteConfig latest = configService.getLatestConfig(siteId);
int nextVersion = 1;
if (latest != null) {
try { nextVersion = Integer.parseInt(latest.getVersion()) + 1; }
catch (NumberFormatException ignored) {}
}
Long submitterId = (Long) request.getAttribute("accountId");
SiteConfig config = configService.submitConfig(siteId, "1", script, submitterId);
SiteConfig config = configService.submitConfig(siteId, String.valueOf(nextVersion), script, submitterId);
return ApiResponse.success(Map.of("version", config.getVersion()));
}
}