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

import java.util.List;
import java.util.Map;

/**
 * title: GuestAuthorizeFeignFallbackFactory
 * package: com.sptg.estate.api.feigns.fallback
 * description: 访客授权记录 服务接口容错处理
 *
 *
 *
 */
@Component
@Slf4j
public class GuestAuthorizeFeignFallbackFactory implements FallbackFactory<GuestAuthorizeFeign> {
    @Override
    public GuestAuthorizeFeign create(Throwable cause) {
        return new GuestAuthorizeFeign(){
            @Override
            public Page<GuestAuthorize> showGuestAuthorizeList(GuestAuthorizeDto guestAuthorizeDto) {
                log.error(cause.getMessage(),cause);
                return guestAuthorizeDto.getPage();
            }

            @Override
            public Page<GuestAuthorize> showEffectiveGuestAuthorizeList(GuestAuthorizeDto guestAuthorizeDto) {
                log.error(cause.getMessage(),cause);
                return guestAuthorizeDto.getPage();
            }

            @Override
            public ResultBean<GuestAuthorize> addGuestAuthorize(GuestAuthorize guestAuthorize) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public ResultBean<Boolean> updateGuestAuthorize(GuestAuthorizeDto guestAuthorizeDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> deleteGuestAuthorize(GuestAuthorizeDto guestAuthorizeDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> updateGuestAuthorizeEnableType(GuestAuthorize guestAuthorize) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public long getGuestCount(GuestAuthorizeDto guestAuthorizeDto) {
                log.error(cause.getMessage(),cause);
                return 0;
            }

            @Override
            public List<Map<String, Object>> guestAuthorizeCountListForGroupType(GuestAuthorizeDto guestAuthorizeDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public ResultBean<GuestAuthorize> getListByUserId(List<Long> userIds) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public Integer getGuestAuthorizeCountByDay(GuestAuthorizeDto guestAuthorizeDto) {
                log.error(cause.getMessage(),cause);
                return 0;
            }

            @Override
            public GuestAuthorize getGuestAuthorizeByCondition(GuestAuthorize guestAuthorize) {
                log.error(cause.getMessage(),cause);
                return null;
            }
        };
    }
}
