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.NoticeDto;
import com.sptg.estate.api.entity.Notice;
import com.sptg.estate.api.feigns.NoticeFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * title: NoticeFallbackFactory
 * package: com.sptg.estate.api.feigns.fallback
 * description:公告-服务容错处理类
 *
 *                
 *                
 */
@Component
@Slf4j
public class NoticeFeignFallbackFactory implements FallbackFactory<NoticeFeign> {
    @Override
    public NoticeFeign create(Throwable cause) {
        return new NoticeFeign(){
            @Override
            public ResultBean<Page<Notice>> showNoticeList(NoticeDto noticeDto) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public ResultBean<List<Notice>> getList(@RequestBody NoticeDto noticeDto) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public ResultBean<Boolean> addOrEditNotice(Notice notice) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public ResultBean<Notice> findNoticeById(long id) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public ResultBean<Boolean> deleteNoticeById(long id) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public ResultBean<Boolean> deleteNoticeList(NoticeDto noticeDto) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public boolean updateNoticeList(List<Notice> noticeList) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return false;
            }
        };
    }
}
