package com.hdkj.lt.feign;

import com.hdkj.hussar.ApiResponse;
import com.hdkj.lt.base.constants.SystemGlobalConstant;
import com.hdkj.lt.feign.fallback.FileApiClientFallBack;
import com.hdkj.lt.modle.FileInfoDTO;
import com.hdkj.lt.modle.FileRequest;
import com.hdkj.lt.modle.FileUploadDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @Description
 * @Author wcx
 * @Date 2025/6/3 15:52
 * @Version 1.0
 */
@FeignClient(value = SystemGlobalConstant.SERVICE_NAME_LOAD_TRANSFER_IO, fallbackFactory = FileApiClientFallBack.class)
public interface IFileApiClient {
    // 文件上传
    String API_IO_SERVICE_FILE_UPLOAD = "feign/upload";
    // 获取下载文件信息
    String API_IO_SERVICE_FILE_GET = "feign/getFileById";

    // 配电云主站附件查询
    String API_IO_SERVICE_LIST_OBJECT = "feign/listObject";
    // 配电云主站附件下载
    String API_IO_SERVICE_GET_OBJECT = "feign/getObject";
    // 配电云主站附件删除
    String API_IO_SERVICE_REMOVE_OBJECT = "feign/removeObject";

    @PostMapping(API_IO_SERVICE_FILE_UPLOAD)
    ApiResponse<FileInfoDTO> upload(@RequestBody FileRequest request);

    @PostMapping(API_IO_SERVICE_FILE_GET)
    ApiResponse<byte[]> getFileById(@RequestBody FileRequest request);

    @GetMapping(API_IO_SERVICE_LIST_OBJECT)
    ApiResponse<List<FileUploadDTO>> listObject(@RequestParam("fileDir") String fileDir);

    @GetMapping(API_IO_SERVICE_GET_OBJECT)
    ApiResponse<byte[]> getObject(@RequestParam("objectName") String objectName);

    @GetMapping(API_IO_SERVICE_REMOVE_OBJECT)
    ApiResponse<String> removeObject(@RequestParam("objectName") String objectName);

}
