package com.sptg.estate.api.feigns.fallback;

import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.estate.api.entity.PositionRecord;
import com.sptg.estate.api.feigns.PositionRecordFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * title: PositionFeignFallbackFactory
 * package: com.sptg.estate.api.feigns.fallback
 * description:定位记录-服务容错处理类
 *
 *               
 *                
 */
@Component
@Slf4j
public class PositionRecordFeignFallbackFactory implements FallbackFactory<PositionRecordFeign> {

    @Override
    public PositionRecordFeign create(Throwable cause) {
        return new PositionRecordFeign(){

            @Override
            public ResultBean<PositionRecord> getListByPositionId(Long positionId) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<PositionRecord> findById(Long id) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
