package com.sptg.estate.api.feigns.fallback;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.ExcelResultEnum;
import com.sptg.common.core.beans.PageBean;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.estate.api.dto.SimpleUserDto;
import com.sptg.estate.api.dto.UserDto;
import com.sptg.estate.api.entity.User;
import com.sptg.estate.api.feigns.UserFeign;
import com.sptg.estate.api.vo.DevicesAccessPushVO;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * title: UserFeignFallbackFactory
 * package: com.sptg.estate.api.feigns.fallback
 * description: 住户 服务接口容错处理
 *
 *
 *
 */
@Component
@Slf4j
public class UserFeignFallbackFactory implements FallbackFactory<UserFeign> {

    @Override
    public UserFeign create(Throwable cause) {
        return new UserFeign() {
            @Override
            public ResultBean<Page<User>> showUserList(UserDto userDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Page<User>> pagingByUserIds(UserDto userDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> addUser(UserDto userDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public User findUserById(Long id) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public ResultBean<Boolean> updateUser(UserDto userDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> deleteUser(UserDto userDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> trashOrRecover(UserDto userDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> deleteUserList(UserDto userDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<User> findListByPosition(UserDto userDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> updateUserCheckState(UserDto userDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> getUserNameById(Serializable id) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Map<String, Object>> statisticsUserCount(UserDto userDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> importUserList(UserDto userDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ExcelResultEnum.ERROR);
            }

            @Override
            public ResultBean<Map<String, Integer>> getUserAccount(UserDto userDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public int getUserCount(UserDto userDto) {
                log.error(cause.getMessage(),cause);
                return 0;
            }

            @Override
            public ResultBean<Boolean> addOrUpdateUserFaceImage(UserDto userDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ExcelResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> simpleAddOrUpdateUserFaceImage(UserDto userDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ExcelResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> sendUserFaceImage(UserDto userDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ExcelResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> deleteUserFaceImageBatch(List<String> ids) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ExcelResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> issueUserFaceImageBatch(List<SimpleUserDto> simpleUserDtoList) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ExcelResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> deleteUserCardBatch(List<String> ids) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ExcelResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> enableUserCardBatch(List<String> ids) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ExcelResultEnum.ERROR);
            }

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

            @Override
            public List<User> getListByRoomId(List<Long> roomIds) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public Page<User> pagingByRoomId(UserDto userDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public Map<String, Object> userCountForType(UserDto userDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public Map<String, Object> userCountForCreateType(UserDto userDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public List<User> getListByUserId(List<Long> userIds) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public ResultBean<Boolean> deleteUserAndRelationship(UserDto userDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ExcelResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> checkByNameAndRoomId(UserDto userDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ExcelResultEnum.ERROR);
            }

            @Override
            public User getByRoomIdAndUserId(Long roomId, String name) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public User findUserByCondition(UserDto userDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public User findUserByName(UserDto userDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public Integer findUserTotalCount(UserDto userDto) {
                log.error(cause.getMessage(),cause);
                return 0;
            }

            @Override
            public ResultBean<Page> getUserPage(PageBean<User, UserDto> pageBean) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public boolean updateEntity(User user) {
                log.error(cause.getMessage(),cause);
                return false;
            }

            @Override
            public User getByOldId(String oldId) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public User getByOldCustomerId(String customerId,Long roomId) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public boolean faceEnable(User user) {
                log.error(cause.getMessage(),cause);
                return false;
            }

            @Override
            public User getByRoomIdAndUserMobile(Long roomId, String mobile) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public List<User> getListByCondition(UserDto dto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public boolean updateUserList(List<User> userList) {
                log.error(cause.getMessage(),cause);
                return false;
            }
        };
    }
}
