What are the ābest practicesā for defining in the Play Framework objects that have ācalculatedā fields and are not directly mapped to any of the fields associated with the entity?
For example, I would like to define a model for a āproductā that has a ālist priceā and a āreal priceā.
In DB terms, the ālist priceā is directly mapped to the āint listPriceā in the model class. However, the "real price" is calculated by the "list price" using additional data that is not related to the "product" itself (for example, the general discount of the store, the discount for specific departments, etc.), in which some "business logic" is involved )
Since my application needs to identify the REST API (and not just the web application), I would really like to extend the Product class to support the "calculated" field, therefore both "MyProduct.listPrice" and "MyProduct". finalPrice ".
Is it possible to add transition members to a model class? If not, should you determine the class derived from the model and use it?
Thanks for any hint.
Max
source share