package com.microservices.system.api.factory;

import com.microservices.common.core.domain.R;
import com.microservices.system.api.RemotePmsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 用户服务降级处理
 *
 * @author microservices
 */
@Component
public class RemotePmsFallbackFactory implements FallbackFactory<RemotePmsService> {
    private static final Logger log = LoggerFactory.getLogger(RemotePmsFallbackFactory.class);

    @Override
    public RemotePmsService create(Throwable throwable) {
        log.error("项目管理服务调用失败:{}", throwable.getMessage());
        return new RemotePmsService() {

            @Override
            public R<Boolean> changeUserGitlinkRole(Long userId, Long deptId, Long oldRoleId, Long newRoleId, String source, String userKey) {
                return R.fail("切换用户在Gitlink组织团队失败:" + throwable.getMessage());
            }
        };
    }
}
