package com.xhpc.common.api.factory;

import com.xhpc.common.api.ChargingStationPushStatusService;
import com.xhpc.common.core.web.domain.AjaxResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author WH
 * @date 2021/11/5 10:10
 * @since version-1.0
 */
@Component
public class ChargingStationPushStatusFallbackFactory implements FallbackFactory<ChargingStationPushStatusService> {

    private static final Logger logger = LoggerFactory.getLogger(ChargingStationPushStatusFallbackFactory.class);

    @Override
    public ChargingStationPushStatusService create(Throwable cause) {

        logger.error("场站状态服务调用失败：{}//fallback", cause.getMessage());

        return new ChargingStationPushStatusService() {

            @Override
            public AjaxResult editStationStatus(Map<String, Object> map) {

                return AjaxResult.error(3886,"场站编辑回调接口失败:" + cause.getMessage());
            }

            @Override
            public AjaxResult saveStationStatus(Map<String, Object> map) {

                return AjaxResult.error(3886,"场站保存回调接口失败:" + cause.getMessage());
            }
        };
    }

}
