package cn.com.poc.law.extractEntityStrategy;

import cn.com.poc.law.extractEntityStrategy.extractEntityType.MotorVehicleDrivingComplaintType;
import cn.com.yict.framemax.core.exception.BusinessException;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;


@Component
public class LawyerTemplateExtractServiceBuilder implements ApplicationContextAware {

    private ApplicationContext applicationContext;

    public ExtractEntityStrategy getService(LawyerExtractTypeConstants.LawyerExtractTypeEnum type) throws Exception {
        if (LawyerExtractTypeConstants.LawyerExtractTypeEnum.motorVehicleDrivingComplaint.name().equals(type.name())) {
            return applicationContext.getBean(MotorVehicleDrivingComplaintType.class);
        }
        throw new BusinessException("选择模板异常!");
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }
}
