package com.crunii.micro.service.sysmgr.api.factory;

import com.crunii.micro.common.dto.Result;
import com.crunii.micro.service.sysmgr.api.domain.dto.OrgNode;
import com.crunii.micro.service.sysmgr.api.domain.dto.worker.WorkerRoleVo;
import com.crunii.micro.service.sysmgr.api.worker.TsmWorkerClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author gongsongtao
 * @date 2023/9/27 15:25
 */
@Slf4j
@Component
public class TsmWorkerFallbackFactory implements FallbackFactory<TsmWorkerClient> {

    @Override
    public TsmWorkerClient create(Throwable cause) {
        return new TsmWorkerClient() {
            @Override
            public Result<List<WorkerRoleVo>> getRoleListByWorkerId(Long workerId) {
                log.error("调用接口异常:{}", workerId);
                return Result.ofFail("接口调用异常");
            }

            @Override
            public Result<List<OrgNode>> getOrgListByWorkerId(Long workerId) {
                log.error("调用接口异常:{}", workerId);
                return Result.ofFail("getOrgListByWorkerId接口调用异常");
            }
        };
    }
}
