[英]Mapping domain objects to resource objects in service layer or web layer?
I am using Dozer to map my domain objects to resource objects (REST) which only contains the data. 我正在使用推土机将域对象映射到仅包含数据的资源对象(REST)。 I am currently doing this mapping in my web layer.
我目前正在网络层中进行此映射。 However should I move the translation to the service layer?
但是,我应该将翻译移到服务层吗?
I don't know your architecture, but I guess that you have layers in a hierarchical order and access should only be allowed from a higher layer to a lower, right?! 我不知道您的体系结构,但是我想您具有按层次结构排列的层,应该只允许从较高的层到较低的层访问,对吗?
Based on that assumption... 基于这个假设...
If you move the mapping to the service layer, the service layer will be aware of the REST API. 如果将映射移动到服务层,则服务层将知道REST API。 Thus you introduce a dependency from a lower layer (service) to a higher layer (presentation).
因此,您引入了从较低层(服务)到较高层(表示)的依赖关系。 I guess this does not comply to your architecture, because a service layer's purpose is normally to provide a presentation free API to access domain logic.
我猜这不符合您的体系结构,因为服务层的目的通常是提供免费的演示文稿API来访问域逻辑。 Thus I would not move the mapping to the service layer.
因此,我不会将映射移到服务层。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.