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

import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.estate.api.entity.Contract;
import com.sptg.estate.api.feigns.ContractFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * title: ProjectFeignFallbackFactory
 * package: com.sptg.estate.biz.security
 * description: 实施项目-服务容错处理类
 *
 *               
 *                     
 */
@Component
@Slf4j
public class ContractFeignFallbackFactory implements FallbackFactory<ContractFeign> {
    @Override
    public ContractFeign create(Throwable cause) {
        return new ContractFeign() {

            @Override
            public ResultBean<Contract> findByProjectId(Long projectId) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> insertByResidentialId(Contract contract) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> editByProjectId(Contract contract) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
