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

import com.yuchen.saas.manage.user.api.entity.User;
import com.yuchen.saas.manage.user.api.request.UserInfoRequest;
import com.yuchen.saas.manage.user.api.response.UserInfoResponse;
import com.yuchen.saas.manage.user.api.vo.UserVO;
import feign.hystrix.FallbackFactory;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author: 肖润飞
 * @CreateTime: 2022/11/25 14:01
 * @Description: TODO
 * @Version: 1.0
 */
@Component
public class UserFeignFallback implements FallbackFactory<UserFeignServer> {

    @Override
    public UserFeignServer create(Throwable cause) {
        return new UserFeignServer() {

            @Override
            public R accountInfo(String account) {
                return R.error("远程调用失败");
            }

            @Override
            public R<List<UserInfoResponse>> findPatrolUser(UserInfoRequest userInfoRequest) {
                return R.error("远程调用失败");
            }

            @Override
            public R<UserVO> detail(User user) {
                return R.error("远程调用失败");
            }
        };
    }
}