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.ProjectBook;
import com.sptg.estate.api.entity.ProjectCompletion;
import com.sptg.estate.api.feigns.ProjectBookFeign;
import com.sptg.estate.api.feigns.ProjectCompletionFeign;
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 ProjectCompletionFeignFallbackFactory implements FallbackFactory<ProjectCompletionFeign> {
    @Override
    public ProjectCompletionFeign create(Throwable cause) {
        return new ProjectCompletionFeign() {
            @Override
            public ResultBean<Boolean> insert(ProjectCompletion projectCompletion) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

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