首页 > 解决方案 > Java REST - 过滤要返回的信息

问题描述

是否有设计模式或众所周知的解决方案来设计 REST 服务,其中应用程序的前端可能会调用相同的 Web 服务以获取有关对象的不同信息。

例子:

WebServiceFull.class

@PATH('/car/')
public Response getCarInformation(@PathParam('id') long carId) {
   // Call Service/DAO
   // return the complete Car Object (may contain 50 properties for instance (color, size, age, factory, brand, ....)
}

我想知道是否可能/好:

WebServiceWanted.class
@PATH('/car/')
public Response getCarInformation(@PathParam('id') long carId, @QueryParam('info') List<String> infoWanted) {
   // Call Service/DAO with the List
   // Browse through the given list to only get from DataBase the needed info
   // return the partially complete Car Object
}

标签: javarest

解决方案


推荐阅读