package com.ycwl.basic.integration.render.client;

import com.ycwl.basic.integration.common.response.CommonResponse;
import com.ycwl.basic.integration.common.response.PageResponse;
import com.ycwl.basic.integration.render.dto.config.BatchRenderWorkerConfigRequest;
import com.ycwl.basic.integration.render.dto.config.RenderWorkerConfigV2DTO;
import com.ycwl.basic.integration.render.dto.worker.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 渲染工作器V2客户端
 */
@FeignClient(name = "zt-render-worker", contextId = "render-worker-v2", path = "/api/render/worker")
public interface RenderWorkerV2Client {
    
    // ==================== Worker V2 Operations ====================

    /**
     * 获取工作器核心信息
     */
    @GetMapping("v2/{id}")
    CommonResponse<RenderWorkerV2DTO> getWorker(@PathVariable("id") Long id);

    /**
     * 创建工作器
     */
    @PostMapping("v2")
    CommonResponse<RenderWorkerV2DTO> createWorker(@RequestBody CreateRenderWorkerRequest request);
    
    /**
     * 更新工作器
     */
    @PutMapping("v2/{id}")
    CommonResponse<Void> updateWorker(@PathVariable("id") Long id, 
                                      @RequestBody UpdateRenderWorkerRequest request);
    
    /**
     * 删除工作器
     */
    @DeleteMapping("v2/{id}")
    CommonResponse<Void> deleteWorker(@PathVariable("id") Long id);
    
    /**
     * 分页查询工作器列表（核心信息）
     */
    @GetMapping("v2")
    CommonResponse<PageResponse<RenderWorkerV2DTO>> listWorkers(@RequestParam(defaultValue = "1") Integer page,
                                                         @RequestParam(defaultValue = "10") Integer pageSize,
                                                         @RequestParam(required = false) Integer isEnabled,
                                                         @RequestParam(required = false) String name);

    /**
     * 根据key获取工作器核心信息
     */
    @GetMapping("v2/key/{key}")
    CommonResponse<RenderWorkerV2DTO> getWorkerByKey(@PathVariable("key") String key);

    // ==================== Worker Config V2 Operations ====================

    /**
     * 获取工作器所有配置
     */
    @GetMapping("config/v2/{workerId}")
    CommonResponse<List<RenderWorkerConfigV2DTO>> getWorkerConfigs(@PathVariable("workerId") Long workerId);
    
    /**
     * 根据配置键获取特定配置
     */
    @GetMapping("config/v2/{workerId}/key/{configKey}")
    CommonResponse<RenderWorkerConfigV2DTO> getWorkerConfigByKey(@PathVariable("workerId") Long workerId,
                                                                 @PathVariable("configKey") String configKey);
    
    /**
     * 创建配置
     */
    @PostMapping("config/v2/{workerId}")
    CommonResponse<RenderWorkerConfigV2DTO> createWorkerConfig(@PathVariable("workerId") Long workerId,
                                                               @RequestBody RenderWorkerConfigV2DTO config);
    
    /**
     * 更新配置
     */
    @PutMapping("config/v2/{workerId}/{id}")
    CommonResponse<Void> updateWorkerConfig(@PathVariable("workerId") Long workerId,
                                            @PathVariable("id") Long id,
                                            @RequestBody Map<String, Object> updates);
    
    /**
     * 删除配置
     */
    @DeleteMapping("config/v2/{workerId}/{id}")
    CommonResponse<Void> deleteWorkerConfig(@PathVariable("workerId") Long workerId,
                                            @PathVariable("id") Long id);
    
    /**
     * 批量更新配置
     */
    @PostMapping("config/v2/{workerId}/batch")
    CommonResponse<Void> batchUpdateWorkerConfigs(@PathVariable("workerId") Long workerId,
                                                  @RequestBody BatchRenderWorkerConfigRequest request);
}