You've already forked FrameTour-BE
feat(pc): 重构渲染工作器管理接口并添加配置管理功能- 重新设计了渲染工作器管理接口,简化了操作流程- 添加了渲染工作器配置管理相关接口,包括创建、更新、删除等操作
- 优化了代码结构,提高了可维护性和可扩展性
This commit is contained in:
@@ -0,0 +1,196 @@
|
|||||||
|
package com.ycwl.basic.controller.pc;
|
||||||
|
|
||||||
|
import com.ycwl.basic.integration.render.dto.config.BatchRenderWorkerConfigRequest;
|
||||||
|
import com.ycwl.basic.integration.render.dto.config.RenderWorkerConfigV2DTO;
|
||||||
|
import com.ycwl.basic.integration.render.service.RenderWorkerConfigIntegrationService;
|
||||||
|
import com.ycwl.basic.utils.ApiResponse;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渲染工作器配置管理 V2 版本控制器
|
||||||
|
* 基于 zt-render-worker 微服务标准接口实现
|
||||||
|
*
|
||||||
|
* @author Claude Code
|
||||||
|
* @date 2025-09-06
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/render/worker/config/v2")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class RenderWorkerConfigV2Controller {
|
||||||
|
|
||||||
|
private final RenderWorkerConfigIntegrationService configIntegrationService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取工作器所有配置
|
||||||
|
*
|
||||||
|
* @param workerId 工作器ID
|
||||||
|
* @return 工作器配置列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/{workerId}")
|
||||||
|
public ApiResponse<List<RenderWorkerConfigV2DTO>> getWorkerConfigs(@PathVariable Long workerId) {
|
||||||
|
log.info("获取渲染工作器配置列表, workerId: {}", workerId);
|
||||||
|
|
||||||
|
try {
|
||||||
|
List<RenderWorkerConfigV2DTO> configs = configIntegrationService.getWorkerConfigs(workerId);
|
||||||
|
return ApiResponse.success(configs);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取渲染工作器配置列表失败, workerId: {}", workerId, e);
|
||||||
|
return ApiResponse.fail("获取渲染工作器配置列表失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取工作器平铺配置
|
||||||
|
*
|
||||||
|
* @param workerId 工作器ID
|
||||||
|
* @return 平铺配置Map
|
||||||
|
*/
|
||||||
|
@GetMapping("/{workerId}/flat")
|
||||||
|
public ApiResponse<Map<String, Object>> getWorkerFlatConfig(@PathVariable Long workerId) {
|
||||||
|
log.info("获取渲染工作器平铺配置, workerId: {}", workerId);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Map<String, Object> flatConfig = configIntegrationService.getWorkerFlatConfig(workerId);
|
||||||
|
return ApiResponse.success(flatConfig);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取渲染工作器平铺配置失败, workerId: {}", workerId, e);
|
||||||
|
return ApiResponse.fail("获取渲染工作器平铺配置失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据配置键获取特定配置
|
||||||
|
*
|
||||||
|
* @param workerId 工作器ID
|
||||||
|
* @param configKey 配置键
|
||||||
|
* @return 配置信息
|
||||||
|
*/
|
||||||
|
@GetMapping("/{workerId}/key/{configKey}")
|
||||||
|
public ApiResponse<RenderWorkerConfigV2DTO> getWorkerConfigByKey(@PathVariable Long workerId,
|
||||||
|
@PathVariable String configKey) {
|
||||||
|
log.info("根据配置键获取渲染工作器配置, workerId: {}, configKey: {}", workerId, configKey);
|
||||||
|
|
||||||
|
try {
|
||||||
|
RenderWorkerConfigV2DTO config = configIntegrationService.getWorkerConfigByKey(workerId, configKey);
|
||||||
|
return ApiResponse.success(config);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("根据配置键获取渲染工作器配置失败, workerId: {}, configKey: {}", workerId, configKey, e);
|
||||||
|
return ApiResponse.fail("根据配置键获取渲染工作器配置失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建工作器配置
|
||||||
|
*
|
||||||
|
* @param workerId 工作器ID
|
||||||
|
* @param config 配置信息
|
||||||
|
* @return 创建的配置信息
|
||||||
|
*/
|
||||||
|
@PostMapping("/{workerId}")
|
||||||
|
public ApiResponse<RenderWorkerConfigV2DTO> createWorkerConfig(@PathVariable Long workerId,
|
||||||
|
@Valid @RequestBody RenderWorkerConfigV2DTO config) {
|
||||||
|
log.info("创建渲染工作器配置, workerId: {}, configKey: {}", workerId, config.getConfigKey());
|
||||||
|
|
||||||
|
try {
|
||||||
|
RenderWorkerConfigV2DTO result = configIntegrationService.createWorkerConfig(workerId, config);
|
||||||
|
return ApiResponse.success(result);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("创建渲染工作器配置失败, workerId: {}", workerId, e);
|
||||||
|
return ApiResponse.fail("创建渲染工作器配置失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新工作器配置
|
||||||
|
*
|
||||||
|
* @param workerId 工作器ID
|
||||||
|
* @param configId 配置ID
|
||||||
|
* @param updates 更新内容
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
@PutMapping("/{workerId}/{configId}")
|
||||||
|
public ApiResponse<Void> updateWorkerConfig(@PathVariable Long workerId,
|
||||||
|
@PathVariable Long configId,
|
||||||
|
@Valid @RequestBody Map<String, Object> updates) {
|
||||||
|
log.info("更新渲染工作器配置, workerId: {}, configId: {}", workerId, configId);
|
||||||
|
|
||||||
|
try {
|
||||||
|
configIntegrationService.updateWorkerConfig(workerId, configId, updates);
|
||||||
|
return ApiResponse.success(null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("更新渲染工作器配置失败, workerId: {}, configId: {}", workerId, configId, e);
|
||||||
|
return ApiResponse.fail("更新渲染工作器配置失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除工作器配置
|
||||||
|
*
|
||||||
|
* @param workerId 工作器ID
|
||||||
|
* @param configId 配置ID
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/{workerId}/{configId}")
|
||||||
|
public ApiResponse<Void> deleteWorkerConfig(@PathVariable Long workerId,
|
||||||
|
@PathVariable Long configId) {
|
||||||
|
log.info("删除渲染工作器配置, workerId: {}, configId: {}", workerId, configId);
|
||||||
|
|
||||||
|
try {
|
||||||
|
configIntegrationService.deleteWorkerConfig(workerId, configId);
|
||||||
|
return ApiResponse.success(null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("删除渲染工作器配置失败, workerId: {}, configId: {}", workerId, configId, e);
|
||||||
|
return ApiResponse.fail("删除渲染工作器配置失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量更新工作器配置
|
||||||
|
*
|
||||||
|
* @param workerId 工作器ID
|
||||||
|
* @param request 批量配置请求
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/{workerId}/batch")
|
||||||
|
public ApiResponse<Void> batchUpdateWorkerConfigs(@PathVariable Long workerId,
|
||||||
|
@Valid @RequestBody BatchRenderWorkerConfigRequest request) {
|
||||||
|
log.info("批量更新渲染工作器配置, workerId: {}, configCount: {}",
|
||||||
|
workerId, request.getConfigs() != null ? request.getConfigs().size() : 0);
|
||||||
|
|
||||||
|
try {
|
||||||
|
configIntegrationService.batchUpdateWorkerConfigs(workerId, request);
|
||||||
|
return ApiResponse.success(null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("批量更新渲染工作器配置失败, workerId: {}", workerId, e);
|
||||||
|
return ApiResponse.fail("批量更新渲染工作器配置失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量平铺更新工作器配置
|
||||||
|
*
|
||||||
|
* @param workerId 工作器ID
|
||||||
|
* @param flatConfigs 平铺配置Map
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/{workerId}/flat-batch")
|
||||||
|
public ApiResponse<Void> batchFlatUpdateWorkerConfigs(@PathVariable Long workerId,
|
||||||
|
@Valid @RequestBody Map<String, Object> flatConfigs) {
|
||||||
|
log.info("批量平铺更新渲染工作器配置, workerId: {}, configCount: {}", workerId, flatConfigs.size());
|
||||||
|
|
||||||
|
try {
|
||||||
|
configIntegrationService.batchFlatUpdateWorkerConfigs(workerId, flatConfigs);
|
||||||
|
return ApiResponse.success(null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("批量平铺更新渲染工作器配置失败, workerId: {}", workerId, e);
|
||||||
|
return ApiResponse.fail("批量平铺更新渲染工作器配置失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,49 +1,49 @@
|
|||||||
package com.ycwl.basic.controller.pc;
|
package com.ycwl.basic.controller.pc;
|
||||||
|
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.ycwl.basic.integration.common.response.PageResponse;
|
||||||
import com.ycwl.basic.model.pc.renderWorker.entity.RenderWorkerEntity;
|
import com.ycwl.basic.integration.render.dto.worker.CreateRenderWorkerRequest;
|
||||||
import com.ycwl.basic.model.pc.renderWorker.req.RenderWorkerReqQuery;
|
import com.ycwl.basic.integration.render.dto.worker.RenderWorkerV2DTO;
|
||||||
import com.ycwl.basic.model.pc.renderWorker.resp.RenderWorkerRespVO;
|
import com.ycwl.basic.integration.render.dto.worker.UpdateRenderWorkerRequest;
|
||||||
import com.ycwl.basic.service.pc.RenderWorkerService;
|
import com.ycwl.basic.integration.render.service.RenderWorkerIntegrationService;
|
||||||
import com.ycwl.basic.utils.ApiResponse;
|
import com.ycwl.basic.utils.ApiResponse;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 渲染机管理 V2 版本控制器
|
* 渲染工作器管理 V2 版本控制器
|
||||||
|
* 基于 zt-render-worker 微服务标准接口实现
|
||||||
*
|
*
|
||||||
* @author Claude Code
|
* @author Claude Code
|
||||||
* @date 2025-09-05
|
* @date 2025-09-06
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/renderWorker/v2")
|
@RequestMapping("/api/render/worker/v2")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class RenderWorkerV2Controller {
|
public class RenderWorkerV2Controller {
|
||||||
|
|
||||||
private final RenderWorkerService renderWorkerService;
|
private final RenderWorkerIntegrationService renderWorkerIntegrationService;
|
||||||
|
|
||||||
// ========== 渲染机基础 CRUD 操作 ==========
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 渲染机分页列表查询
|
* 分页查询渲染工作器列表
|
||||||
|
*
|
||||||
|
* @param page 页码,从1开始
|
||||||
|
* @param pageSize 每页大小,默认10,最大100
|
||||||
|
* @param isEnabled 是否启用(0-禁用,1-启用)
|
||||||
|
* @param name 工作器名称(模糊搜索)
|
||||||
|
* @return 分页查询结果
|
||||||
*/
|
*/
|
||||||
@GetMapping("/")
|
@GetMapping
|
||||||
public ApiResponse<PageInfo<RenderWorkerRespVO>> listRenderWorkers(@RequestParam(defaultValue = "1") Integer page,
|
public ApiResponse<PageResponse<RenderWorkerV2DTO>> listWorkers(
|
||||||
@RequestParam(defaultValue = "10") Integer pageSize,
|
@RequestParam(defaultValue = "1") Integer page,
|
||||||
@RequestParam(required = false) String name,
|
@RequestParam(defaultValue = "10") Integer pageSize,
|
||||||
@RequestParam(required = false) String platform,
|
@RequestParam(required = false) Integer isEnabled,
|
||||||
@RequestParam(required = false) Long scenicOnly,
|
@RequestParam(required = false) String name) {
|
||||||
@RequestParam(required = false) Integer testOnly,
|
|
||||||
@RequestParam(required = false) Integer online,
|
log.info("分页查询渲染工作器列表, page: {}, pageSize: {}, isEnabled: {}, name: {}",
|
||||||
@RequestParam(required = false) Integer status) {
|
page, pageSize, isEnabled, name);
|
||||||
log.info("分页查询渲染机列表, page: {}, pageSize: {}, name: {}, platform: {}, scenicOnly: {}, testOnly: {}, online: {}, status: {}",
|
|
||||||
page, pageSize, name, platform, scenicOnly, testOnly, online, status);
|
|
||||||
|
|
||||||
// 参数验证:限制pageSize最大值为100
|
// 参数验证:限制pageSize最大值为100
|
||||||
if (pageSize > 100) {
|
if (pageSize > 100) {
|
||||||
@@ -51,252 +51,92 @@ public class RenderWorkerV2Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
RenderWorkerReqQuery queryReq = new RenderWorkerReqQuery();
|
PageResponse<RenderWorkerV2DTO> result = renderWorkerIntegrationService.listWorkers(
|
||||||
queryReq.setPageNum(page);
|
page, pageSize, isEnabled, name);
|
||||||
queryReq.setPageSize(pageSize);
|
return ApiResponse.success(result);
|
||||||
queryReq.setName(name);
|
|
||||||
queryReq.setPlatform(platform);
|
|
||||||
queryReq.setScenicOnly(scenicOnly);
|
|
||||||
queryReq.setTestOnly(testOnly);
|
|
||||||
queryReq.setOnline(online);
|
|
||||||
queryReq.setStatus(status);
|
|
||||||
|
|
||||||
return renderWorkerService.pageQuery(queryReq);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("分页查询渲染机列表失败", e);
|
log.error("分页查询渲染工作器列表失败", e);
|
||||||
return ApiResponse.fail("分页查询渲染机列表失败: " + e.getMessage());
|
return ApiResponse.fail("分页查询渲染工作器列表失败: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据ID获取渲染机详情
|
* 根据ID获取渲染工作器详情
|
||||||
|
*
|
||||||
|
* @param id 工作器ID
|
||||||
|
* @return 工作器详情
|
||||||
*/
|
*/
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public ApiResponse<RenderWorkerRespVO> getRenderWorker(@PathVariable Long id) {
|
public ApiResponse<RenderWorkerV2DTO> getWorker(@PathVariable Long id) {
|
||||||
|
log.info("获取渲染工作器详情, id: {}", id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return renderWorkerService.detail(id);
|
RenderWorkerV2DTO worker = renderWorkerIntegrationService.getWorker(id);
|
||||||
|
return ApiResponse.success(worker);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("获取渲染机详情失败, id: {}", id, e);
|
log.error("获取渲染工作器详情失败, id: {}", id, e);
|
||||||
return ApiResponse.fail("获取渲染机详情失败: " + e.getMessage());
|
return ApiResponse.fail("获取渲染工作器详情失败: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建渲染机
|
* 创建渲染工作器
|
||||||
|
*
|
||||||
|
* @param request 创建请求
|
||||||
|
* @return 创建的工作器信息
|
||||||
*/
|
*/
|
||||||
@PostMapping("/")
|
@PostMapping
|
||||||
public ApiResponse<Integer> createRenderWorker(@Valid @RequestBody RenderWorkerEntity renderWorker) {
|
public ApiResponse<RenderWorkerV2DTO> createWorker(@Valid @RequestBody CreateRenderWorkerRequest request) {
|
||||||
log.info("创建渲染机, name: {}, accessKey: {}, scenicOnly: {}, testOnly: {}",
|
log.info("创建渲染工作器, name: {}, key: {}, isActive: {}",
|
||||||
renderWorker.getName(), renderWorker.getAccessKey(), renderWorker.getScenicOnly(), renderWorker.getTestOnly());
|
request.getName(), request.getKey(), request.getIsActive());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return renderWorkerService.add(renderWorker);
|
RenderWorkerV2DTO worker = renderWorkerIntegrationService.createWorker(request);
|
||||||
|
return ApiResponse.success(worker);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("创建渲染机失败", e);
|
log.error("创建渲染工作器失败", e);
|
||||||
return ApiResponse.fail("创建渲染机失败: " + e.getMessage());
|
return ApiResponse.fail("创建渲染工作器失败: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新渲染机信息
|
* 更新渲染工作器
|
||||||
|
*
|
||||||
|
* @param id 工作器ID
|
||||||
|
* @param request 更新请求
|
||||||
|
* @return 操作结果
|
||||||
*/
|
*/
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
public ApiResponse<Integer> updateRenderWorker(@PathVariable Long id, @Valid @RequestBody RenderWorkerEntity renderWorker) {
|
public ApiResponse<Void> updateWorker(@PathVariable Long id,
|
||||||
log.info("更新渲染机信息, id: {}", id);
|
@Valid @RequestBody UpdateRenderWorkerRequest request) {
|
||||||
|
log.info("更新渲染工作器, id: {}, name: {}, isActive: {}",
|
||||||
|
id, request.getName(), request.getIsActive());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
renderWorker.setId(id);
|
renderWorkerIntegrationService.updateWorker(id, request);
|
||||||
return renderWorkerService.update(renderWorker);
|
return ApiResponse.success(null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("更新渲染机信息失败, id: {}", id, e);
|
log.error("更新渲染工作器失败, id: {}", id, e);
|
||||||
return ApiResponse.fail("更新渲染机信息失败: " + e.getMessage());
|
return ApiResponse.fail("更新渲染工作器失败: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除渲染机
|
* 删除渲染工作器
|
||||||
|
*
|
||||||
|
* @param id 工作器ID
|
||||||
|
* @return 操作结果
|
||||||
*/
|
*/
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
public ApiResponse<Integer> deleteRenderWorker(@PathVariable Long id) {
|
public ApiResponse<Void> deleteWorker(@PathVariable Long id) {
|
||||||
log.info("删除渲染机, id: {}", id);
|
log.info("删除渲染工作器, id: {}", id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return renderWorkerService.deleteById(id);
|
renderWorkerIntegrationService.deleteWorker(id);
|
||||||
|
return ApiResponse.success(null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("删除渲染机失败, id: {}", id, e);
|
log.error("删除渲染工作器失败, id: {}", id, e);
|
||||||
return ApiResponse.fail("删除渲染机失败: " + e.getMessage());
|
return ApiResponse.fail("删除渲染工作器失败: " + e.getMessage());
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== 状态管理操作 ==========
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 启用渲染机
|
|
||||||
*/
|
|
||||||
@PutMapping("/{id}/enable")
|
|
||||||
public ApiResponse<String> enableRenderWorker(@PathVariable Long id) {
|
|
||||||
log.info("启用渲染机, id: {}", id);
|
|
||||||
try {
|
|
||||||
// 获取渲染机信息
|
|
||||||
ApiResponse<RenderWorkerRespVO> detailResponse = renderWorkerService.detail(id);
|
|
||||||
if (!detailResponse.isSuccess()) {
|
|
||||||
return ApiResponse.fail("渲染机不存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更新状态
|
|
||||||
RenderWorkerEntity entity = new RenderWorkerEntity();
|
|
||||||
entity.setId(id);
|
|
||||||
entity.setStatus(1); // 1表示启用
|
|
||||||
|
|
||||||
ApiResponse<Integer> updateResponse = renderWorkerService.update(entity);
|
|
||||||
if (updateResponse.isSuccess()) {
|
|
||||||
return ApiResponse.success("渲染机启用成功");
|
|
||||||
} else {
|
|
||||||
return ApiResponse.fail("渲染机启用失败");
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("启用渲染机失败, id: {}", id, e);
|
|
||||||
return ApiResponse.fail("启用渲染机失败: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 禁用渲染机
|
|
||||||
*/
|
|
||||||
@PutMapping("/{id}/disable")
|
|
||||||
public ApiResponse<String> disableRenderWorker(@PathVariable Long id) {
|
|
||||||
log.info("禁用渲染机, id: {}", id);
|
|
||||||
try {
|
|
||||||
// 获取渲染机信息
|
|
||||||
ApiResponse<RenderWorkerRespVO> detailResponse = renderWorkerService.detail(id);
|
|
||||||
if (!detailResponse.isSuccess()) {
|
|
||||||
return ApiResponse.fail("渲染机不存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更新状态
|
|
||||||
RenderWorkerEntity entity = new RenderWorkerEntity();
|
|
||||||
entity.setId(id);
|
|
||||||
entity.setStatus(0); // 0表示禁用
|
|
||||||
|
|
||||||
ApiResponse<Integer> updateResponse = renderWorkerService.update(entity);
|
|
||||||
if (updateResponse.isSuccess()) {
|
|
||||||
return ApiResponse.success("渲染机禁用成功");
|
|
||||||
} else {
|
|
||||||
return ApiResponse.fail("渲染机禁用失败");
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("禁用渲染机失败, id: {}", id, e);
|
|
||||||
return ApiResponse.fail("禁用渲染机失败: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== 配置管理操作 ==========
|
|
||||||
// 注意:以下配置管理方法需要根据实际的RenderWorker配置服务进行调整
|
|
||||||
// 目前暂时保留接口结构,等待配置相关服务的具体实现
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取渲染机配置列表
|
|
||||||
*/
|
|
||||||
@GetMapping("/{id}/config")
|
|
||||||
public ApiResponse<List<Map<String, Object>>> getRenderWorkerConfigs(@PathVariable Long id) {
|
|
||||||
log.info("获取渲染机配置列表, renderWorkerId: {}", id);
|
|
||||||
try {
|
|
||||||
// TODO: 需要实现RenderWorker配置服务
|
|
||||||
return ApiResponse.fail("配置管理功能待实现");
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("获取渲染机配置列表失败, renderWorkerId: {}", id, e);
|
|
||||||
return ApiResponse.fail("获取渲染机配置列表失败: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取渲染机扁平化配置
|
|
||||||
*/
|
|
||||||
@GetMapping("/{id}/flat-config")
|
|
||||||
public ApiResponse<Map<String, Object>> getRenderWorkerFlatConfig(@PathVariable Long id) {
|
|
||||||
log.info("获取渲染机扁平化配置, renderWorkerId: {}", id);
|
|
||||||
try {
|
|
||||||
// TODO: 需要实现RenderWorker配置服务
|
|
||||||
return ApiResponse.fail("配置管理功能待实现");
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("获取渲染机扁平化配置失败, renderWorkerId: {}", id, e);
|
|
||||||
return ApiResponse.fail("获取渲染机扁平化配置失败: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据配置键获取配置
|
|
||||||
*/
|
|
||||||
@GetMapping("/{id}/config/{configKey}")
|
|
||||||
public ApiResponse<Map<String, Object>> getRenderWorkerConfigByKey(@PathVariable Long id,
|
|
||||||
@PathVariable String configKey) {
|
|
||||||
log.info("根据键获取渲染机配置, renderWorkerId: {}, configKey: {}", id, configKey);
|
|
||||||
try {
|
|
||||||
// TODO: 需要实现RenderWorker配置服务
|
|
||||||
return ApiResponse.fail("配置管理功能待实现");
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("根据键获取渲染机配置失败, renderWorkerId: {}, configKey: {}", id, configKey, e);
|
|
||||||
return ApiResponse.fail("根据键获取渲染机配置失败: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建渲染机配置
|
|
||||||
*/
|
|
||||||
@PostMapping("/{id}/config")
|
|
||||||
public ApiResponse<Map<String, Object>> createRenderWorkerConfig(@PathVariable Long id,
|
|
||||||
@Valid @RequestBody Map<String, Object> request) {
|
|
||||||
log.info("创建渲染机配置, renderWorkerId: {}", id);
|
|
||||||
try {
|
|
||||||
// TODO: 需要实现RenderWorker配置服务
|
|
||||||
return ApiResponse.fail("配置管理功能待实现");
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("创建渲染机配置失败, renderWorkerId: {}", id, e);
|
|
||||||
return ApiResponse.fail("创建渲染机配置失败: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量创建/更新渲染机配置
|
|
||||||
*/
|
|
||||||
@PostMapping("/{id}/config/batch")
|
|
||||||
public ApiResponse<Map<String, Object>> batchUpdateRenderWorkerConfig(@PathVariable Long id,
|
|
||||||
@Valid @RequestBody Map<String, Object> request) {
|
|
||||||
log.info("批量更新渲染机配置, renderWorkerId: {}", id);
|
|
||||||
try {
|
|
||||||
// TODO: 需要实现RenderWorker配置服务
|
|
||||||
return ApiResponse.fail("配置管理功能待实现");
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("批量更新渲染机配置失败, renderWorkerId: {}", id, e);
|
|
||||||
return ApiResponse.fail("批量更新渲染机配置失败: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新渲染机配置
|
|
||||||
*/
|
|
||||||
@PutMapping("/{id}/config/{configId}")
|
|
||||||
public ApiResponse<String> updateRenderWorkerConfig(@PathVariable Long id, @PathVariable Long configId,
|
|
||||||
@Valid @RequestBody Map<String, Object> request) {
|
|
||||||
log.info("更新渲染机配置, renderWorkerId: {}, configId: {}", id, configId);
|
|
||||||
try {
|
|
||||||
// TODO: 需要实现RenderWorker配置服务
|
|
||||||
return ApiResponse.fail("配置管理功能待实现");
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("更新渲染机配置失败, renderWorkerId: {}, configId: {}", id, configId, e);
|
|
||||||
return ApiResponse.fail("更新渲染机配置失败: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除渲染机配置
|
|
||||||
*/
|
|
||||||
@DeleteMapping("/{id}/config/{configId}")
|
|
||||||
public ApiResponse<String> deleteRenderWorkerConfig(@PathVariable Long id, @PathVariable Long configId) {
|
|
||||||
log.info("删除渲染机配置, renderWorkerId: {}, configId: {}", id, configId);
|
|
||||||
try {
|
|
||||||
// TODO: 需要实现RenderWorker配置服务
|
|
||||||
return ApiResponse.fail("配置管理功能待实现");
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("删除渲染机配置失败, renderWorkerId: {}, configId: {}", id, configId, e);
|
|
||||||
return ApiResponse.fail("删除渲染机配置失败: " + e.getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -13,8 +13,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.math.RoundingMode;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -25,7 +23,7 @@ public class RenderWorkerRepository {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private RedisTemplate<String, String> redisTemplate;
|
private RedisTemplate<String, String> redisTemplate;
|
||||||
public static final String RENDER_WORKER_STATUS_CACHE_KEY = "render_worker:host_status:%s";
|
public static final String RENDER_WORKER_STATUS_CACHE_KEY = "render_worker:host_status:%s";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RenderWorkerIntegrationService renderWorkerIntegrationService;
|
private RenderWorkerIntegrationService renderWorkerIntegrationService;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user