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.MemberAndUser;
import com.sptg.estate.api.feigns.MemberAndUserFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * title: MemberAndUserFeignFallbackFactory
 * package: com.sptg.estate.biz.security
 * description: 会员与住户 服务接口容错处理
 *
 *               
 *                      
 */
@Component
@Slf4j
public class MemberAndUserFeignFallbackFactory  implements FallbackFactory<MemberAndUserFeign> {
    @Override
    public MemberAndUserFeign create(Throwable cause) {
        return new MemberAndUserFeign() {
            @Override
            public List<MemberAndUser> getByCondition(MemberAndUser memberAndUser) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public ResultBean<Boolean> checkRelationship(MemberAndUser memberAndUser) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public boolean addEntity(MemberAndUser memberAndUser) {
                log.error(cause.getMessage(),cause);
                return false;
            }

            @Override
            public List<MemberAndUser> getListByMemberId(Long memberId) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public boolean deleteMemberAndUser(MemberAndUser memberAndUser) {
                return false;
            }
        };
    }
}
