package com.sptg.third.api.feigns.qinlin.fallback;

import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.third.api.entity.qinlin.*;
import com.sptg.third.api.feigns.qinlin.QLinFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author zwx
 * @create 2020/11/28 20:19
 */
@Slf4j
@Component
public class QLinFeignFallbackFactory implements FallbackFactory<QLinFeign> {
    @Override
    public QLinFeign create(Throwable cause) {
        return new QLinFeign() {

            @Override
            public ResultBean<String> addUser(QLinUser qLinUser) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> deleteUser(QLinUser qLinUser) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> deleteUserPermission(QLinUserDevice qLinUserDevice) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> deleteDevice(QLinDevice qLinDevice) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> getDeviceInfo(QLinDevice qLinDevice) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

//            @Override
//            public ResultBean<String> deleteDevice(QLinDevice qLinDevice) {
//                log.error(cause.getMessage(), cause);
//                return new ResultBean<>(ResultEnum.ERROR);
//            }
//
//            @Override
//            public ResultBean<String> getDeviceInfo(QLinDevice qLinDevice) {
//                log.error(cause.getMessage(), cause);
//                return new ResultBean<>(ResultEnum.ERROR);
//            }


            @Override
            public ResultBean<String> remoteOpenDoor(QLinUserDevice qLinUserDevice) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> getLogs(QLinQuery qLinQuery) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }


            @Override
            public ResultBean<String> recordQinLinApiLog(QLinApiLog qLinApiLog) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> addCommunity(QLinCommunityDevices qLinCommunityDevices) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> addDevices(QLinCommunityDevices qLinCommunityDevices) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
