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

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.estate.api.dto.IntegratedServiceDto;
import com.sptg.estate.api.entity.IntegratedService;
import com.sptg.estate.api.feigns.IntegratedServiceFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * title: MemberAndUserFeignFallbackFactory
 * package: com.sptg.estate.biz.security
 * description: 综合服务方 服务接口容错处理
 *
 *               
 *                      
 */
@Component
@Slf4j
public class IntegratedServiceFeignFallbackFactory implements FallbackFactory<IntegratedServiceFeign> {

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

            @Override
            public ResultBean<Page<IntegratedService>> showList(IntegratedServiceDto integratedServiceDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> insert(IntegratedService integratedService) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public ResultBean<Boolean> editById(IntegratedService integratedService) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
