订单模块-结构设计
作者:互联网
IOrderDomainService给网关调用,接收一个参数orderType,比如createOrder(CreateOrderRequest req)
=======================================================================================================
class OrderDomainService
public CreateOrderResult createOrder(CreateOrderRequest request) {
//参数验证
return this.getOrderService(request.getOrderType().toString()).createOrder(request);
}
private IOrderService getOrderService(String orderType) {
String className = String.format("orderService%s", orderType);
IOrderService orderService = MyApplicationContext.getInstance().getBean(className, IOrderService.class, false);
if (orderService == null) {
throw new ServiceException(String.format("合作方订单服务未定义[%s]", orderType), ServiceException.NOT_EXIST);
}
return orderService;
}
====================================================================================================================
@Service("orderService1")
public class Child1OrderService extends AbstractOrderService implements IChild1OrderService
@Service("orderService2")
public class Child2OrderService extends AbstractOrderService implements IChild2OrderService
标签:String,orderType,public,订单,orderService,模块,IOrderService,class,结构设计 来源: https://www.cnblogs.com/joke0406/p/10905794.html