package com.xhpc.common.api.factory;

import com.xhpc.common.api.WorkOrderYuService;
import com.xhpc.common.core.domain.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.Map;

/**
 * @author yuyang
 * @date 2022/6/6 11:39
 */
@Component
public class WorkOrderFallbackFactory implements FallbackFactory<WorkOrderYuService> {

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

    @Override
    public WorkOrderYuService create(Throwable cause) {
        logger.error("工单调用失败：{}//fallback",cause.getMessage());
        return new WorkOrderYuService() {
            @Override
            public R addNewOrder(String type, String title, String content, String reason,String stationId,String deviceType,String serialNumber) {
                return R.fail(3886,"工单生成失败调用失败:" + cause.getMessage());
            }

            @Override
            public R workOrderMessage(Integer type, String time) {
                return R.fail(3886,"工单查询调用失败:" + cause.getMessage());
            }

        };
    }
}
