package com.persagy.dmp.auth.client;

import com.persagy.dmp.auth.domain.BossAuthMenu;
import com.persagy.dmp.auth.domain.BossAuthPermission;
import com.persagy.dmp.auth.domain.BossAuthUser;
import com.persagy.dmp.common.model.response.CommonResult;
import com.persagy.dmp.common.utils.ResultHelper;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * boss-auth应用
 * @author : lijie
 * Update By 2022/1/10 19:21
 */
@Slf4j
public class BossAuthFallbackFactory implements FallbackFactory<BossAuthClient> {

    /**
     * 调用失败,返回
     */
    @Override
    public BossAuthClient create(Throwable throwable) {
        return new BossAuthClient(){

            @Override
            public CommonResult<BossAuthUser> loginInnerLoginInfo() {
                return ResultHelper.failure("调用boss-auth失败:" + throwable.getMessage());
            }

            @Override
            public CommonResult<BossAuthUser> loginOuterLoginInfo() {
                return ResultHelper.failure("调用boss-auth失败:" + throwable.getMessage());
            }

            @Override
            public CommonResult<List<BossAuthMenu>> loginMenu(String websiteId) {
                return ResultHelper.failure("调用boss-auth失败:" + throwable.getMessage());
            }

            @Override
            public CommonResult<List<BossAuthPermission>> loginPermission(String websiteId) {
                return ResultHelper.failure("调用boss-auth失败:" + throwable.getMessage());
            }
        };
    }

}
