package com.sptg.permissions.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.permissions.api.dto.AccountDto;
import com.sptg.permissions.api.entity.Account;
import com.sptg.permissions.api.feigns.AccountFeign;
import com.sun.org.apache.xpath.internal.operations.Bool;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * title: AccountFeignFallbackFactory
 * package: com.sptg.permissions.api.feigns.fallback
 * description: 账号对外服务容错处理
 *
 *                  
 *                 
 */
@Component
@Slf4j
public class AccountFeignFallbackFactory implements FallbackFactory<AccountFeign> {

    @Override
    public AccountFeign create(Throwable cause) {
        return new AccountFeign() {
            @Override
            public ResultBean<Page> pagingQuery(PageBean<Account, AccountDto> pageBean) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Account> addEntity(AccountDto dto) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

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

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

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

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

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

            @Override
            public ResultBean<Boolean> updateById(Account account) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

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

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

            @Override
            public Account getByOrgId(String orgId) {
                log.error(cause.getMessage(), cause);
                return null;
            }

            @Override
            public Boolean addEntityByResidential(Account account) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public Page<Account> page(PageBean<Account, AccountDto> pageBean) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public ResultBean<String> resetPassword(AccountDto dto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public ResultBean<Boolean> modifyPassword(Account account) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public Account getByUserMobile(String userMobile) {
                return null;
            }
        };
    }
}
