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.dto.AccountOauthDto;
import com.sptg.permissions.api.dto.AccountOauthDto;
import com.sptg.permissions.api.entity.Account;
import com.sptg.permissions.api.entity.AccountOauth;
import com.sptg.permissions.api.entity.AccountOauth;
import com.sptg.permissions.api.feigns.AccountOauthFeign;
import com.sptg.permissions.api.feigns.AccountOauthFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * title: AccountOauthFeignFallbackFactory
 * package: com.sptg.permissions.api.feigns.fallback
 * description: 账号角色对外服务接口-容错处理
 *
 *                  
 *                 
 */
@Component
@Slf4j
public class AccountOauthFeignFallbackFactory implements FallbackFactory<AccountOauthFeign> {

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

            @Override
            public ResultBean<AccountOauth> getByUuIdAndSource(AccountOauthDto dto) {
                return null;
            }

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

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