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

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.PageBean;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.device.api.entity.Device;
import com.sptg.estate.api.dto.AccessCardDto;
import com.sptg.estate.api.entity.AccessCard;
import com.sptg.estate.api.feigns.AccessCardFeign;
import com.sptg.estate.api.vo.DevicesAccessPushVO;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * title: UserCardFeignFallbackFactory
 * package: com.sptg.estate.api.feigns.fallback
 * description: 门禁卡 服务接口容错处理
 *
 *
 *
 */
@Component
@Slf4j
public class AccessCardFeignFallbackFactory implements FallbackFactory<AccessCardFeign> {
    @Override
    public AccessCardFeign create(Throwable cause) {
        return new AccessCardFeign() {
            @Override
            public ResultBean<Page<AccessCard>> showAccessCardList(AccessCardDto accessCardDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Page<AccessCard>> showCardList(AccessCardDto accessCardDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> addAccessCard(AccessCardDto accessCardDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> pushAccessCardBatch(List<AccessCardDto> accessCardDtoList) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public ResultBean<Boolean> updateAccessCard(AccessCardDto accessCardDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> deleteAccessCard(AccessCardDto accessCardDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> deleteCardList(AccessCardDto accessCardDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public List<AccessCard> findAccessCardByCondition(AccessCardDto accessCardDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public Page<AccessCard> pagingQuery(PageBean<AccessCard, Device> pageBean) {
                log.error(cause.getMessage(),cause);
                return pageBean;
            }

            @Override
            public Page<AccessCard> enablePagingQuery(PageBean<AccessCard, Device> pageBean) {
                log.error(cause.getMessage(),cause);
                return pageBean;
            }
            @Override
            public ResultBean<Boolean> addOrUpdateUserCard(AccessCardDto accessCardDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<AccessCardDto> simpleAddOrUpdateUserCard(AccessCardDto accessCardDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> sendAccessUserCard(DevicesAccessPushVO devicesAccessPushVO) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public List<AccessCard> getAccessCardByUserIdAndType(AccessCardDto accessCardDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public ResultBean<AccessCard> findListByPosition(AccessCardDto accessCardDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> importAccessCardList(List<AccessCard> list) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public AccessCard getCardByCardNo(String cardNo) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public List<AccessCard> getAccessCardListByCardNo(AccessCardDto accessCardDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public List<AccessCard> getAccessCardListByCardIds(AccessCardDto accessCardDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public List<AccessCard> getListByCardNoAndDate(AccessCardDto accessCardDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public ResultBean<Boolean> updateAccessCardByCardNo(AccessCardDto accessCardDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

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

            @Override
            public ResultBean<Boolean> updateAccessCardById(AccessCard accessCard) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public List<AccessCard> findAccessCardByUserIdAndUserName(AccessCardDto accessCardDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }
        };
    }
}
