[英]spring boot: sending data to 1 endpoint but hiding from other
I have a simple spring boot application, my model contains 3 fields.我有一个简单的 Spring Boot 应用程序,我的模型包含 3 个字段。 and controller exposes 2 endpoints /e1 and /e2.
和控制器公开 2 个端点 /e1 和 /e2。 what I want to achieve is that when /e1 is called I want to return all 3 fields from my model by when /e2 is called I was to return just 2 fields and hiding the 3rd field from it.
我想要实现的是,当 /e1 被调用时,我想从我的模型中返回所有 3 个字段,当 /e2 被调用时,我只返回 2 个字段并从中隐藏第三个字段。
is there a way to do it and how this can be done ?有没有办法做到这一点以及如何做到这一点? thanks
谢谢
First, you should always have 2 classes - entity and its dto presentation - even if they fields are very similar.首先,您应该始终有 2 个类 - 实体及其 dto 表示 - 即使它们的字段非常相似。 This gives you:
这给你:
You might need bean mapper for converting entity to DTO.您可能需要bean 映射器将实体转换为 DTO。
Two solutions you can try either of them ..您可以尝试两种解决方案中的任何一种..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.