package com.cool.store.service.impl;

import com.cool.store.enums.WorkflowStageEnum;
import com.cool.store.exception.ApiException;
import com.cool.store.request.CloseFollowRequest;
import com.cool.store.request.TransferInvestmentManagerRequest;
import com.cool.store.service.WorkFlowService;
import com.cool.store.service.impl.workflow.IntentWorkFlowService;
import com.cool.store.service.impl.workflow.InterviewWorkFlowService;
import com.cool.store.service.impl.workflow.ReservationWorkFlowService;
import com.cool.store.service.impl.workflow.WorkFlowBaseService;
import com.cool.store.utils.CommonContextUtil;
import org.springframework.stereotype.Service;

/**
 * @author zhangchenbiao
 * @FileName: WorkFlowBaseService
 * @Description:
 * @date 2023-06-26 21:14
 */
@Service
public class WorkFlowServiceImpl implements WorkFlowService{
    private WorkFlowBaseService getWorkflowService(WorkflowStageEnum workflowStage){
        switch (workflowStage){
            case INTENT:
                return CommonContextUtil.getBean(IntentWorkFlowService.class);
            case RESERVATION:
                return CommonContextUtil.getBean(ReservationWorkFlowService.class);
            case INTERVIEW:
                return CommonContextUtil.getBean(InterviewWorkFlowService.class);
            default:
                return null;
        }
    }


    @Override
    public void endProcess(WorkflowStageEnum workflowStage, CloseFollowRequest request) throws ApiException {
        getWorkflowService(workflowStage).endProcess(request);
    }

    @Override
    public void transferInvestmentManager(WorkflowStageEnum workflowStage, TransferInvestmentManagerRequest request) throws ApiException {
        getWorkflowService(workflowStage).transferInvestmentManager(request);
    }
}
