订单模块-结构设计
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