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

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.permissions.api.dto.AreaDto;
import com.sptg.permissions.api.entity.AppArea;
import com.sptg.permissions.api.entity.Area;
import com.sptg.permissions.api.feigns.AreaFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;


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

    @Override
    public AreaFeign create(Throwable cause) {
        return new AreaFeign() {
            @Override
            public List<Area> getSubList(Serializable parentCode) {
                log.error(cause.getMessage(), cause);
                return new ArrayList<>(0);
            }

            @Override
            public Area selectByCode(Serializable code) {
                log.error(cause.getMessage(), cause);
                return null;
            }

            @Override
            public List<Area> getListByIds(List<Long> idList) {
                log.error(cause.getMessage(),cause);
                return new ArrayList<>(0);
            }

            @Override
            public Map<String ,Object> selectByNameAndLayer(AreaDto dto) {
                log.error(cause.getMessage(), cause);
                return null;
            }

            @Override
            public List<Area> getCityAndProvinceByName(String name) {
                log.error(cause.getMessage(), cause);
                return null;
            }
            @Override
            public List<AppArea> selectAll() {
                log.error(cause.getMessage(), cause);
                return null;
            }
            @Override
            public ResultBean<Page<Area>> pagingQuery(AreaDto areaDto) {
                log.error(cause.getMessage(), cause);
                return null;
            }
            @Override
            public ResultBean<Boolean> addArea(AreaDto areaDto) {
                log.error(cause.getMessage(), cause);
                return null;
            }
            @Override
            public Area getById(Serializable id) {
                log.error(cause.getMessage(), cause);
                return null;
            }
            @Override
            public ResultBean<Boolean> delete(Area area) {
                log.error(cause.getMessage(), cause);
                return null;
            }
        };
    }
}
