package com.sptg.device.api.feigns.fallback;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.PageBean;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.device.api.dto.FlowCardDto;
import com.sptg.device.api.entity.FlowCard;
import com.sptg.device.api.feigns.FlowCardFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * title: DeviceFeignFallbackFactory
 * description:
 *
 *
 *
 */
@Component
@Slf4j
public class FlowCardFeignFallbackFactory implements FallbackFactory<FlowCardFeign> {
    @Override
    public FlowCardFeign create(Throwable cause) {
        return new FlowCardFeign() {

            @Override
            public ResultBean<Page<FlowCard>> pagingQuery(PageBean<FlowCard, FlowCardDto> pageBean) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR,pageBean);
            }

            @Override
            public ResultBean<Boolean> add(FlowCardDto dto) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> edit(FlowCardDto dto) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public FlowCard getById(FlowCardDto dto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

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

            @Override
            public ResultBean<Boolean> delete(FlowCardDto dto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> bind(FlowCardDto dto) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> reBind(FlowCardDto dto) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public FlowCard getOneFlowCard(FlowCardDto dto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public FlowCard getByOldId(String oldId) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public ResultBean<Boolean> updateBind(FlowCardDto dto) {
                log.error(cause.getMessage(),cause);
                return null;
            }
        };
    }
}
