feat: 脚本版本接口区分自定义/默认+返回source字段
This commit is contained in:
@@ -57,12 +57,18 @@ public class ScriptController {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
/** 获取脚本版本 */
|
||||
/** 获取脚本版本(自定义脚本优先,否则返回默认模板版本) */
|
||||
@GetMapping("/api/v1/scripts/{siteId}/version")
|
||||
public ApiResponse<Map<String, String>> getVersion(@PathVariable String siteId) {
|
||||
SiteConfig latest = configService.getLatestConfig(siteId);
|
||||
String v = latest != null ? latest.getVersion() : "0";
|
||||
return ApiResponse.success(Map.of("version", v));
|
||||
if (latest != null && latest.getScriptStoragePath() != null && !latest.getScriptStoragePath().isBlank()) {
|
||||
return ApiResponse.success(Map.of("version", latest.getVersion(), "source", "custom"));
|
||||
}
|
||||
// 回退到默认模板版本
|
||||
var site = siteMapper.selectBySiteId(siteId);
|
||||
String siteType = site != null && site.getSiteType() != null ? site.getSiteType().getValue() : null;
|
||||
int defVer = GroovyScriptEngine.getDefaultVersion(siteType);
|
||||
return ApiResponse.success(Map.of("version", String.valueOf(defVer), "source", "default"));
|
||||
}
|
||||
|
||||
/** 获取站点类型默认脚本(管理员) */
|
||||
|
||||
Reference in New Issue
Block a user