mercredi 4 janvier 2023

What is the best architecture for several DTO's to be called by the same method

I am projecting API, where I have 1 controller and several services for preparing some kinds of reports. Let's say it's ReportA, ReportB and ReportC. All services inherit from abstract class ReportBase, where I have some methods common for all services, fe. GetTotalUsage, which download data from database before calculating the report.

Now it is the tricky part:

method GetTotalUsage use the ReportARequestDto, but I would like to make it take any kind of the DTO (also ReportBRequestDto and ReportCRequestDto).

All DTO's have common properties (StationId,MediaName,DateTimeRange) and some unique.

I could make base class for all DTO's and inherit from it, but it's not a best solution, since I may need to modify and use different properties in the future for another method.

The composite pattern makes the DTO's complex.

What is the most appropiate aproach?

Aucun commentaire:

Enregistrer un commentaire