fix: PUT/POST新接口加入鉴权拦截器+uploadScript版本号自增
This commit is contained in:
@@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user