package com.yuchen.saas.manage.system.api.feign;

import com.yuchen.saas.manage.system.api.entity.Role;
import com.yuchen.saas.manage.system.api.vo.RoleParkVO;
import com.yuchen.saas.manage.system.api.vo.RoleVO;
import feign.hystrix.FallbackFactory;
import org.nest.springwrap.core.secure.ContextUser;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @Author: 肖润飞
 * @CreateTime: 2022/11/25 10:08
 * @Description: TODO
 * @Version: 1.0
 */
@Component
public class RoleFeignFallback implements FallbackFactory<RoleFeignServer> {

    @Override
    public RoleFeignServer create(Throwable cause) {
        return new RoleFeignServer() {
            @Override
            public R<RoleVO> detail(Role role) {
                return R.error("远程调用失败");
            }

            @Override
            public R list(Map<String, Object> role, ContextUser contextUser) {
                return R.error("远程调用失败");
            }

            @Override
            public R listByAlias(List<String> roleAlias, Long tenantId) {
                return R.error("远程调用失败");
            }

            @Override
            public R<List<RoleParkVO>> getRoleParksByRoleId(String id) {
                return R.error("远程调用失败");
            }
        };
    }
}