package com.yuchen.saas.flow.api.feign;

import com.yuchen.saas.flow.api.dto.FlowTaskQuery;
import com.yuchen.saas.flow.api.dto.NodeUser;
import com.yuchen.saas.flow.api.dto.ProcessInstanceParamDTO;
import com.yuchen.saas.flow.api.dto.TaskParamDTO;
import com.yuchen.saas.flow.api.dto.req.customerFlow.SyncFlowToCustomerReqDTO;
import com.yuchen.saas.flow.api.entity.SaasFlowProcessInstanceRecord;
import com.yuchen.saas.flow.api.utils.FlowFeignFallbackUtils;
import feign.hystrix.FallbackFactory;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.stereotype.Component;

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

/**
 * @author zhouhanwei
 * @create 2024/3/4 10:29
 */
@Component
public class CustomerFlowFallback implements FallbackFactory<CustomerFlowFeign> {
    @Override
    public CustomerFlowFeign create(Throwable throwable) {
        return new CustomerFlowFeign() {
            @Override
            public R syncFlowToCustomer(SyncFlowToCustomerReqDTO reqDTO) {
                return FlowFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<SaasFlowProcessInstanceRecord> customerCompleteTask(TaskParamDTO paramDTO) {
                return FlowFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<SaasFlowProcessInstanceRecord> startProcessInstance(ProcessInstanceParamDTO paramDTO) {
                return FlowFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<List<Map<String, NodeUser>>> checkApplyDimensionality(ProcessInstanceParamDTO paramDTO) {
                return FlowFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<List<SaasFlowProcessInstanceRecord>> listByAssetsIds(List<String> ids) {
                return FlowFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R stopProcessInstance(TaskParamDTO paramDTO) {
                return FlowFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<String> getRuTaskById(String taskId) {
                return FlowFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<Boolean> updateFormVariables(TaskParamDTO paramDTO) {
                return FlowFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<Boolean> rollBackApproval(TaskParamDTO paramDTO) {
                return FlowFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<List<String>> flowQueryMineTaskByType(FlowTaskQuery paramDTO) {
                return FlowFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<String> gerRuTaskByDataId(String processInstanceId) {
                return FlowFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<Long> getRuTaskCount(FlowTaskQuery paramDTO) {
                return FlowFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<Long> getAllRuTaskCount(FlowTaskQuery paramDTO) {
                return FlowFeignFallbackUtils.printLogAndReturn(throwable);
            }
        };
    }
}
