feat: 删除站点自定义脚本回退默认模板
This commit is contained in:
@@ -27,6 +27,7 @@ public class ScriptController {
|
||||
private final ConfigService configService;
|
||||
private final CachedStorageService storageService;
|
||||
private final SiteMapper siteMapper;
|
||||
private final com.par.core.mapper.SiteConfigMapper siteConfigMapper;
|
||||
|
||||
/** 下载最新 Groovy 脚本 */
|
||||
@GetMapping("/api/v1/scripts/{siteId}")
|
||||
@@ -57,6 +58,19 @@ public class ScriptController {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
/** 删除站点自定义脚本(回退到默认模板) */
|
||||
@DeleteMapping("/api/v1/admin/configs/{siteId}/script")
|
||||
public ApiResponse<Void> deleteScript(@PathVariable String siteId, HttpServletRequest request) {
|
||||
checkAdmin(request);
|
||||
SiteConfig latest = configService.getLatestConfig(siteId);
|
||||
if (latest == null) return ApiResponse.success();
|
||||
latest.setScriptStoragePath(null);
|
||||
latest.setIsLatest(false);
|
||||
siteConfigMapper.updateById(latest);
|
||||
log.info("Custom script deleted for siteId={}, fallback to default", siteId);
|
||||
return ApiResponse.success();
|
||||
}
|
||||
|
||||
/** 获取脚本版本(自定义脚本优先,否则返回默认模板版本) */
|
||||
@GetMapping("/api/v1/scripts/{siteId}/version")
|
||||
public ApiResponse<Map<String, String>> getVersion(@PathVariable String siteId) {
|
||||
|
||||
Reference in New Issue
Block a user