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.DeviceTemplateDto;
import com.sptg.device.api.entity.DeviceTemplate;
import com.sptg.device.api.feigns.DeviceTemplateFeign;
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 DeviceTemplateFeignFallbackFactory implements FallbackFactory<DeviceTemplateFeign> {
    @Override
    public DeviceTemplateFeign create(Throwable cause) {
        return new DeviceTemplateFeign() {
            @Override
            public ResultBean<Page<DeviceTemplate>> pagingQuery(DeviceTemplateDto deviceTemplateDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> addDeviceTemplate(DeviceTemplateDto deviceTemplateDto) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> updateDeviceTemplate(DeviceTemplateDto deviceTemplateDto) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> deleteDeviceTemplate(DeviceTemplateDto deviceTemplateDto) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public DeviceTemplate getOne(DeviceTemplateDto deviceTemplateDto) {
                log.error(cause.getMessage());
                return null;
            }

            @Override
            public List<DeviceTemplate> getListByCondition(DeviceTemplateDto deviceTemplateDto) {
                log.error(cause.getMessage());
                return new ArrayList<>(0);
            }

            @Override
            public DeviceTemplate getOneById(Long id) {
                log.error(cause.getMessage());
                return null;
            }

            @Override
            public List<DeviceTemplate> getListByLikeTypeCode(DeviceTemplateDto deviceTemplateDto) {
                log.error(cause.getMessage());
                return new ArrayList<>(0);
            }
        };
    }
}
