简体   繁体   English

将域对象映射到服务层或Web层中的资源对象?

[英]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.

相关问题 在Java中将域对象映射到Web服务代理对象 - Mapping domain objects to web service proxy objects in Java 域对象/服务和业务逻辑层 - Domain objects/services and the Business Logic Layer 将 Presentation Modal 对象传递给服务和业务层 - Passing Presentation Modal objects to the service and business layer 在Servlet的字段中具有服务层对象 - Having service layer objects in servlet's fields 具有数据传输对象 (DTO) 的服务层 - Service layer with Data Transfer Objects (DTO) Libgdx:Tiled Objects图层用于碰撞 - Libgdx: Tiled Objects layer for collision Spring DTO-DAO(资源-实体)映射在哪个应用层:控制器还是服务? - Spring DTO-DAO (Resource - entity) mapping goes in which application layer: Controller or Service? 服务层应该将对象或id作为输入吗? 应答应该是对象吗? - Should service layer take objects or id's as input? Should responses be objects? 服务层和域模型层之间有什么区别 - what's the difference between service layer and domain model layer 在Web方法,服务层或DAO层中创建服务响应? - Create service response in web method, service layer or DAO layer?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM