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

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

/**
 * title: AccessRecordsFeignFallbackFactory
 * package: com.sptg.estate.api.feigns.fallback
 * description:  服务接口容错处理
 *
 *
 *
 */
@Component
@Slf4j
public class AccessRecordsFeignFallbackFactory implements FallbackFactory<AccessRecordsFeign> {

    @Override
    public AccessRecordsFeign create(Throwable cause) {
        return new AccessRecordsFeign(){

            @Override
            public ResultBean<Page<AccessRecords>> showAccessRecordsList(AccessRecordsDto accessRecordsDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Page<AccessRecords>> accessRecordsListByMemberId(AccessRecordsDto accessRecordsDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }


            @Override
            public ResultBean<?> addRecords(AccessRecords records) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> addAccessRecords(AccessRecords records) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> addDHAccessRecords(AccessRecords records) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public ResultBean<Boolean> updateAccessRecords(AccessRecordsDto accessRecordsDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> deleteAccessRecords(AccessRecordsDto accessRecordsDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public List<Map<String, Object>> accessCountListForGroupType(AccessRecordsDto accessRecordsDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public Map<String, Object> accessCountForOpenWay(AccessRecordsDto accessRecordsDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public Long getAccessRecordsCount(AccessRecordsDto accessRecordsDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

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

            @Override
            public Integer getAccessRecordsCountByDay(AccessRecordsDto accessRecordsDto) {
                log.error(cause.getMessage(),cause);
                return 0;
            }

            @Override
            public ResultBean<Page<Map<String, Object>>> getDeviceOpenCountList(AccessRecordsDto accessRecordsDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Page<AccessRecords>> getAccessRecordsList(AccessRecordsDto accessRecordsDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public List<AccessRecords> getListByCondition(AccessRecordsDto accessRecordsDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public boolean updateBatchList(List<AccessRecords> accessRecordList) {
                log.error(cause.getMessage(),cause);
                return false;
            }
        };
    }
}
