package com.crunii.micro.feign.client;

import com.crunii.micro.common.dto.Result;
import com.crunii.micro.domain.dto.obs.ObsServiceCodeDto;
import com.crunii.micro.domain.dto.sys.FileBase64;
import com.crunii.micro.feign.client.dto.DownloadFileVo;
import com.crunii.micro.feign.client.dto.FileVo;
import com.crunii.micro.feign.client.fallbackfactory.ObsServiceFallbackFactory;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @author qiaolin
 * @version 1.0
 * @date 2023/6/5 16:34
 */
@FeignClient(value = "service-obs", fallbackFactory = ObsServiceFallbackFactory.class)
public interface ObsService {

    @ApiOperation(value = "通过fileKey删除文件")
    @RequestMapping(path = "/auth/FileController/deleteListFileKey", method = RequestMethod.POST)
    Result<String> deleteListFileKey(@RequestBody List<String> fileKey);

    @ApiOperation("标记obsFile的业务编码")
    @RequestMapping(value = "/auth/FileController/updateObsServiceCode", method = RequestMethod.POST)
    Result<String> updateObsServiceCode(@RequestBody List<ObsServiceCodeDto> obsServiceCodeDtos);

    @ApiOperation("Web上传文件")
    @RequestMapping(value = "/auth/FileController/feignFileUpload", method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE,
            consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    Result<FileVo> feignFileUpload(@RequestPart("file") MultipartFile file);

    @ApiOperation("App上传文件")
    @RequestMapping(value = "/auth/FileController/appFileUpload", method = RequestMethod.POST)
    Result<FileVo> appFileUpload(@RequestBody FileBase64 fileBase64);

    @ApiOperation("下载文件(返回base64格式)")
    @RequestMapping(value = "/auth/FileController/doDownloadFile", method = RequestMethod.GET)
    Result<DownloadFileVo> doDownloadFile(@RequestParam("fileId")Long fileId);
}
