package com.hdkj.lt.feign.fallback;

import com.hdkj.lt.core.bizms.modle.dto.StateEstimation;
import com.hdkj.lt.core.bizms.modle.po.FhzgFeederAutoSwitchMapping;
import com.hdkj.lt.core.bizms.modle.request.StateEstimationEquipRequest;
import com.hdkj.lt.core.bizms.modle.request.StateEstimationRequest;
import com.hdkj.lt.feign.IStateEstimationApiClient;
import com.hdkj.hussar.ApiResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Description
 * @Author wcx
 * @Date 2025/5/28 16:38
 * @Version 1.0
 */
@Slf4j
@Component
public class StateEstimationApiClientFallBack implements FallbackFactory<IStateEstimationApiClient> {

    @Override
    public IStateEstimationApiClient create(Throwable cause) {
        return new IStateEstimationApiClient() {
            @Override
            public ApiResponse<StateEstimation> queryPeriodByEquip(StateEstimationEquipRequest stateEstimationEquip) {
                log.error("分时段查询设备状估数据-getPlanTransferScheme 远程调用服务异常, 参数:{}", stateEstimationEquip);
                return ApiResponse.fail(String.format("分时段查询设备状估数据-getPlanTransferScheme 远程调用服务异常：%s", cause.getMessage()));
            }

            @Override
            public ApiResponse<StateEstimation> queryByFeederSave(StateEstimationRequest request) {
                log.error("分时段查询设备状估数据-getPlanTransferScheme 远程调用服务异常, 参数:{}", request);
                return ApiResponse.fail(String.format("分时段查询设备状估数据-getPlanTransferScheme 远程调用服务异常：%s", cause.getMessage()));
            }

            @Override
            public ApiResponse<List<FhzgFeederAutoSwitchMapping>> saveAutoSwitch(StateEstimationRequest request) {
                log.error("查询线路自动化开关失败-getPlanTransferScheme 远程调用服务异常, 参数:{}", request);
                return ApiResponse.fail(String.format("查询线路自动化开关失败-getPlanTransferScheme 远程调用服务异常：%s", cause.getMessage()));

            }
        };
    }
}
