mapstrcutを使用してエンティティをdtoにマップしています。 "discount"の余分なフィールドがあり、このフィールドの値を管理するためにmapstructが必要です。このフィールドは2つの値(salePriceとretailPrice)に基づいて計算されます。Mapstruct - 数式を使用してフィールドをマッピングする(例:taget = "x"、source = "a + b")
私の質問どのようにmapstructを使用するようなこのようなマッピングを行うことができます。
@Mapping(target="discount", source="retailPrice-salePrice")
私は建物が言う一方で、このラインコードブレークを追加してみました:
error: No property named "salePrice*retailPrice" exists in source parameter(s).
@Mapping(source="salePrice*retailPrice", target="discount")
だからどのように私は、このようなマッピングを行うことができますか?
おかげではありません:) –