1
我是新來的MapStruct API,任何人都可以說如何做嵌套映射。 我有兩個類,一個是我的實際purchaseOrder類,它是我的目標類,另一個是EDPurchaseOrder類,它被稱爲源文件,這裏不用擔心我使用的命名約定,只需使用源文件和目標文件即可。Mapstruct中的嵌套映射
源類
源類EDCustomerOrder及其引用類
public class EDCustomerOrder{
private Integer orderID;
private String orderNumber;
private BigDecimal orderTotalQty;
private String UOM;
private PickupDTO pickupPoints;
private Integer supplierID;
private String supplierName;
private String supplierNature;
private EDAddress supplierEDAddress;
}
public class EDPickup{
private List<EDPOItem> items;
}
public class EDAddress{
private String addressLine1;
private String addressLine2;
private String addressLine3;
private String city;
private String state;
private string countryCode;
private String country;
private String postalCode;
}
public class EDPOItem{
private Integer itemID;
private String itemCode;
private String itemDescription;
private Integer itemQuantity;
}
目標類
這裏我的目標類CustomerOrder和它引用類
public class CustomerOrder{
private Integer orderID;
private String orderNumber;
private List<Pickup> pickupPoints;
private Supplier supplierDetail;
}
public class Pickup{
private Integer pickupID;
private Integer pickupLocationNumber;
private List<POItem> items;
}
public class POItem{
private Integer itemID;
private String itemCode;
private String itemDescription;
private Integer itemQuantity;
}
public class Supplier{
private Integer supplierID;
private String supplierName;
private String supplierNature;
private Address supplierAddress;
}
public class Address{
private String addressLine1;
private String addressLine2;
private String addressLine3;
private String city;
private String state;
private string countryCode;
private String country;
private String postalCode;
}
嗨@Gunnar感謝您的回覆,我提出了我的問題,可以幫助我再次對我 – AdamIJK
您是否嘗試了我上面提出的建議? – Gunnar
嗨@Gunnar嗨@Gunnar我嘗試了你的建議,我遵循相同的方式,就像你在上面爲我工作一樣,但我正在嘗試一些不同的場景,因爲面臨困難,我可以給你的郵件地圖添加地圖。我會發送我所有的問題。 – AdamIJK