package com.vctgo.system.api.factory;

import com.vctgo.common.core.domain.R;
import com.vctgo.system.api.RemoteSysProvinceService;
import com.vctgo.system.api.domain.SysProvince;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author feng
 * @date 2024/8/19
 */
@Component
public class RemoteSysProvinceFactory implements FallbackFactory<RemoteSysProvinceService> {

    private static final Logger log = LoggerFactory.getLogger(RemotePlatformUserFactory.class);

    @Override
    public RemoteSysProvinceService create(Throwable throwable) {
        log.error("地区服务调用失败:{}", throwable.getMessage());
        return new RemoteSysProvinceService() {
            @Override
            public R<List<SysProvince>> getProvinceTreeList(String provinceId, String cityId) {
                return R.fail("地区列表调用失败" + throwable.getMessage());
            }

            @Override
            public R<List<SysProvince>> getProvince() {
                return R.fail("获取省份失败" + throwable.getMessage());
            }

        };
    }
}
