package com.yd.oss.feign.client;

import com.yd.common.result.Result;
import com.yd.oss.feign.fallback.ApiExcelFeignFallbackFactory;
import com.yd.oss.feign.request.ApiOssExportAppointmentExcelRequest;
import com.yd.oss.feign.response.ApiOssExcelParseResponse;
import com.yd.oss.feign.response.ApiOssExportAppointmentExcelResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

/**
 * Excel信息Feign客户端
 */
@FeignClient(name = "yd-oss-api", fallbackFactory = ApiExcelFeignFallbackFactory.class)
public interface ApiExcelFeignClient {

    /**
     * 导出excel-预约信息
     * @return
     */
    @PostMapping("/export/appointment")
    Result<ApiOssExportAppointmentExcelResponse> exportAppointment(@Validated @RequestBody ApiOssExportAppointmentExcelRequest request);

    /**
     * 通用-Excel解析（支持多sheet页解析）
     * @return
     */
    @PostMapping(value = "/parse-excel", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    Result<ApiOssExcelParseResponse> parse(@RequestPart("file") MultipartFile file,
                                           @RequestPart("sheetClassNames") String[] sheetClassNames);
}
