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.ServerUserDto;
import com.sptg.estate.api.entity.ServerUser;
import com.sptg.estate.api.entity.ServerUserDetail;
import com.sptg.estate.api.entity.ServerUserFaceImage;
import com.sptg.estate.api.feigns.ServerUserFeign;
import com.sptg.estate.api.vo.DevicesAccessPushVO;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * title: ServerUserFallbackFactory
 * package: com.sptg.estate.api.feigns.fallback
 * description:服务人员-服务容错处理类
 *
 *
 *
 */
@Component
@Slf4j
public class ServerUserFeignFallbackFactory implements FallbackFactory<ServerUserFeign> {
    @Override
    public ServerUserFeign create(Throwable cause) {
        return new ServerUserFeign() {
            @Override
            public ResultBean<Page<ServerUser>> showServerUserList(ServerUserDto serverUserDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Page<ServerUser>> pagingByServerUserIds(ServerUserDto serverUserDto) {
                return null;
            }

            @Override
            public ResultBean<Boolean> insertOrUpdateServerUser(ServerUser serverUser) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public ResultBean<ServerUser> findServerUserById(long id) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public ResultBean<Boolean> deleteServerUser(long id) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public ResultBean<Boolean> deleteServerUserList(ServerUserDto serverUserDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public ResultBean<Boolean> updateIsEnable(long id, int enable) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public ResultBean<Boolean> insertServerUserFaceImage(ServerUserFaceImage serverUserFaceImage) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> deleteServerUserFaceImage(ServerUserFaceImage serverUserFaceImage) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> addOrEditOpenPermission(ServerUser serverUser) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> accessDevicesManualPush(DevicesAccessPushVO devicesAccessPushVO) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<ServerUser> findServerUserCardAndFaceById(long id) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public int getServerUserCount(ServerUserDto serverUserDto) {
                log.error(cause.getMessage(),cause);
                return 0;
            }

            @Override
            public List<ServerUserDetail> findServerUserDetailList(long serverUserId) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public List<ServerUser> getServerUserByCondition(ServerUserDto serverUserDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public boolean updateServerUserList(List<ServerUser> serverUserList) {
                log.error(cause.getMessage(),cause);
                return false;
            }
        };
    }
}
