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

/**
 * title: PositionFeignFallbackFactory
 * package: com.sptg.estate.api.feigns.fallback
 * description:设备安装-服务容错处理类
 *
 *               
 *                
 */
@Component
@Slf4j
public class DeviceInstallationFeignFallbackFactory implements FallbackFactory<DeviceInstallationFeign> {

    @Override
    public DeviceInstallationFeign create(Throwable cause) {
        return new DeviceInstallationFeign(){

            @Override
            public ResultBean<Page<DeviceInstallation>> showList(DeviceInstallationDto dto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<DeviceInstallation> findById(Long id) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public ResultBean<Integer> countByOrgPosition(String orgPosition) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<DeviceInstallation> findListByPosition(DeviceInstallationDto dto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> countBySerialNumber(String serialNumber) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> insertEntity(DeviceInstallation deviceInstallation) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<DeviceInstallation> findBySerialNumber(String serialNumber) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<DeviceInstallation> findEntityById(Long id) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

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

            @Override
            public ResultBean<DeviceInstallation> findByCondition(DeviceInstallation deviceInstallation) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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