嗨大家好我很容易问。
我使用CRUD方法创建了服务类,我必须为getObject方法创建Lambda类,通过id在数据库中查找对象,例如:
public Product getProduct(String id){
return dbService.get(Product.class, id);
}
我想在请求正文中发送id,但它不起作用:
public class GetProductLambda extends Lambda {
@Override
public ApiGatewayResponse handleRequest(Map<String, Object> input, Context context) {
super.handleRequest(input, context);
try {
String id = RequestUtil.parseRequestBody(input, String.class);
KitchenService kitchenService = appComponent.getKitchenService();
Product product = kitchenService.getProduct(id);
return ResponseUtil.generateResponse(HttpStatus.SC_OK, product);
} catch (IllegalArgumentException e) {
return ResponseUtil.generateResponse(HttpStatus.SC_BAD_REQUEST, e.getMessage());
}
}
}
有人可以告诉我需要改变什么吗?