package com.sptg.video.cloud.api.feigns.fallback;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.ExcelResultEnum;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.video.cloud.api.dto.DistrictNodeDto;
import com.sptg.video.cloud.api.entity.DistrictNode;
import com.sptg.video.cloud.api.feigns.DistrictNodeFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author zwx
 * @create 2020/10/18 11:53
 */
@Slf4j
@Component
public class DistrictNodeFallbackFactory implements FallbackFactory<DistrictNodeFeign> {
    @Override
    public DistrictNodeFeign create(Throwable cause) {
        return new DistrictNodeFeign() {
            @Override
            public ResultBean<Page<DistrictNode>> showDistrictNodeList(DistrictNodeDto districtNodeDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public DistrictNode findDistrictNodeById(Long id) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public ResultBean<Boolean> syncDistrictNodeList(DistrictNodeDto districtNodeDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
