From fe764bc2ab775dcf83f2047fd9f2201eb21e0e66 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Fri, 12 Jul 2024 15:02:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E7=A9=BA=E8=AE=A2=E5=8D=95=E5=8F=B7=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/aggregates/order/OrderDetail.java | 40 ++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/chint/domain/aggregates/order/OrderDetail.java b/src/main/java/com/chint/domain/aggregates/order/OrderDetail.java index 6b278a0e..db0c29c0 100644 --- a/src/main/java/com/chint/domain/aggregates/order/OrderDetail.java +++ b/src/main/java/com/chint/domain/aggregates/order/OrderDetail.java @@ -209,28 +209,48 @@ public class OrderDetail implements Serializable { return this; } - public OrderDetail deepClone(){ + public OrderDetail deepClone() { OrderDetail copyOrderDetail = BeanUtil.copyProperties(this, OrderDetail.class); - HotelOrderDetail copiedHotelOrderDetail = BeanUtil.copyProperties(this.hotelOrderDetail, HotelOrderDetail.class); - copyOrderDetail.setHotelOrderDetail(copiedHotelOrderDetail); + if (this.hotelOrderDetail != null) { + HotelOrderDetail copiedHotelOrderDetail = BeanUtil.copyProperties(this.hotelOrderDetail, HotelOrderDetail.class); + copyOrderDetail.setHotelOrderDetail(copiedHotelOrderDetail); + } else { + copyOrderDetail.setHotelOrderDetail(null); + } + // 深拷贝 carOrderDetail - CarOrderDetail copiedCarOrderDetail = BeanUtil.copyProperties(this.carOrderDetail, CarOrderDetail.class); - copyOrderDetail.setCarOrderDetail(copiedCarOrderDetail); + if (this.carOrderDetail != null) { + CarOrderDetail copiedCarOrderDetail = BeanUtil.copyProperties(this.carOrderDetail, CarOrderDetail.class); + copyOrderDetail.setCarOrderDetail(copiedCarOrderDetail); + } else { + copyOrderDetail.setCarOrderDetail(null); + } + // 深拷贝 flightOrderDetail - FlightOrderDetail copiedFlightOrderDetail = BeanUtil.copyProperties(this.flightOrderDetail, FlightOrderDetail.class); - copyOrderDetail.setFlightOrderDetail(copiedFlightOrderDetail); + if (this.flightOrderDetail != null) { + FlightOrderDetail copiedFlightOrderDetail = BeanUtil.copyProperties(this.flightOrderDetail, FlightOrderDetail.class); + copyOrderDetail.setFlightOrderDetail(copiedFlightOrderDetail); + } else { + copyOrderDetail.setFlightOrderDetail(null); + } + // 深拷贝 trainOrderDetail - TrainOrderDetail copiedTrainOrderDetail = BeanUtil.copyProperties(this.trainOrderDetail, TrainOrderDetail.class); - copyOrderDetail.setTrainOrderDetail(copiedTrainOrderDetail); + if (this.trainOrderDetail != null) { + TrainOrderDetail copiedTrainOrderDetail = BeanUtil.copyProperties(this.trainOrderDetail, TrainOrderDetail.class); + copyOrderDetail.setTrainOrderDetail(copiedTrainOrderDetail); + } else { + copyOrderDetail.setTrainOrderDetail(null); + } + // 深拷贝 otherOrderDetail //OtherOrderDetail copiedOtherOrderDetail = BeanUtil.copyProperties(this.otherOrderDetail, OtherOrderDetail.class); copyOrderDetail.setOtherOrderDetail(null); // 深拷贝 orderEventList - if(this.orderEventList != null && !this.orderEventList.isEmpty()) { + if (this.orderEventList != null && !this.orderEventList.isEmpty()) { List copiedOrderEventList = this.orderEventList.stream() .map(event -> BeanUtil.copyProperties(event, OrderEvent.class)) .collect(Collectors.toList());