package com.example.factory;
|
|
import com.example.config.ConfigValue;
|
import com.example.service.HisService;
|
import com.example.service.PacsService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.context.ApplicationContext;
|
import org.springframework.stereotype.Component;
|
|
/**
|
* @Company: 西安路泰科技有限公司
|
* @Author: zhaowenxuan
|
* @Date: 2024/12/18 09:32
|
*/
|
@Component
|
public class ServiceFactory {
|
private final ApplicationContext applicationContext;
|
|
@Autowired
|
public ServiceFactory(ApplicationContext applicationContext) {
|
this.applicationContext = applicationContext;
|
}
|
|
public HisService getService(String hospName) {
|
String beanName = getServiceBeanName(hospName);
|
return (HisService) applicationContext.getBean(beanName);
|
}
|
|
public PacsService getPacsService(String hospName) {
|
String beanName = getServiceBeanName(hospName);
|
return (PacsService) applicationContext.getBean(beanName+"Pacs");
|
}
|
|
|
private String getServiceBeanName(String hospName) {
|
switch (hospName) {
|
case "shanxiqinxamjyy":
|
return "ShanXiQinXiAnMeiJi"; // 对应的业务 Bean 名称
|
default:
|
throw new RuntimeException("找不到对应的医院服务配置:" + hospName);
|
}
|
}
|
}
|