为什么我们必须将实体转换为 dto?
我试图了解春季靴子和建造REST API。
我已经看到一些项目创建了自己的转换器类或使用ModelMapper。但是我无法清楚地得到主要的想法。
为什么我们必须将实体转换为DTO?我找不到很多关于它的文档。你能帮助我吗?
我找到了两种不同的映射内容。
映射和模型模型。我应该使用哪一个?
I'm trying to understand Spring Boot and building Rest APIs.
I've seen some projects which is creates their own Converter class or which is using modelMapper. But I couldn't clearly get the main idea.
Why do we have to convert entities to DTOs? I could'nt find a lot of docs about it. Can you help me?
I've found two different things for mapping.
mapstruct and modelmapper. Which one should i use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
DTO代表数据传输对象,它们在许多情况下可能很有用。
由于实体代表数据库,并且具有直接创建的所有字段,例如。产品实体具有以下模式
名称:“字符串”,
desc:“ string”,
Quantity_number:整数,
Quantity_QOM:“字符串”,
MANTH_PRICE:200
MANTH_MEASER:“ USD”
DTO帮助我们以结构化的方式显示响应或请求,例如
我更喜欢ModelMapper的用法。
DTO Represents Data Transfer Objects, They can be useful in many situation.
Since the entity represents the database and has all fields created directly eg. a product entity has following schema
name: "String",
desc: "string",
quantity_number: integer,
quantity_qom: "string",
amount_price: 200
amount_measure: "USD"
DTO helps us show response or request in a structured manner like
Regarding the usage i prefer modelmapper.