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

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

@Component
@Slf4j
public class MemberDeviceFeignFallbackFactory implements FallbackFactory<MemberDeviceFeign> {
    @Override
    public MemberDeviceFeign create(Throwable cause) {
        return new MemberDeviceFeign() {
            @Override
            public ResultBean<Page<MemberDevice>> pagingQuery(MemberDevice memberDevice) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> enable(MemberDevice memberDevice) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public List<MemberDevice> getListByMemberId(MemberDevice memberDevice) {
                log.error(cause.getMessage(),cause);
                return new ArrayList<>();
            }

            @Override
            public ResultBean<Boolean> addBatch(List<MemberDevice> memberDeviceList) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> deleteBatch(List<Long> ids) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
