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

import com.ycwl.basic.integration.common.response.CommonResponse;
import com.ycwl.basic.integration.scenic.dto.config.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

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

@FeignClient(name = "zt-scenic", contextId = "scenic-config-v2", path = "/api/scenic/config/v2")
public interface ScenicConfigV2Client {

    @GetMapping("/{scenicId}")
    CommonResponse<List<ScenicConfigV2DTO>> listConfigs(@PathVariable("scenicId") Long scenicId);

    @GetMapping("/{scenicId}/key/{configKey}")
    CommonResponse<ScenicConfigV2DTO> getConfigByKey(@PathVariable("scenicId") Long scenicId,
                                                     @PathVariable("configKey") String configKey);

    @GetMapping("/{scenicId}/keys")
    CommonResponse<Map<String, Object>> getFlatConfigs(@PathVariable("scenicId") Long scenicId);

    @PostMapping("/{scenicId}")
    CommonResponse<ScenicConfigV2DTO> createConfig(@PathVariable("scenicId") Long scenicId,
                                                   @RequestBody CreateConfigRequest request);

    @PutMapping("/{scenicId}/{id}")
    CommonResponse<ScenicConfigV2DTO> updateConfig(@PathVariable("scenicId") Long scenicId,
                                                   @PathVariable("id") String id,
                                                   @RequestBody UpdateConfigRequest request);

    @DeleteMapping("/{scenicId}/{id}")
    CommonResponse<Void> deleteConfig(@PathVariable("scenicId") Long scenicId,
                                      @PathVariable("id") String id);

    @PostMapping("/{scenicId}/batch")
    CommonResponse<BatchUpdateResponse> batchUpdateConfigs(@PathVariable("scenicId") Long scenicId,
                                                          @RequestBody BatchConfigRequest request);

    @PostMapping("/{scenicId}/batchFlatUpdate")
    CommonResponse<BatchUpdateResponse> batchFlatUpdateConfigs(@PathVariable("scenicId") Long scenicId,
                                                              @RequestBody Map<String, Object> configs);
}