外观模式,改造后

This commit is contained in:
2020-02-28 11:28:53 +08:00
parent 91cceedf26
commit aabff787bf
2 changed files with 4 additions and 18 deletions

View File

@@ -13,23 +13,11 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class GiftExchangeService {
private PointPaymentService pointPaymentService;
private PointPaymentService pointPaymentService = new PointPaymentService();
private QualifyService qualifyService;
private QualifyService qualifyService = new QualifyService();
private ShippingService shippingService;
public void setPointPaymentService(PointPaymentService pointPaymentService) {
this.pointPaymentService = pointPaymentService;
}
public void setQualifyService(QualifyService qualifyService) {
this.qualifyService = qualifyService;
}
public void setShippingService(ShippingService shippingService) {
this.shippingService = shippingService;
}
private ShippingService shippingService = new ShippingService();
/**
* 系统交互逻辑

View File

@@ -15,9 +15,7 @@ class GiftExchangeServiceTest {
PointGift pointGift = new PointGift("手环");
// 注入服务
GiftExchangeService exchangeService = new GiftExchangeService();
exchangeService.setPointPaymentService(new PointPaymentService());
exchangeService.setQualifyService(new QualifyService());
exchangeService.setShippingService(new ShippingService());
// 兑换
exchangeService.giftExchange(pointGift);
}