I'm using the MVC approach.
So when I'm receiving an EntityFilterRequest
from the body (payload) for PUT/POST verbs, I need to transform the EntityFilterRequest
to an EntityFilterRequestModel
using
EntityFilterRequestModel.of(EntityFilterRequest).
The of
method performs:
So basically instead of having the traditionally MVC approach, I have a layer between the C
and the M
to perform the conversion between the *requests
and the *requestModels
classes.
- All the necessary casts (String to Integer, Short)
- Default values for empty fields from the request
- Performs some check existents entity ids.
- Build new fields that will be necessary for the model layer.
Is this already a design pattern? Is there a better approach?
The main idea is to remove all validations describes above from the Model using the classes EntityFilterRequestModel
and reduce the unnecessary code on the M
layer.
If you needs more details please add comments and I will try to be more clear.
Aucun commentaire:
Enregistrer un commentaire