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

/**
 * title: NoticePushDetailsFeignFallbackFactory
 * package: com.sptg.estate.api.feigns.fallback
 * description:
 *
 *
 *
 */
@Component
@Slf4j
public class NoticePushDeviceDetailsFeignFallbackFactory implements FallbackFactory<NoticePushDeviceDetailsFeign> {


    @Override
    public NoticePushDeviceDetailsFeign create(Throwable cause) {
        return new NoticePushDeviceDetailsFeign() {
            @Override
            public ResultBean<Page<NoticePushDeviceDetails>> showNoticePushDeviceDetailsList(NoticePushDeviceDetails noticePushDeviceDetails) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public ResultBean<NoticePushDeviceDetails> getNoticePushDevice(Long id) {
                log.error(cause.getMessage(),cause);
                return null;
            }
        };
    }
}
