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

import java.util.Map;

/**
 * title: MemberFeignFallbackFactory
 * package: com.sptg.estate.api.feigns.fallback
 * description: 会员 服务接口容错处理
 *
 *               
 *                
 */
@Component
@Slf4j
public class MemberFeignFallbackFactory implements FallbackFactory<MemberFeign> {
    @Override
    public MemberFeign create(Throwable cause) {
        return new MemberFeign() {
            @Override
            public ResultBean<Member> getMemberByOpenid(MemberDto memberDto) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Member> getMemberById(MemberDto memberDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> memberRegister(Member member) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> checkMemberTel(Member member) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> updateMemberOpenId(Member member) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Map<String, Integer>> getMemberAccount(MemberDto memberDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public Member getMemberByMemberId(Long memberId) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public ResultBean<Map<String, Object>> getMemberTypeCount(MemberDto memberDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> updateMemberPassword(Member member) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> changeTel(Member member) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public Member findMemberByTel(Member member) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public ResultBean<Page<Member>> showMemberList(MemberDto memberDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Member> memberRegisterNew(Member member) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public Member getByOldId(String oldId) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public ResultBean<Boolean> updateMember(Member member) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public ResultBean<Boolean> activation(MemberDto memberDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public Member getMember(Member member) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public ResultBean<Boolean> delete(Long memberId) {
                return null;
            }
        };
    }
}
