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.common.core.constant.OperationConstant;
import com.sptg.estate.api.dto.NoticePushDto;
import com.sptg.estate.api.dto.UserDto;
import com.sptg.estate.api.entity.NoticePush;
import com.sptg.estate.api.entity.NoticePushDetails;
import com.sptg.estate.api.entity.NoticePushImg;
import com.sptg.estate.api.feigns.NoticePushFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * title: NoticePushDetailsFallbackFactory
 * package: com.sptg.estate.api.feigns.fallback
 * description:公告发布详细-服务容错处理类
 *
 *                
 *                
 */
@Component
@Slf4j
public class NoticePushFeignFallbackFactory implements FallbackFactory<NoticePushFeign> {
    @Override
    public NoticePushFeign create(Throwable cause) {
        return new NoticePushFeign(){
            @Override
            public ResultBean<Page<NoticePush>> showNoticePushList(NoticePushDto noticePushDto) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public ResultBean<Long> addNoticePush(NoticePush noticePush) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public ResultBean<NoticePush> findNoticePushById(long id) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public List<NoticePushImg> selectNoticePushImgList(long noticePushId) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return new ArrayList<>(OperationConstant.ZERO);
            }

            @Override
            public List<NoticePushDetails> getListByNoticePushId(long noticePushId) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return new ArrayList<>(OperationConstant.ZERO);
            }

            @Override
            public Boolean updateNoticePushById(NoticePush noticePush) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return false;
            }

            @Override
            public List<NoticePush> getListByUser(UserDto userDto) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return null;
            }
        };
    }
}
