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

import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.permissions.api.dto.DictDto;
import com.sptg.permissions.api.entity.Dict;
import com.sptg.permissions.api.feigns.DictFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


/**
 * title: AreaFeignFallbackFactory
 * package: com.sptg.permissions.api.feigns.fallback
 * description: 全国省市区街道-对外服务容错处理
 *
 *                  
 *                
 */
@Slf4j
@Component
public class DictFeignFallbackFactory implements FallbackFactory<DictFeign> {

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

            @Override
            public ResultBean<Dict> getDictTreeList() {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> insertDict(DictDto dictDto) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> updateDict(DictDto dictDto) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> deleteDict(DictDto dictDto) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public ResultBean<Dict> getByCode(String code) {
                log.error(cause.getMessage(), cause);
                return null;
            }
        };
    }
}
